Thanks for the great work putting things together for Mi Air Purifier.
I ported the automations for switch controls in the first post to Node-Red if anyone interested. (some entities name are changed)
[
{
"id": "93baa36e.9ebff",
"type": "server-state-changed",
"z": "52c9cd1c.793d94",
"name": "when mode switch is selected",
"server": "1c37c39d.61b2fc",
"version": 1,
"entityidfilter": "input_select.miair_mode",
"entityidfiltertype": "exact",
"outputinitially": false,
"state_type": "str",
"haltifstate": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"outputs": 1,
"output_only_on_state_change": true,
"x": 220,
"y": 440,
"wires": [
[
"10ae046f.c847bc"
]
]
},
{
"id": "10ae046f.c847bc",
"type": "api-call-service",
"z": "52c9cd1c.793d94",
"name": "set purifier mode",
"server": "1c37c39d.61b2fc",
"version": 1,
"debugenabled": true,
"service_domain": "fan",
"service": "set_speed",
"entityId": "fan.xiaomi_miio_device",
"data": "{\"speed\":\"{{payload}}\"}",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 490,
"y": 440,
"wires": [
[]
]
},
{
"id": "826c4203.6edcd",
"type": "server-state-changed",
"z": "52c9cd1c.793d94",
"name": "when purifier turned on",
"server": "1c37c39d.61b2fc",
"version": 1,
"entityidfilter": "fan.xiaomi_miio_device",
"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,
"x": 240,
"y": 520,
"wires": [
[
"a69f5269.141b3"
],
[]
]
},
{
"id": "a69f5269.141b3",
"type": "api-call-service",
"z": "52c9cd1c.793d94",
"name": "change input_select to running mode",
"server": "1c37c39d.61b2fc",
"version": 1,
"debugenabled": true,
"service_domain": "input_select",
"service": "select_option",
"entityId": "input_select.miair_mode",
"data": "{\"option\": \"{{data.new_state.attributes.speed}}\"}",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 550,
"y": 520,
"wires": [
[]
]
},
{
"id": "b64f1f25.c1eb1",
"type": "comment",
"z": "52c9cd1c.793d94",
"name": "Mi Air Purifier basic switch controls",
"info": "",
"x": 340,
"y": 380,
"wires": []
},
{
"id": "45cb24aa.f0f81c",
"type": "server-state-changed",
"z": "52c9cd1c.793d94",
"name": "when fav_level is selected",
"server": "1c37c39d.61b2fc",
"version": 1,
"entityidfilter": "input_number.miair_fav_level",
"entityidfiltertype": "exact",
"outputinitially": false,
"state_type": "num",
"haltifstate": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"outputs": 1,
"output_only_on_state_change": true,
"x": 230,
"y": 600,
"wires": [
[
"4a224d74.01fc04"
]
]
},
{
"id": "4a224d74.01fc04",
"type": "api-call-service",
"z": "52c9cd1c.793d94",
"name": "set purifier fav_level",
"server": "1c37c39d.61b2fc",
"version": 1,
"debugenabled": true,
"service_domain": "fan",
"service": "xiaomi_miio_set_favorite_level",
"entityId": "fan.xiaomi_miio_device",
"data": "{\"level\":\"{{payload}}\"}",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 500,
"y": 600,
"wires": [
[]
]
},
{
"id": "695f06ce.0372d8",
"type": "server-state-changed",
"z": "52c9cd1c.793d94",
"name": "when purifier turned on",
"server": "1c37c39d.61b2fc",
"version": 1,
"entityidfilter": "fan.xiaomi_miio_device",
"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,
"x": 240,
"y": 680,
"wires": [
[
"f73a9ba8.9848c8"
],
[]
]
},
{
"id": "f73a9ba8.9848c8",
"type": "api-call-service",
"z": "52c9cd1c.793d94",
"name": "change input_number to running level",
"server": "1c37c39d.61b2fc",
"version": 1,
"debugenabled": true,
"service_domain": "input_number",
"service": "set_value",
"entityId": "input_number.miair_fav_level",
"data": "{\"value\": \"{{data.new_state.attributes.favorite_level}}\"}",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 550,
"y": 680,
"wires": [
[]
]
},
{
"id": "1c37c39d.61b2fc",
"type": "server",
"z": "",
"name": "Home Assistant"
}
]