Hi,
Hereās some cleaned up and working config at 25/04/22 with official Xiaomi Miio integration, thatās how it looks in Spanish (the code in the post has visual names translated to English):
-
Configure your device as normal with the official Xiaomi Miio integration using IP and token
-
Install THIS CUSTOM CARD through HACS or manually (read instructions on the linked github)
-
Add custom card from code (that one is for Mi Purifier 3H, edit or adapt it for your device):
type: custom:purifier-card
entity: fan.zhimi_airpurifier_mb3
aqi:
entity_id: sensor.zhimi_airpurifier_mb3_pm2_5
unit: Āµg/mĀ³
stats:
- entity_id: sensor.zhimi_airpurifier_mb3_motor_speed
unit: RPM
subtitle: Speed
- entity_id: sensor.zhimi_airpurifier_mb3_temperature
unit: ĀŗC
subtitle: Temperature
- entity_id: sensor.zhimi_airpurifier_mb3_humidity
unit: '%'
subtitle: Humidity
- entity_id: sensor.zhimi_airpurifier_mb3_filter_life_remaining
subtitle: Filter
unit: '%'
actions:
- name: Silent
icon: mdi:weather-night
preset_mode: Silent
- name: 25%
icon: mdi:circle-slice-2
preset_mode: Favorite
number.zhimi_airpurifier_mb3_favorite_level: 3
- name: 50%
icon: mdi:circle-slice-4
preset_mode: Favorite
number.zhimi_airpurifier_mb3_favorite_level: 7
- name: 75%
icon: mdi:circle-slice-6
preset_mode: Favorite
number.zhimi_airpurifier_mb3_favorite_level: 10
- name: 100%
icon: mdi:circle-slice-8
preset_mode: Favorite
number.zhimi_airpurifier_mb3_favorite_level: 14
- name: Auto
icon: mdi:refresh-auto
preset_mode: Auto
shortcuts:
- name: Silent
icon: mdi:weather-night
preset_mode: Silent
- name: 25%
icon: mdi:circle-slice-2
percentage: 25
- name: 50%
icon: mdi:circle-slice-4
percentage: 50
- name: 75%
icon: mdi:circle-slice-6
percentage: 100
- name: Auto
icon: mdi:refresh-auto
preset_mode: Auto
show_name: true
show_status: true
show_state: true
show_toolbar: true
compact_view: false
- Hereās my automations.yaml (descriptions are pretty self-explanatory):
- id: '1234567891011'
alias: AP01 - Air Purifier turn on
description: Automatically turns on purifier on Favorite when >15 for +30s, only
when it's OFF
trigger:
- platform: time_pattern
minutes: /1
condition:
- condition: device
device_id: 62ff38a78452b62f71afd27c306bae6c
domain: fan
entity_id: fan.zhimi_airpurifier_mb3
type: is_off
- type: is_pm25
condition: device
device_id: 62ff38a78452b62f71afd27c306bae6c
entity_id: sensor.zhimi_airpurifier_mb3_pm2_5
domain: sensor
above: 15
action:
- data:
preset_mode: Favorite
service: fan.turn_on
target:
entity_id: fan.zhimi_airpurifier_mb3
mode: restart
- id: '1234567891012'
alias: AP03 - Air Purifier set favorite level based on PM2.5
description: Automatically changes Favorite level every 15s based on PM2.5, only
when it's ON
trigger:
- platform: time_pattern
seconds: /30
condition:
- condition: device
device_id: 62ff38a78452b62f71afd27c306bae6c
domain: fan
entity_id: fan.zhimi_airpurifier_mb3
type: is_on
- condition: and
conditions:
- condition: state
entity_id: automation.ap01_air_purifier_turn_on
state: 'on'
action:
- service: fan.set_preset_mode
target:
entity_id: fan.zhimi_airpurifier_mb3
data:
preset_mode: Favorite
- service: number.set_value
entity_id: number.zhimi_airpurifier_mb3_favorite_level
data_template:
value: "{% if states('sensor.zhimi_airpurifier_mb3_pm2_5') | int(0) > 500 %}\n\
\ 10\n{% elif states('sensor.zhimi_airpurifier_mb3_pm2_5') | int(0) > 400\
\ %}\n 9\n{% elif states('sensor.zhimi_airpurifier_mb3_pm2_5') | int(0) >\
\ 300 %}\n 8\n{% elif states('sensor.zhimi_airpurifier_mb3_pm2_5') | int(0)\
\ > 200 %}\n 7\n{% elif states('sensor.zhimi_airpurifier_mb3_pm2_5') | int(0)\
\ > 100 %}\n 6\n{% elif states('sensor.zhimi_airpurifier_mb3_pm2_5') | int(0)\
\ > 10 %}\n 5\n{% else %}\n 4\n{% endif %}\n"
mode: restart
- id: '1234567891013'
alias: AP03 - Air Purifier turn off
description: Automatically turns off purifier when <5 for +30s, only when it's ON
trigger:
- platform: time_pattern
minutes: /1
condition:
- condition: device
device_id: 62ff38a78452b62f71afd27c306bae6c
domain: fan
entity_id: fan.zhimi_airpurifier_mb3
type: is_on
- type: is_pm25
condition: device
device_id: 62ff38a78452b62f71afd27c306bae6c
entity_id: sensor.zhimi_airpurifier_mb3_pm2_5
domain: sensor
below: 5
action:
- data: {}
entity_id: fan.zhimi_airpurifier_mb3
service: fan.turn_off
mode: restart
Hope it helps
Only problem I currently have is that I get timeouts when fetching data from the purifier every few minutes, hopefully someone can shred some light on this @schilea :
2022-04-26 00:53:00 ERROR (MainThread) [homeassistant.components.xiaomi_miio] Timeout fetching Mi Air Purifier 3/3H data