Need help with xiaomi air purifier

How do i set favorite speed in node-red for xiaomi air purifier.
Since i’m using EU version and EU server it lacks automotion in app. I want to set favorite level based on AQI level i can extract aqi level and speed but how do I set speed ?
My current automotion:

[{"id":"16ba5014.5977c","type":"server-events","z":"62680cb3.8eee74","name":"","server":"db5e6215.95c2","event_type":"","x":115.5,"y":206,"wires":[["8f4df04.c4ea91"]]},{"id":"8f4df04.c4ea91","type":"switch","z":"62680cb3.8eee74","name":"","property":"payload.entity_id","propertyType":"msg","rules":[{"t":"eq","v":"fan.air_purifier","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":262,"y":203,"wires":[["929cca32.09a5c8"]]},{"id":"929cca32.09a5c8","type":"switch","z":"62680cb3.8eee74","name":"","property":"payload.event.new_state.attributes.aqi","propertyType":"msg","rules":[{"t":"lt","v":"30","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":398,"y":212,"wires":[["c5352919.860658","154d0145.b808cf"]]},{"id":"c5352919.860658","type":"api-call-service","z":"62680cb3.8eee74","name":"","server":"db5e6215.95c2","version":1,"service_domain":"homeassistant","service":"update_entity","entityId":"fan.air.purifier","data":"{\"level\":1}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":651.5,"y":258,"wires":[[]]},{"id":"154d0145.b808cf","type":"debug","z":"62680cb3.8eee74","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":580,"y":181,"wires":[]},{"id":"db5e6215.95c2","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]

For me the air purifier shows up as a fan in my Home Assistant. The Favorite is just a speed setting. So you would use the service fan.set_speed

fan speed is for mode “auto, silent, favorite” I need to change attribute favorite level

{
  "speed_list": [
    "Auto",
    "Silent",
    "Favorite"
  ],
  "model": "zhimi.airpurifier.mc1",
  "temperature": 24,
  "humidity": 55,
  "aqi": 232,
  "mode": "favorite",
  "filter_hours_used": 75,
  "filter_life_remaining": 97,
  "favorite_level": 2,
  "child_lock": false,
  "led": true,
  "motor_speed": 0,
  "average_aqi": 50,
  "learn_mode": false,
  "extra_features": 0,
  "turbo_mode_supported": false,
  "button_pressed": "power",
  "buzzer": false,
  "friendly_name": "Air Purifier",
  "supported_features": 1
}

Ah, i dont think thats possible outside the MiHome app. Also doesnt work from Home Assistant directly afaik.

I can update it via homeassistant directly but dont know how to do it via node. It can be updated via home assisatant services
xiaomi%20fan

Ah ok. Then its the same way.
I exported a service call:

[
    {
        "id": "5bfeab81.d675f4",
        "type": "api-call-service",
        "z": "6b8efe0d.bc75e",
        "name": "",
        "server": "2fba4297.e4145e",
        "version": 1,
        "service_domain": "fan",
        "service": "xiaomi_miio_set_favorite_level",
        "entityId": "fan.xiaomi_miio_device",
        "data": "{\"level\":\"10\"}",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 230,
        "y": 240,
        "wires": [
            []
        ]
    },
    {
        "id": "2fba4297.e4145e",
        "type": "server",
        "z": "",
        "name": "Home Assistant",
        "legacy": false,
        "hassio": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true
    }
]

Its woking :slight_smile: . Thank You

From today you need change the domain to: xiaomi_miio and then service!

[
    {
        "id": "59aea196.7a6a1",
        "type": "api-call-service",
        "z": "e47906ea.f77ce8",
        "name": "Fan set speed 5",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "debugenabled": false,
        "service_domain": "xiaomi_miio",
        "service": "fan_set_favorite_level",
        "entityId": "fan.xiaomi_miio_device",
        "data": "{\"level\":\"5\"}",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 1160,
        "y": 380,
        "wires": [
            []
        ]
    },
    {
        "id": "b3e9b226.7fd0c",
        "type": "server",
        "z": "",
        "name": "Home Assistant"
    }
]
1 Like