Xiaomi Air Purifier - Show all sensors and Switches in UI and HomeKit

This is a good idea. If it doesn’t work, then you should check for any problems in the pairing procedure.
Check this:
Connecting Mi Air Purifier to a phone

Oh you do use an Android device. Goooooood. :wink:

You tried this method: https://github.com/Maxmudjon/com.xiaomi-miio/blob/ed0428f96ab3fdaa26fffacd864681c9496aa267/docs/obtain_token.md#android-users

If so, I personally find it way easier with the original method listed on the HA components page:

What I’ve done was the following:

  • Got the MiHomeApp in version v5.4.49 from apkmirror and installed it on the phone.
  • Setup the Air Purifier in the app. If this works, meaning you can control your purifier from within the app, then move to the next step.
  • Look for the mentioned file in Smarthome/logs and copy the content of the file into a whatsapp message or whatever, where you can paste in all the content of the file (or files) and send it to your computer.
  • Save this message content to a txt file in windows (assuming you run windows on your PC/Laptop) => whats app web to copy the content.
  • Then use any editor you like to search the file/files with the search function of the editor. Problem is, there can be a few tokens listed in this file. If so, try one token after the other, beginning with the last found.

I had the problem myself, and couldn’t connect to the Air Purifier at first. After that, I searched the files again, turned out, there was a second token, and that one worked like a charme. :smiley:

Let us know, how things turn out. :slight_smile:

PS: If you have it running with HA you can uninstall the app from your phone (you never know with chinese apps…). As long as you don’t change your WIFI settings, the token stays valid. If you later need to change, you have to do this again. I left the downloaded app in my donwloads folder on the phone, so if I need it (because of the specific version), I can easily install and delete it again. :slight_smile:

Hi. I will try this version then. I get back how it goes :slight_smile:

Hi, I’m new in Home Assistant.
I’ve had configured my purifier as explained above, but values of the sensors like air quality or temperature remains as “None”.
Is there any solution to this problem?

Hello
I have the same issue, the only thing that works is the on/off. It will not show other sensors. Anyone who can help?

Hello
My purifier will not show any info, just the on/off?

1 Like

No,
You should have all the data coming from the sensors (fan speed, filter hours remaining, led on/off, etc etc).
Have you configured all the sensors, switches, inputs and automations?
Automations are very important too…

Check all the stuff at the top of this thread and follow the @MickL ‘s instructions …

@miguelmieres580 and @KePeSWE
Which model type did you assign in your configuration?

Hi. Ok i just picked out some of @MickL .yaml.

@paddy0174 this is what i have in the fan.yaml

xiaomi purifier 2H in closet

  • platform: xiaomi_miio

    name: “Xiaomi Air Purifier 2H Closet”

    host: 192.168.10.xxx

    token: mytoken

Where do i put the info in “cards:” ?

Try it with this model type:

- platform: xiaomi_miio
  host: !secret host_air_purifier_2h
  token: !secret mi_home_app_token
  model: zhimi.airpurifier.ma2
  name: Livingroom Mi Air Purifier 2H

The model types are listed here:

Hi @paddy0174
I did use your config, but i still dont get any results with the temp, humidity and so on in HA. Just the fan on/off works.

You should create a Lovelace ‘manual’ card and put them inside of it

Have you tried the other model types that are listed for your device? :slight_smile: In my case it is the zhimi.airpurifier.ma2, but that doesn’t mean, it is yours. We all know, that Xiaomi isn’t particullary strict with their naming conventions and built in parts. It’s not that unusual, that you get one thing on the outside, and a totally different on the inside. :crazy_face:

Name Model Model no.
Air Purifier 2 zhimi.airpurifier.v2 FJY4006CN
Air Purifier MA1 zhimi.airpurifier.ma1
Air Purifier 2S zhimi.airpurifier.ma2
Air Purifier 2S zhimi.airpurifier.mc1

You can try all the other model types as well, there’s no harm done to HA or the Air Purifier. :wink:

EDIT: I just see your other post with the “card”. You do not find sensors under dev-tools or just not in lovelace?

@paddy0174 i will try other models from the list, hope some of them will work. I will get to you how it goes.

@liuk4friends, ok i will try that, thanks

Sorry that didn´t work, to paste the info in the card from the top of this thread.

One step at a time. :slight_smile: First: get the component to work. Second: show the correct functioning component in lovelace. :smiley:

It doesn’t make any sense, to check the lovelace data, if you’re not sure, if it even works.

So, test the other models, we’ll see how that goes, and afterwards we check the rest of the configuration. :slight_smile:

Alright then. I will paste my fan.yaml and config.yaml, mayby there are some wrong with either of them.

fan.yaml

Xiaomi Purifier 2H Closet

  • platform: xiaomi_miio

    host: !secret host_air_purifier_2h

    token: !secret mi_home_app_token

    model: zhimi.airpurifier.ma1

    name: Closet Mi Air Purifier 2H

And here´s my config.yaml

sensor:

Xiaomi Air Purifier 2H

  • platform: template

    sensors:

    xiaomi_airpurifier_temp:

    friendly_name: "Temperature"
    
    value_template: "{{ state_attr('fan.xiaomi_miio_device', 'temperature') }}"
    
    unit_of_measurement: "°C"
    
    device_class: "temperature"
    

    xiaomi_airpurifier_humidity:

    friendly_name: "Humidity"
    
    value_template: "{{ state_attr('fan.xiaomi_miio_device', 'humidity') }}"
    
    unit_of_measurement: "%"
    
    device_class: "humidity"
    

    xiaomi_airpurifier_air_quality_pm25:

    friendly_name: "Air quality"
    
    value_template: "{{ state_attr('fan.xiaomi_miio_device', 'aqi') }}"
    
    unit_of_measurement: "μg/m³"
    
    icon_template: "mdi:weather-fog"
    

    xiaomi_airpurifier_speed:

    friendly_name: "Fan speed"
    
    value_template: "{{ state_attr('fan.xiaomi_miio_device', 'motor_speed') }}"
    
    unit_of_measurement: "rpm"
    
    icon_template: "mdi:speedometer"
    

    xiaomi_airpurifier_filter_remaining:

    friendly_name: "Filter remaining"
    
    value_template: "{{ state_attr('fan.xiaomi_miio_device', 'filter_life_remaining') }}"
    
    unit_of_measurement: "%"
    
    icon_template: "mdi:heart-outline"
    

switch:

Xiaomi Air Purifier 2H

  • platform: template

    switches:

    xiaomi_airpurifier_led:

    friendly_name: "LED"
    
    value_template: "{{ is_state_attr('fan.xiaomi_miio_device', 'led', true) }}"
    
    turn_on:
    
      service: xiaomi_miio.fan_set_led_on
    
      data:
    
        entity_id: fan.xiaomi_miio_device
    
    turn_off:
    
      service: xiaomi_miio.fan_set_led_off
    
      data:
    
        entity_id: fan.xiaomi_miio_device
    
    icon_template: "mdi:lightbulb-outline"
    

    xiaomi_airpurifier_child_lock:

    friendly_name: "Child lock"
    
    value_template: "{{ is_state_attr('fan.xiaomi_miio_device', 'child_lock', true) }}"
    
    turn_on:
    
      service: xiaomi_miio.fan_set_child_lock_on
    
      data:
    
        entity_id: fan.xiaomi_miio_device
    
    turn_off:
    
      service: xiaomi_miio.fan_set_child_lock_off
    
      data:
    
        entity_id: fan.xiaomi_miio_device
    
    icon_template: "mdi:lock-outline"
    

    xiaomi_airpurifier_buzzer:

    friendly_name: "Buzzer"
    
    value_template: "{{ is_state_attr('fan.xiaomi_miio_device', 'buzzer', true) }}"
    
    turn_on:
    
      service: xiaomi_miio.fan_set_buzzer_on
    
      data:
    
        entity_id: fan.xiaomi_miio_device
    
    turn_off:
    
      service: xiaomi_miio.fan_set_buzzer_off
    
      data:
    
        entity_id: fan.xiaomi_miio_device
    
    icon_template: "mdi:volume-high"
    

input_select:

Xiaomi Air Purifier 2H

xiaomi_airpurifier_mode:

name: Mode

options:

  - Auto

  - Silent

  - Favorite

icon: "mdi:animation-outline"

input_number:

Xiaomi Air Purifier 2H

xiaomi_airpurifier_favorite_level:

name: "Favorite level"

initial: 0

min: 0

max: 14

step: 1

icon: "mdi:weather-windy"