Home Assistant - Xiaomi Mi Air Purifier

Home Assistant - Xiaomi Mi Air Purifier

Do tej pory aby dowiedzieć się jak duże zanieczyszczenie mamy w mieszkaniu musiałem otworzyć telefon, wyszukać aplikację ze skrótem do oczyszczacza a następnie odczekać chwilę aż się załaduje. Obecnie mam to pod jednym kliknięciu na panelu HA. A gdy zanieczyszczenie będzie powyżej 8 AQI/PM2.5 to gdy jestem w domu otrzymuję powiadomienie na @ i oczyszczać się włącza.

Ważna informacja, wskazanie opisane jako AQI w HA jest równe PM2.5. Kto nie czytał o samym oczyszczaczu, tego zapraszam do tego artykułu: Xiaomi Mi Air Purifier 2s - tani w eksploatacji oczyszczacz powietrza, ta integracja działa z każdym oczyszczaczem Xiaomi (no prawie każdym). Sam obecnie używam obecnie Xiaomi Air Purifier PRO oraz  Mi Air Purifier 2s, ponieważ dynamicznie odczytują nawet najniższe AQI. Czego  Xiaomi Air Purifier 3H nie potrafi i ma opóźnienia. 

Drugą rzeczą jest to, że nawet gdy oczyszczacz jest wyłączony (czyli tak naprawdę w trybie czuwania). To cały czas mamy dostęp do tych informacji i możemy je wykorzystać w automatyzacjach. 

Integracja

Obecnie nie musimy już pobierać tokena, przejdź od razu do konfiguracji. 

Największym "problemem" jest wyciągnięcie tokena, jak to zrobić opisuję tutaj: Xiaomi o co chodzi z tymi regionami Europa / Chiny i dlaczego to jest tak ważne - sam koniec artykułu. Jednak tym razem postanowiłem skorzystać z emulatora androida czyli BlueStacks, ściągnąłem na niego specjalną wersję aplikacji i nie trzeba nic instalować na telefonie. Więc jedyną zmianą względem poprzedniego opisu jest skorzystanie z emulatora zamiast usuwać i instalować na nowo aplikację na telefonie ;) 

Konfiguracja

Gdy już mamy token, to do configuration.ymla  Przechodzimy do Configuration -> Integrations -> wybieramy o ile się nam nie pojawi automatycznie wykryte urządzenie + i uzupełniamy dane.

Pamiętajcie aby wybrać odpowiedni region.

Jak mamy na serwerze PL, to tak naprawdę wybieramy DE w cloud server country.

Przechodzimy do Configuration -> Devices -> nasz oczyszczacz. 

I możemy sobie odczytać każdą zmienną, jak widzicie dużo się zmieniło, wszystko jest od razu dostępne.

Jak widzicie jest ona trochę zmodyfikowana ponieważ wyjąłem na wierzch trzy informacje a zrobiłem to następująco, do pliku configuration.yaml dodałem: 

A zakładkę skonfigurowałem następująco: 

Dzięki temu mamy od razu 3 parametry dostępne zawsze w karcie oczyszczacza. Dodatkowo wyciągnąłem je od razu na górę aby mieć podgląd cały czas na parametry tego pomieszczenia:

Automatyzacje w nodeRED

Jeżeli masz oczyszczacz z europejskiej dystrybucji tak jak ja to nie masz rozbudowanych automatyzacji. Mnie osobiście mega irytowało, że np. chodzi całą noc nawet jeżeli jest ok. 1 AQI albo idziemy spać a w nocy AQI podskakuje (bo zmienia się ciśnienie i wiatr) i przydało by się aby powietrze oczyścił.

Obecnie rozwijam automatyzacje i dużo przeniosłem właśnie tutaj wygląda to tak

Kod do skopiowania:

[
    {
        "id": "81ed7611.e5c5b8",
        "type": "server-state-changed",
        "z": "e47906ea.f77ce8",
        "name": "Group Living On",
        "server": "b3e9b226.7fd0c",
        "version": 3,
        "entityidfilter": "group.living_room_lights_cinema",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 2,
        "output_only_on_state_change": true,
        "for": "0",
        "forType": "num",
        "forUnits": "minutes",
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "eventData"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "",
                "valueType": "triggerId"
            }
        ],
        "x": 100,
        "y": 260,
        "wires": [
            [
                "af4a988d.1aae18"
            ],
            [
                "af4a988d.1aae18"
            ]
        ]
    },
    {
        "id": "af4a988d.1aae18",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "AQI >10?",
        "server": "b3e9b226.7fd0c",
        "version": 2,
        "outputs": 2,
        "halt_if": "10",
        "halt_if_type": "num",
        "halt_if_compare": "gt",
        "entity_id": "sensor.mi_aqi",
        "state_type": "num",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "x": 380,
        "y": 140,
        "wires": [
            [
                "fb14ba06.3a2ff8"
            ],
            [
                "58aee37b.1766ec"
            ]
        ]
    },
    {
        "id": "b9242c97.d21c8",
        "type": "server-state-changed",
        "z": "e47906ea.f77ce8",
        "name": "AQI >10",
        "server": "b3e9b226.7fd0c",
        "version": 3,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "sensor.mi_aqi",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "num",
        "haltifstate": "10",
        "halt_if_type": "num",
        "halt_if_compare": "gt",
        "outputs": 2,
        "output_only_on_state_change": true,
        "for": "5",
        "forType": "num",
        "forUnits": "minutes",
        "ignorePrevStateNull": false,
        "ignorePrevStateUnknown": false,
        "ignorePrevStateUnavailable": false,
        "ignoreCurrentStateUnknown": false,
        "ignoreCurrentStateUnavailable": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "eventData"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "",
                "valueType": "triggerId"
            }
        ],
        "x": 100,
        "y": 140,
        "wires": [
            [
                "af4a988d.1aae18"
            ],
            [
                "8825f750.327f68"
            ]
        ]
    },
    {
        "id": "c3e13ea.6eb80c",
        "type": "server-state-changed",
        "z": "e47906ea.f77ce8",
        "name": "Awesome w domu",
        "server": "b3e9b226.7fd0c",
        "version": 3,
        "entityidfilter": "group.awesome_people",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "home",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 2,
        "output_only_on_state_change": true,
        "for": "0",
        "forType": "num",
        "forUnits": "minutes",
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "eventData"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "",
                "valueType": "triggerId"
            }
        ],
        "x": 130,
        "y": 80,
        "wires": [
            [
                "af4a988d.1aae18"
            ],
            [
                "58aee37b.1766ec"
            ]
        ]
    },
    {
        "id": "4ccd7b1c.d74494",
        "type": "inject",
        "z": "e47906ea.f77ce8",
        "name": "23:01",
        "repeat": "",
        "crontab": "01 23 * * *",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 90,
        "y": 360,
        "wires": [
            [
                "af4a988d.1aae18",
                "99f6af8dd361680d"
            ]
        ]
    },
    {
        "id": "bdb49c18.afc42",
        "type": "inject",
        "z": "e47906ea.f77ce8",
        "name": "10:01",
        "repeat": "",
        "crontab": "01 10 * * *",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 90,
        "y": 320,
        "wires": [
            [
                "af4a988d.1aae18",
                "99f6af8dd361680d"
            ]
        ]
    },
    {
        "id": "36c17c72.1d7044",
        "type": "server-state-changed",
        "z": "e47906ea.f77ce8",
        "name": "AQI >25",
        "server": "b3e9b226.7fd0c",
        "version": 3,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "sensor.mi_aqi",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "num",
        "haltifstate": "25",
        "halt_if_type": "num",
        "halt_if_compare": "gt",
        "outputs": 2,
        "output_only_on_state_change": true,
        "for": "",
        "forType": "num",
        "forUnits": "minutes",
        "ignorePrevStateNull": false,
        "ignorePrevStateUnknown": false,
        "ignorePrevStateUnavailable": false,
        "ignoreCurrentStateUnknown": false,
        "ignoreCurrentStateUnavailable": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "eventData"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "",
                "valueType": "triggerId"
            }
        ],
        "x": 80,
        "y": 200,
        "wires": [
            [
                "af4a988d.1aae18"
            ],
            [
                "af4a988d.1aae18"
            ]
        ]
    },
    {
        "id": "fb14ba06.3a2ff8",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Awesowme w domu?",
        "server": "b3e9b226.7fd0c",
        "version": 2,
        "outputs": 2,
        "halt_if": "home",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "group.awesome_people",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "x": 600,
        "y": 140,
        "wires": [
            [
                "688dec1d.2e5364"
            ],
            [
                "58aee37b.1766ec"
            ]
        ]
    },
    {
        "id": "58aee37b.1766ec",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Mi Air On?",
        "server": "b3e9b226.7fd0c",
        "version": 2,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "fan.xiaomi_miio_device",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "x": 890,
        "y": 80,
        "wires": [
            [
                "a0fe792028d1f8e0"
            ],
            []
        ]
    },
    {
        "id": "8825f750.327f68",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Script Clan Air on (fav=10)?",
        "server": "b3e9b226.7fd0c",
        "version": 2,
        "outputs": 2,
        "halt_if": "10",
        "halt_if_type": "num",
        "halt_if_compare": "is",
        "entity_id": "number.air_purifier_favorite_level",
        "state_type": "num",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "x": 520,
        "y": 60,
        "wires": [
            [],
            [
                "58aee37b.1766ec"
            ]
        ]
    },
    {
        "id": "99f6af8dd361680d",
        "type": "api-call-service",
        "z": "e47906ea.f77ce8",
        "name": "Purifier alwasy on -> off",
        "server": "b3e9b226.7fd0c",
        "version": 3,
        "debugenabled": false,
        "service_domain": "input_boolean",
        "service": "turn_off",
        "entityId": "input_boolean.purifier_always_on",
        "data": "",
        "dataType": "json",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 190,
        "y": 460,
        "wires": [
            []
        ]
    },
    {
        "id": "688dec1d.2e5364",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Window bedroom Open?",
        "server": "b3e9b226.7fd0c",
        "version": 2,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "binary_sensor.bedroom_window",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "x": 410,
        "y": 220,
        "wires": [
            [
                "a0fe792028d1f8e0"
            ],
            [
                "277aa483.79b65c"
            ]
        ]
    },
    {
        "id": "e66e7d3e.e6224",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "AQI <10?",
        "server": "b3e9b226.7fd0c",
        "version": 2,
        "outputs": 2,
        "halt_if": "10",
        "halt_if_type": "num",
        "halt_if_compare": "lt",
        "entity_id": "sensor.mi_aqi",
        "state_type": "num",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "x": 920,
        "y": 200,
        "wires": [
            [
                "58aee37b.1766ec"
            ],
            [
                "45d9e07f.596f9"
            ]
        ]
    },
    {
        "id": "a0fe792028d1f8e0",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Purifier always on?",
        "server": "b3e9b226.7fd0c",
        "version": 2,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "input_boolean.purifier_always_on",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "x": 1230,
        "y": 80,
        "wires": [
            [],
            [
                "79353a5b8592df6b"
            ]
        ]
    },
    {
        "id": "277aa483.79b65c",
        "type": "trigger",
        "z": "e47906ea.f77ce8",
        "name": "",
        "op1": "",
        "op2": "",
        "op1type": "nul",
        "op2type": "payl",
        "duration": "2",
        "extend": false,
        "units": "min",
        "reset": "",
        "bytopic": "all",
        "outputs": 1,
        "x": 630,
        "y": 240,
        "wires": [
            [
                "edca11d8.439f3"
            ]
        ]
    },
    {
        "id": "6fa03be2.5a5e84",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "d": true,
        "name": "Group Office On?",
        "server": "b3e9b226.7fd0c",
        "version": 2,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "group.office_work_time",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "x": 570,
        "y": 500,
        "wires": [
            [
                "e66e7d3e.e6224"
            ],
            [
                "60960bcf.df5884"
            ]
        ]
    },
    {
        "id": "65f46ba6.1833c4",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "d": true,
        "name": "Kate computer On?",
        "server": "b3e9b226.7fd0c",
        "version": 2,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "switch.kate_computer",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "x": 570,
        "y": 580,
        "wires": [
            [
                "60960bcf.df5884"
            ],
            [
                "e66e7d3e.e6224"
            ]
        ]
    },
    {
        "id": "dbecaeb.c3a7d5",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Nap time",
        "server": "b3e9b226.7fd0c",
        "version": 2,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "input_boolean.nap_time",
        "state_type": "num",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "x": 720,
        "y": 320,
        "wires": [
            [
                "60960bcf.df5884"
            ],
            [
                "e66e7d3e.e6224"
            ]
        ]
    },
    {
        "id": "45d9e07f.596f9",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Mi Air On?",
        "server": "b3e9b226.7fd0c",
        "version": 2,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "fan.xiaomi_miio_device",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "x": 1150,
        "y": 140,
        "wires": [
            [
                "2430bc86.2f22c4"
            ],
            [
                "aa242636.1a7c88"
            ]
        ]
    },
    {
        "id": "d9ccbcab.2ff7f",
        "type": "server-state-changed",
        "z": "e47906ea.f77ce8",
        "name": "Window bedroom Open?",
        "server": "b3e9b226.7fd0c",
        "version": 3,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "binary_sensor.bedroom_window",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 2,
        "output_only_on_state_change": true,
        "for": "",
        "forType": "num",
        "forUnits": "minutes",
        "ignorePrevStateNull": false,
        "ignorePrevStateUnknown": false,
        "ignorePrevStateUnavailable": false,
        "ignoreCurrentStateUnknown": false,
        "ignoreCurrentStateUnavailable": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "eventData"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "",
                "valueType": "triggerId"
            }
        ],
        "x": 150,
        "y": 20,
        "wires": [
            [
                "a0fe792028d1f8e0"
            ],
            []
        ]
    },
    {
        "id": "79353a5b8592df6b",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Mi Air On?",
        "server": "b3e9b226.7fd0c",
        "version": 2,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "fan.xiaomi_miio_device",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "x": 1410,
        "y": 60,
        "wires": [
            [
                "a5f2c93e2b0ab1cd"
            ],
            []
        ]
    },
    {
        "id": "edca11d8.439f3",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Script Clan Air on (fav=10)?",
        "server": "b3e9b226.7fd0c",
        "version": 2,
        "outputs": 2,
        "halt_if": "10",
        "halt_if_type": "num",
        "halt_if_compare": "is",
        "entity_id": "number.air_purifier_favorite_level",
        "state_type": "num",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "x": 480,
        "y": 300,
        "wires": [
            [
                "c9c4520f.da863"
            ],
            [
                "9c9be614.2f89b8"
            ]
        ]
    },
    {
        "id": "9c9be614.2f89b8",
        "type": "time-range-switch",
        "z": "e47906ea.f77ce8",
        "name": "",
        "lat": "50.2443",
        "lon": "19.04186",
        "startTime": "10:00",
        "endTime": "23:00",
        "startOffset": 0,
        "endOffset": 0,
        "x": 590,
        "y": 380,
        "wires": [
            [
                "dbecaeb.c3a7d5"
            ],
            [
                "b8ea7a42.c8a8b8",
                "6fa03be2.5a5e84",
                "60960bcf.df5884"
            ]
        ]
    },
    {
        "id": "60960bcf.df5884",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Mi Air On?",
        "server": "b3e9b226.7fd0c",
        "version": 2,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "fan.xiaomi_miio_device",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "x": 850,
        "y": 520,
        "wires": [
            [
                "1e36a12a.1fdc4f"
            ],
            [
                "94db704f.d2574"
            ]
        ]
    },
    {
        "id": "b8ea7a42.c8a8b8",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "d": true,
        "name": "Group Living On?",
        "server": "b3e9b226.7fd0c",
        "version": 2,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "group.living_room_lights_cinema",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "x": 510,
        "y": 660,
        "wires": [
            [
                "65f46ba6.1833c4"
            ],
            [
                "60960bcf.df5884"
            ]
        ]
    },
    {
        "id": "2430bc86.2f22c4",
        "type": "trigger",
        "z": "e47906ea.f77ce8",
        "name": "",
        "op1": "",
        "op2": "{\"occupancy\":false}",
        "op1type": "nul",
        "op2type": "json",
        "duration": "15",
        "extend": true,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "outputs": 1,
        "x": 1390,
        "y": 180,
        "wires": [
            [
                "f1f02778.27d4a8"
            ]
        ]
    },
    {
        "id": "aa242636.1a7c88",
        "type": "api-call-service",
        "z": "e47906ea.f77ce8",
        "name": "Fan On",
        "server": "b3e9b226.7fd0c",
        "version": 3,
        "debugenabled": false,
        "service_domain": "fan",
        "service": "turn_on",
        "entityId": "fan.xiaomi_miio_device",
        "data": "",
        "dataType": "json",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 1160,
        "y": 200,
        "wires": [
            [
                "2430bc86.2f22c4"
            ]
        ]
    },
    {
        "id": "a5f2c93e2b0ab1cd",
        "type": "api-call-service",
        "z": "e47906ea.f77ce8",
        "name": "Fan set auto",
        "server": "b3e9b226.7fd0c",
        "version": 3,
        "debugenabled": false,
        "service_domain": "fan",
        "service": "set_preset_mode",
        "entityId": "fan.xiaomi_miio_device",
        "data": "{\"preset_mode\":\"Auto\"}",
        "dataType": "json",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 1570,
        "y": 60,
        "wires": [
            [
                "b9242cb1245a1301"
            ]
        ]
    },
    {
        "id": "c9c4520f.da863",
        "type": "trigger",
        "z": "e47906ea.f77ce8",
        "name": "",
        "op1": "",
        "op2": "",
        "op1type": "nul",
        "op2type": "payl",
        "duration": "13",
        "extend": false,
        "units": "min",
        "reset": "",
        "bytopic": "all",
        "outputs": 1,
        "x": 310,
        "y": 380,
        "wires": [
            [
                "d4764c812f59ec16"
            ]
        ]
    },
    {
        "id": "d4764c812f59ec16",
        "type": "api-call-service",
        "z": "e47906ea.f77ce8",
        "name": "Fan set speed 5",
        "server": "b3e9b226.7fd0c",
        "version": 3,
        "debugenabled": false,
        "service_domain": "number",
        "service": "set_value",
        "entityId": "number.air_purifier_favorite_level",
        "data": "{\"value\":5}",
        "dataType": "json",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 360,
        "y": 440,
        "wires": [
            [
                "9c9be614.2f89b8"
            ]
        ]
    },
    {
        "id": "1e36a12a.1fdc4f",
        "type": "api-call-service",
        "z": "e47906ea.f77ce8",
        "name": "Fan set silent",
        "server": "b3e9b226.7fd0c",
        "version": 3,
        "debugenabled": false,
        "service_domain": "fan",
        "service": "set_preset_mode",
        "entityId": "fan.xiaomi_miio_device",
        "data": "{\"preset_mode\":\"Silent\"}",
        "dataType": "json",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 1210,
        "y": 580,
        "wires": [
            []
        ]
    },
    {
        "id": "94db704f.d2574",
        "type": "api-call-service",
        "z": "e47906ea.f77ce8",
        "name": "Fan On",
        "server": "b3e9b226.7fd0c",
        "version": 3,
        "debugenabled": false,
        "service_domain": "fan",
        "service": "turn_on",
        "entityId": "fan.xiaomi_miio_device",
        "data": "",
        "dataType": "json",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 840,
        "y": 580,
        "wires": [
            [
                "ae44ab41.548638"
            ]
        ]
    },
    {
        "id": "f1f02778.27d4a8",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "AQI <20",
        "server": "b3e9b226.7fd0c",
        "version": 2,
        "outputs": 2,
        "halt_if": "20",
        "halt_if_type": "num",
        "halt_if_compare": "lt",
        "entity_id": "sensor.mi_aqi",
        "state_type": "num",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "x": 920,
        "y": 280,
        "wires": [
            [
                "7f5e2154.42451"
            ],
            [
                "644d03bf.2ef8bc"
            ]
        ]
    },
    {
        "id": "b9242cb1245a1301",
        "type": "trigger",
        "z": "e47906ea.f77ce8",
        "name": "",
        "op1": "",
        "op2": "{\"occupancy\":false}",
        "op1type": "nul",
        "op2type": "json",
        "duration": "5",
        "extend": true,
        "overrideDelay": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 1460,
        "y": 120,
        "wires": [
            [
                "d791a7f4.68ea28"
            ]
        ]
    },
    {
        "id": "ae44ab41.548638",
        "type": "trigger",
        "z": "e47906ea.f77ce8",
        "name": "",
        "op1": "",
        "op2": "{\"occupancy\":false}",
        "op1type": "nul",
        "op2type": "json",
        "duration": "5",
        "extend": true,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "outputs": 1,
        "x": 1000,
        "y": 600,
        "wires": [
            [
                "1e36a12a.1fdc4f"
            ]
        ]
    },
    {
        "id": "7f5e2154.42451",
        "type": "api-call-service",
        "z": "e47906ea.f77ce8",
        "name": "Fan set auto",
        "server": "b3e9b226.7fd0c",
        "version": 3,
        "debugenabled": false,
        "service_domain": "fan",
        "service": "set_preset_mode",
        "entityId": "fan.xiaomi_miio_device",
        "data": "{\"preset_mode\":\"Auto\"}",
        "dataType": "json",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 1130,
        "y": 300,
        "wires": [
            []
        ]
    },
    {
        "id": "644d03bf.2ef8bc",
        "type": "api-call-service",
        "z": "e47906ea.f77ce8",
        "name": "Fan set favorite",
        "server": "b3e9b226.7fd0c",
        "version": 3,
        "debugenabled": false,
        "service_domain": "fan",
        "service": "set_preset_mode",
        "entityId": "fan.xiaomi_miio_device",
        "data": "{\"preset_mode\":\"Favorite\"}",
        "dataType": "json",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 940,
        "y": 340,
        "wires": [
            [
                "d8f6ee23.06204"
            ]
        ]
    },
    {
        "id": "d791a7f4.68ea28",
        "type": "api-call-service",
        "z": "e47906ea.f77ce8",
        "name": "Fan OFF",
        "server": "b3e9b226.7fd0c",
        "version": 3,
        "debugenabled": false,
        "service_domain": "fan",
        "service": "turn_off",
        "entityId": "fan.xiaomi_miio_device",
        "data": "",
        "dataType": "json",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 1600,
        "y": 120,
        "wires": [
            []
        ]
    },
    {
        "id": "d8f6ee23.06204",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "AQI <30",
        "server": "b3e9b226.7fd0c",
        "version": 2,
        "outputs": 2,
        "halt_if": "30",
        "halt_if_type": "num",
        "halt_if_compare": "lt",
        "entity_id": "sensor.mi_aqi",
        "state_type": "num",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "x": 980,
        "y": 400,
        "wires": [
            [
                "7f47cd6d81cc5a8e"
            ],
            [
                "c2cf29f6.5ecd58"
            ]
        ]
    },
    {
        "id": "632c7cca8e7edf1e",
        "type": "inject",
        "z": "e47906ea.f77ce8",
        "name": "",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 780,
        "y": 420,
        "wires": [
            [
                "d8f6ee23.06204"
            ]
        ]
    },
    {
        "id": "7f47cd6d81cc5a8e",
        "type": "api-call-service",
        "z": "e47906ea.f77ce8",
        "name": "Fan set speed 5",
        "server": "b3e9b226.7fd0c",
        "version": 3,
        "debugenabled": false,
        "service_domain": "number",
        "service": "set_value",
        "entityId": "number.air_purifier_favorite_level",
        "data": "{\"value\":5}",
        "dataType": "json",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 1380,
        "y": 380,
        "wires": [
            []
        ]
    },
    {
        "id": "c2cf29f6.5ecd58",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "AQI <40",
        "server": "b3e9b226.7fd0c",
        "version": 2,
        "outputs": 2,
        "halt_if": "40",
        "halt_if_type": "num",
        "halt_if_compare": "lt",
        "entity_id": "sensor.mi_aqi",
        "state_type": "num",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "x": 1020,
        "y": 460,
        "wires": [
            [
                "46bd268255898103"
            ],
            [
                "20690eba8b65fa5e"
            ]
        ]
    },
    {
        "id": "46bd268255898103",
        "type": "api-call-service",
        "z": "e47906ea.f77ce8",
        "name": "Fan set speed 8",
        "server": "b3e9b226.7fd0c",
        "version": 3,
        "debugenabled": false,
        "service_domain": "number",
        "service": "set_value",
        "entityId": "number.air_purifier_favorite_level",
        "data": "{\"value\":8}",
        "dataType": "json",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 1200,
        "y": 460,
        "wires": [
            []
        ]
    },
    {
        "id": "20690eba8b65fa5e",
        "type": "api-call-service",
        "z": "e47906ea.f77ce8",
        "name": "Fan set speed 14",
        "server": "b3e9b226.7fd0c",
        "version": 3,
        "debugenabled": false,
        "service_domain": "number",
        "service": "set_value",
        "entityId": "number.air_purifier_favorite_level",
        "data": "{\"value\":14}",
        "dataType": "json",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 1210,
        "y": 520,
        "wires": [
            []
        ]
    },
    {
        "id": "b3e9b226.7fd0c",
        "type": "server",
        "name": "Home Assistant",
        "version": 1,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true
    }
]

Jak widzicie ostro pojechałem do tego mam skrypt maksymalnego oczyszczania.

clean_air:
  alias: Clean air
  sequence:
  - service: fan.turn_on  
    entity_id: fan.xiaomi_miio_device
  - service: fan.set_preset_mode
    entity_id: fan.xiaomi_miio_device
    data:
      preset_mode: Favorite
  - service: number.set_value
    data_template:
      entity_id: number.air_purifier_favorite_level
      value: 10

Uwagi

Uwaga 1: od grudnia 2020 zmieniło się servicefan_set_favorite_level oraz domainxiaomi_miio (ważne zwłaszcza w nodeRED).

Uwaga 2: model 2s ma 14 poziomów favorite a nie 16 jak pozostałe modele. 

Uwaga 3: od września 2021 zmieniła się dostępność do AQI itp. nie jest to już template tylko od razu dostępny sensor. Dlatego aby nie przerabiać wszystkiego, wystarczy tutaj zmienić Entity ID na taką jaką używamy w automatyzacji. 

U mnie zmieniłem: sensor.air_purifier_humidity - który nadała mi integracja na to co używałem wcześniej czyli sensor.mi_humidity tak jak poniżej:

Po tym zabiegu restart całej maszyny i wszystko będzie działało i wyświetlało się jak wcześniej. 

Uwaga 4: od września 2021 zmienił się też sposób ustalania number.air_purifier_favorite_level

To bardzo ważne aby automatyzacje (nie tylko w nodered działały). 

 


Źródła: 

https://community.home-assistant.io/t/automating-air-purifiers/81745/6 

https://www.home-assistant.io/integrations/fan.xiaomi_miio

Chcesz wiedzieć więcej? Dołącz do grupy na FB. Będzie nam też miło jak polubisz Fanpage!

Głośnik Google Home - średni

Od: 99 zł 199 zł | Powiadom gdy cena spadnie

Podstawowy głośnik Google, na którym da się już słuchać muzyki, a nie tylko wiadomości czy wyników naszych poleceń. Głośnik ma zaskakująco dobre parametry muzyczne i bardzo fajny panel sterujący. Idealnie pasuje do kuchni (wygląda jak słoik).

Dziwi brak reklam? Przeczytaj dlaczego i wesprzyj bloga na  ||