You don’t need Xiaomi Integration as addon there GW required
just put in your configuration.yaml
fan:
- platform: xiaomi_miio
host: ip of your air purifier
token: 'your air purifier token'
You don’t need Xiaomi Integration as addon there GW required
just put in your configuration.yaml
fan:
- platform: xiaomi_miio
host: ip of your air purifier
token: 'your air purifier token'
Hello, I own 2 x Xiaomi Air Purifier 2H. I would REALLY like them integrated in HA, but I’m having a hard time understanding how I can add them… To me it look and sounds like they should be added throuhg the Xiamo miio integration, but that does not make a lot of sense to me, as they do not connect to a gateway, they connect directly to the Xiaomi Home app via wifi. And when I click the xiaomi miio integration in HA it is clearly wanting to add a gateway, not an air purifier (or other device).
I know how to retrieve the token etc, I have done that before when I integrated these devices to smartthings but that was a very very very unfinished terrible solution that only worked half and partly not at all. hence why I am here
Hello everyone, I just copied the configuration from the first post, but I cannot see any sensor on my Air Purifier 2H in the entity card, but if I click the Air Purifier entity, it shows every single sensor. Also, the buttons for modifying the mode and the speed, and the LED, aren’t working… Can you tell me how to fix it?
Have you adapted the names of the entities in the automations?
Updated the names? Could you please explain me what to do? Thanks!
Hello, I have 3 days experience in Home Assistant and this was my hardest yet device to integrate, so I want to give back to the community as there’s much confusion in this subject. I’m not a programmer I just built it by copy and paste from the forum.
Do not use the visual interface to integrate the Air Purifier! (I have done this and it managed to mess up the name of the “entity” and the configuration had to change and some other things, lost a lot of time with this)
Use this integration to get the Token directly in Home Assistant without any other android or IOS method.
fan:
- platform: xiaomi_miio
host: IP OF THE Air Purifier
token: YOUR TOKEN
name: "WHAT NAME YOU WANT FOR THE DEVICE"
Check config using the interface and restart Home Assistant
2. After restart check in the “Entities” section for your Home assistant for an Fan entity, note the “Entity ID” you can check if is working by clicking on it and pushing the icon on the top-right corner.
sensor:
# Xiaomi Air Purifier PRO
- platform: template
sensors:
xiaomi_airpurifier_temp:
friendly_name: "Air Purifier Temperature"
value_template: "{{ state_attr('fan.xiaomi_air_purifier_pro', 'temperature') }}"
unit_of_measurement: "°C"
device_class: "temperature"
icon_template: "mdiThermometerLines"
xiaomi_airpurifier_humidity:
friendly_name: "Air Purifier Humidity"
value_template: "{{ state_attr('fan.xiaomi_air_purifier_pro', 'humidity') }}"
unit_of_measurement: "%"
device_class: "humidity"
icon_template: "mdiWaterPercent"
xiaomi_airpurifier_air_quality_pm25:
friendly_name: "Air Purifier Air quality"
value_template: "{{ state_attr('fan.xiaomi_air_purifier_pro', 'aqi') }}"
unit_of_measurement: "μg/m³"
icon_template: "mdi:weather-fog"
xiaomi_airpurifier_speed:
friendly_name: "Air Purifier Fan Speed"
value_template: "{{ state_attr('fan.xiaomi_air_purifier_pro', 'motor2_speed') }}"
unit_of_measurement: "rpm"
icon_template: "mdi:speedometer"
xiaomi_airpurifier_filter_remaining:
friendly_name: "Air Purifier Filter Remaining"
value_template: "{{ state_attr('fan.xiaomi_air_purifier_pro', 'filter_life_remaining') }}"
unit_of_measurement: "%"
icon_template: "mdiAirFilter"
xiaomi_airpurifier_luminance:
friendly_name: "Air Purifier Luminance"
value_template: "{{ state_attr('fan.xiaomi_air_purifier_pro', 'illuminance') }}"
unit_of_measurement: "Lux"
icon_template: "mdiLightbulbOutline"
switch:
# Xiaomi Air Purifier PRO
- platform: template
switches:
xiaomi_airpurifier_led:
friendly_name: "Air Purifier Display"
value_template: "{{ is_state_attr('fan.xiaomi_air_purifier_pro', 'led', true) }}"
turn_on:
service: xiaomi_miio.fan_set_led_on
data:
entity_id: fan.xiaomi_air_purifier_pro
turn_off:
service: xiaomi_miio.fan_set_led_off
data:
entity_id: fan.xiaomi_air_purifier_pro
icon_template: "mdi:lightbulb-outline"
xiaomi_airpurifier_child_lock:
friendly_name: "Air Purifier Child lock"
value_template: "{{ is_state_attr('fan.xiaomi_air_purifier_pro', 'child_lock', true) }}"
turn_on:
service: xiaomi_miio.fan_set_child_lock_on
data:
entity_id: fan.xiaomi_air_purifier_pro
turn_off:
service: xiaomi_miio.fan_set_child_lock_off
data:
entity_id: fan.xiaomi_air_purifier_pro
icon_template: "mdi:lock-outline"
input_select:
xiaomi_airpurifier_mode:
name: Mode
options:
- Auto
- Silent
- Favorite
icon: "mdi:animation-outline"
input_number:
xiaomi_airpurifier_favorite_level:
name: "Favorite Level"
initial: 3
min: 0
max: 16
step: 1
icon: "mdi:weather-windy"
automations.yaml
- alias: Air Purifier mode change
trigger:
entity_id: input_select.xiaomi_airpurifier_mode
platform: state
action:
service: fan.set_speed
data_template:
entity_id: fan.xiaomi_air_purifier_pro
speed: '{{ states.input_select.xiaomi_airpurifier_mode.state }}'
- alias: Air Purifier mode changed
trigger:
platform: state
entity_id: fan.xiaomi_air_purifier_pro
action:
service: input_select.select_option
entity_id: input_select.xiaomi_airpurifier_mode
data_template:
option: '{{ states.fan.xiaomi_air_purifier_pro.attributes.speed }}'
- alias: Air Purifier favorite level change
trigger:
entity_id: input_number.xiaomi_airpurifier_favorite_level
platform: state
action:
service: xiaomi_miio.fan_set_favorite_level
data_template:
entity_id: fan.xiaomi_air_purifier_pro
level: '{{ states.input_number.xiaomi_airpurifier_favorite_level.state | int
}}'
- alias: Air Purifier favorite level changed
trigger:
platform: state
entity_id: fan.xiaomi_air_purifier_pro
action:
service: input_number.set_value
entity_id: input_number.xiaomi_airpurifier_favorite_level
data_template:
value: '{{ states.fan.xiaomi_air_purifier_pro.attributes.favorite_level }}'
Check and restart HA
You can create your Lovelace dashboard using the visual editor once all the Entities are present
What I have changed in the code is:
What I want to add:
THANK YOU SOOOOOOOOOOOOO MUCH FOR THAT. Finally I got mine to work (2H)
Hi, Nice to see that you have got it working. I’m fiddling atm with getting my Air purifier integrated. But one thing that is REALLY not clear to me is whether it is necessary to add the xiaomi miio gateway integration from the integrations menu before I can add my air purfier? - it doesn’t say in the documentation, but you must know since you just made it work.
I have added exactly like you
fan:
- platform: xiaomi_miio
host: IP OF THE Air Purifier
token: YOUR TOKEN
name: "WHAT NAME YOU WANT FOR THE DEVICE"
to my configuration.yaml
Restarted my server, with no errors, but the fan wont show up in the entities menu… Did you setup a gateway before you did everything that you describe? I’m really not interested in buying a gateway just to have my air purifier connected as it really doesn’t need one, it connects directly over wifi, not through a gateway.
Cheers
As I specified to my first post, do not add the integration from the interface. Remove any old configuration if you added it by the interface, it will mess up the entity creation.
If you added correctly the IP and token the in the configuration YAML it will show up as an fan entity. Check your IP and token, in your case I think that is the issue.
Thanks for the fast reply! No, I didn’t use the interface integration as it very clearly wants a gateway.
How did you restart you system? Do I need to do a full reboot of the server machine ?
Modify the code and put your IP and token there, save and then go to HA settings and check config and restart.
Still no Air Purifier added. I have also looked through the whole list, not a single one with fan icon, and also nothing when i search “miio”
Anyone any ideas what could be wrong ? Are there any debugging steps? Any logs that will show failed handshake between device an HA or something like that ?
Everything looks good, from your pictures.
What to check:
Thanks for spending so much time with my problem, that’s very generous of you!
I’m using Advanced IP scanne to locate the IP, but I have double checked with the MI Home app, and I have reserved the IP in my route so that it will always be x.x.x.28 whenever the lease is renewed
Logger: homeassistant.components.fan
Source: helpers/entity_platform.py:208
Integration: Fan (documentation, issues)
First occurred: 5:50:11 PM (24 occurrences)
Last logged: 6:51:42 PM
- Platform xiaomi_miio not ready yet. Retrying in 60 seconds.
- Platform xiaomi_miio not ready yet. Retrying in 90 seconds.
- Platform xiaomi_miio not ready yet. Retrying in 120 seconds.
- Platform xiaomi_miio not ready yet. Retrying in 150 seconds.
- Platform xiaomi_miio not ready yet. Retrying in 180 seconds.
But unfortunately it’s a bit cheap on infomation
I managed to solve the problem. The issue was the token. I’m having two air purfiers, and the tokens got mixed up … I dont know how this happened but after swapping the tokens it was added
Hi,
i currently buy a Xiaomi Air Purifier 2H and test the MIIO Integration but don’t get it work.
The following settings are testet in the configuration.yaml.
I double checked the token with the old android app and the Integration from AlexxIT
Do you have any Ideas? I know the 2H Modell is currently not officially supported.
Thanks!
- platform: xiaomi_miio
host: ###hidden###
token: ###hidden###
#model: zhimi.airpurifier.ma2
name: “Air Purifier 2H”
Name: Mi Air Purifier 2H
Model: zhimi.airpurifier.mc2
I have the exact same air purifier, and though it is not officialy supported, it works perfektly when configured right.
This is how my configuration.yaml looks. Remember to restart server after adding and wait a bit. Go into logs if still not appearing and see if it says anything about miio integration timeout.
Hello,
Is this still fully functional? For me, “favorite level” and “mode” are not working anymore.
Regards
Same here… can’t figure out what is wrong, my log is clear.
Solved here… Try this:
input_select:
airpurifier_mode:
name: Operation mode
options:
- Auto
- Silent
- Favorite
input_number:
airpurifier_favorite_level:
name: Favorite Level
initial: 1
min: 0
max: 16
step: 1