Xiaomi mi wifi plug & air purifier

The service is called fan.set_speed and the parameter must be speed:

- alias: 'xiaomi fan test silent'        
  trigger:
  action:
    - service: persistent_notification.create
      data:
        message: "I just turned the fan onto silent mode"
        title: "Fan Notification"
    - service: fan.set_speed
      entity_id: fan.MYAIRPURIFIER
      data:
        speed: 'silent'
1 Like

Thanks, just in case anyone searches into this thread, to set favorite level the syntax is:

- alias: 'set fan favorite level to 12'
  trigger:
  action:
    - service: FAN.XIAOMI_MIIO_SET_FAVORITE_LEVEL
      entity_id: fan.xiaomairpurifier
      data:
        level: '12'

@kiwijunglist Just a hint: The styling of a headline at the documentation is in uppercase. You can use the service name in lower case too: fan.xiaomi_miio_set_favorite_level

1 Like

cheers, Iā€™m new to all of this, just started automations yesterday, and Iā€™m not in the IT profession :stuck_out_tongue:

when Iā€™m writing automations, I make frequent syntax mistakes (eg too many spaces, or forget a colon or something like that). To quick check my automation.yaml is correct I click reload automations and if there is an error then it shows up as a persistant notification is hass.

however Iā€™d quite like to know what line # my error is on, when I use check config in hassio, it frequently only tells me the line # error in the configutation file that corresponds to automation: !include automations.yaml , is there a trick to making my life easier?

Try to use a YAML capable editor. Writing YAML files is error-prone if you are unfocused. :wink:

1 Like

im using notepad++

Hereā€™s an example of a mistake i just made, took quite a while to figure it out

- alias: 'I couldn't find this mistake for a while'
# using ' inside '....' marks

Hey,

Thank you for setting up this component, it works fantastically!

I am trying to setup a pull down menu so I can set the mode for the fan.

Its all working with the following code:

Configuration:

input_select:
  xiaomi_mode:
    name: Air Purifier Mode
    options:
     - auto
     - favorite
     - silent
     - idle

Automation:

- id: xiaomi_mode
  alias: Xiaomi Mode
  trigger:
    platform: state
    entity_id: input_select.xiaomi_mode
  action:
    - service: FAN.SET_SPEED
      data_template:
        entity_id: fan.xiaomi_miio_device
        speed: '{{ states.input_select.xiaomi_mode.state }}'

The only thing left Iā€™d like to do is have the pull down automatically changed if a automation or the mi home app changes the mode. I know this shouldnā€™t be too hard but Im having difficulties finding some good instructions or code to copy. Can someone point me in the right direction?

Edit: sinker1345 on the discord came up with this for me:

  • alias: Set input select on Xiaomi mode HIDE
    trigger:
    • platform: state
      entity_id: sensor.bedroom_air_purifier_mode
      to: ā€˜autoā€™
    • platform: state
      entity_id: sensor.bedroom_air_purifier_mode
      to: ā€˜favoriteā€™
    • platform: state
      entity_id: sensor.bedroom_air_purifier_mode
      to: ā€˜silentā€™
    • platform: state
      entity_id: sensor.bedroom_air_purifier_mode
      to: ā€˜idleā€™
      action:
    • service: input_select.select_option
      data_template:
      entity_id: input_select.xiaomi_mode
      option: >
      {% if states.sensor.bedroom_air_purifier_mode.state == ā€˜autoā€™ %}
      auto
      {% endif %}
      {% if states.sensor.bedroom_air_purifier_mode.state == ā€˜favoriteā€™ %}
      favorite
      {% endif %}
      {% if states.sensor.bedroom_air_purifier_mode.state == ā€˜silentā€™ %}
      silent
      {% endif %}
      {% if states.sensor.bedroom_air_purifier_mode.state == ā€˜idleā€™ %}
      idle
      {% endif %}

Thanks!

hi. i think itā€™s easier to just trigger on state change rather then including all different state for updating your input_select

  trigger:
    - platform: state
      entity_id: fan.air_purifier
  action:
    - service: input_select.select_option
      data_template:
        entity_id: input_select.xiaomi_mode
        option: '{{states.fan.air_purifier.state}}'

Thanks, that works better.

How do you get the token of ZNCZ02CM ?
I have the same but Iā€™m spending my whole day to looking for a method.
Older versions of mi home doesnā€™t support for ZNCZ02CM, isnt it?