So i suppose there is nothing we can do apart from using an external PM2.5 sensor
Purifier pm2.5 vs external sensor reporting
I think there is a Delta in purifier reporting, new value reported only if greater than previous one with this delta, otherwise reporting on 30 minutes.
Again, could be a limitation set by the developers at core/homeassistant/components/xiaomi_miio at dev ¡ home-assistant/core (github.com)
So I would suggest raising an issue.
Already did, but they confirmed itâs a device issue
what firmware do you have?
Ah thanks. So if we are to trust the developers, itâs a restriction imposed by the device. Which Iâm not sure I am buying.
I guess an external sensor is the way forward. Which one are you using @schilea ?
I am using this one that is also reporting PM10 and CO2 with Miio/MioT integration Cleargrass air quality monitor co2 pm2.5 pm10 sensor detector air analyzer thermometer with temperature humidity display 400 ~ 99999ppm measuring range Sale - Banggood.com.
PM2.5 values are consistent with the purifier displayed ones and the ones in the Mi home app.
If it would be a limitation of the device, the application of the mobile would work with the same limitation and it is not.
when I turn on the purifier the first 5 updates are every 30 seconds and regardless of the value afterwards it is random
@bjorn.sivertsen : Hello, Bjorn! Iâd like to have a closer look into your âway more minimalisticâ card. If you can share config iâd be very gratefull.
I have Air purifier pro, thouhg, but that shouldnât be a problem. A bit of changes in configâŚ
Hi Pavel, you should probably be fine with the Pro.
Here is a cleaned up config.
I connect my humidifier through the GUI and the official integration, so no connection info is in my configuration.yaml, you of course still need to change fan entity name to match yours.
For the lovelace card, you need the 2 custom cards: stack-in-card and mini-graph-card installed
You need the following empty picture placed in the folder config/www/, right click below here and save picture
Configuration.yaml
template:
- binary_sensor:
- name: bedroom_purifier_mode_silent
state: "{{ state_attr('fan.bedroom_purifier', 'speed') == 'Silent' }}"
- binary_sensor:
- name: bedroom_purifier_mode_favorite
state: "{{ state_attr('fan.bedroom_purifier', 'speed') == 'Favorite' }}"
- binary_sensor:
- name: bedroom_purifier_mode_fan
state: "{{ state_attr('fan.bedroom_purifier', 'speed') == 'Fan' }}"
- binary_sensor:
- name: bedroom_purifier_mode_fan_1'
state: "{{ state_attr('fan.bedroom_purifier', 'speed') == 'Fan' and is_state('number.bedroomair_purifier_fan_level', '1') }}"
- binary_sensor:
- name: bedroom_purifier_mode_fan_2
state: "{{ state_attr('fan.bedroom_purifier', 'speed') == 'Fan' and is_state('number.bedroomair_purifier_fan_level', '2') }}"
- binary_sensor:
- name: bedroom_purifier_mode_fan_3
state: "{{ state_attr('fan.bedroom_purifier', 'speed') == 'Fan' and is_state('number.bedroomair_purifier_fan_level', '3') }}"
- binary_sensor:
- name: bedroom_purifier_mode_off
state: "{{ is_state('fan.bedroom_purifier', 'off') }}"
Lovelace
type: custom:stack-in-card
cards:
- type: vertical-stack
cards:
- type: picture-elements
image: local/AP-Card-Background2.png
title: Bedroom Air Purifier
elements:
- type: state-label
prefix: 'Filter Left '
entity: sensor.bedroomair_purifier_filter_life_remaining
style:
top: 90%
left: 85%
- type: state-icon
entity: binary_sensor.bedroom_purifier_mode_off
title: 'Off'
icon: mdi:power-standby
tap_action:
action: call-service
service: fan.toggle
service_data:
entity_id: fan.bedroom_purifier
style:
top: 0%
left: 90%
min-width: 40px
min-height: 40px
transform: translate(-50%, -50%) scale(1.5)
'--paper-item-icon-color': rgb(192, 192, 192)
'--paper-item-icon-active-color': rgb(255, 128, 0)
- type: state-icon
entity: binary_sensor.bedroom_purifier_mode_favorite
title: Auto
icon: mdi:autorenew
tap_action:
action: call-service
service: fan.set_preset_mode
service_data:
entity_id: fan.bedroom_purifier
preset_mode: Favorite
style:
top: 0%
left: 10%
transform: translate(-50%, -50%) scale(1.5)
'--paper-item-icon-color': rgb(192, 192, 192)
'--paper-item-icon-active-color': rgb(255, 128, 0)
- type: state-icon
entity: binary_sensor.bedroom_purifier_mode_silent
title: Silent
icon: mdi:power-sleep
tap_action:
action: call-service
service: fan.set_preset_mode
service_data:
entity_id: fan.bedroom_purifier
preset_mode: Silent
style:
top: 0%
left: 63.34%
transform: translate(-50%, -50%) scale(1.5)
'--paper-item-icon-color': rgb(192, 192, 192)
'--paper-item-icon-active-color': rgb(255, 128, 0)
'--iron-icon-height': 120px
'--iron-icon-width': 120px
- type: state-icon
entity: binary_sensor.bedroom_purifier_mode_fan
title: Fan
icon: mdi:fan
tap_action:
action: call-service
service: number.set_value
service_data:
entity_id: number.bedroomair_purifier_fan_level
value: 1
style:
top: 0%
left: 36.67%
transform: translate(-50%, -50%) scale(1.5)
'--paper-item-icon-color': rgb(192, 192, 192)
'--paper-item-icon-active-color': rgb(255, 128, 0)
- type: conditional
conditions:
- entity: binary_sensor.bedroom_purifier_mode_favorite
state: 'on'
elements:
- type: state-label
prefix: 'Level '
entity: number.bedroom_purifier_favorite_level
style:
top: 50%
left: 11.5%
font-size: 150%
- type: conditional
conditions:
- entity: binary_sensor.bedroom_purifier_mode_fan
state: 'on'
elements:
- type: state-icon
entity: binary_sensor.bedroom_purifier_mode_fan_1
title: Fan level 1
icon: mdi:fan-speed-1
tap_action:
action: call-service
service: number.set_value
service_data:
entity_id: number.bedroomair_purifier_fan_level
value: 1
style:
top: 70%
left: 29.67%
transform: translate(-50%, -50%) scale(1.2, 1.2)
'--paper-item-icon-color': rgb(192, 192, 192)
'--paper-item-icon-active-color': rgb(255, 128, 0)
- type: state-icon
entity: binary_sensor.bedroom_purifier_mode_fan_2
title: Fan level 2
icon: mdi:fan-speed-2
tap_action:
action: call-service
service: number.set_value
service_data:
entity_id: number.bedroomair_purifier_fan_level
value: 2
style:
top: 70%
left: 36.37%
transform: translate(-50%, -50%) scale(1.2, 1.2)
'--paper-item-icon-color': rgb(192, 192, 192)
'--paper-item-icon-active-color': rgb(255, 128, 0)
- type: state-icon
entity: binary_sensor.bedroom_purifier_mode_fan_3
title: Fan level 3
icon: mdi:fan-speed-3
tap_action:
action: call-service
service: number.set_value
service_data:
entity_id: number.bedroomair_purifier_fan_level
value: 3
style:
top: 70%
left: 43.67%
transform: translate(-50%, -50%) scale(1.2, 1.2)
'--paper-item-icon-color': rgb(192, 192, 192)
'--paper-item-icon-active-color': rgb(255, 128, 0)
- type: custom:mini-graph-card
entities:
- sensor.bedroomair_purifier_pm2_5
points_per_hour: 3
animate: true
show:
icon: false
name: false
state: true
Automation.yaml
- id: '1234567891012'
alias: AP03 - Air Purifier set favorite level based on PM2.5
description: 'Automatically changes fan level based on PM2.5 levels, under some conditions, like balcony door not being open, only in day hours etc, you can remove the conditions as needed'
trigger:
- platform: time_pattern
minutes: /5
condition:
- condition: state
entity_id: fan.bedroom_purifier
state: Favorite
attribute: preset_mode
- condition: state
entity_id: fan.bedroom_purifier
state: 'on'
- condition: time
after: 08:00
before: '20:00'
- type: is_not_open
condition: device
device_id: caab6403190bf76661e96c600a77dc08
entity_id: binary_sensor.bedroom_door_sensor
domain: binary_sensor
action:
- service: fan.set_preset_mode
target:
entity_id: fan.bedroom_purifier
data:
preset_mode: Favorite
- service: number.set_value
entity_id: number.bedroom_purifier_favorite_level
data_template:
value: "{% if states('sensor.bedroomair_purifier_pm2_5') | int > 140 %}\n 14\n\
{% elif states('sensor.bedroomair_purifier_pm2_5') | int > 120 %}\n 12\n\
{% elif states('sensor.bedroomair_purifier_pm2_5') | int > 100 %}\n 10\n\
{% elif states('sensor.bedroomair_purifier_pm2_5') | int > 80 %}\n 8\n{%\
\ elif states('sensor.bedroomair_purifier_pm2_5') | int > 60 %}\n 6\n{% elif\
\ states('sensor.bedroomair_purifier_pm2_5') | int > 40 %}\n 4\n{% elif states('sensor.bedroomair_purifier_pm2_5')\
\ | int > 20 %}\n 3\n{% elif states('sensor.bedroomair_purifier_pm2_5') |\
\ int > 10 %}\n 2\n{% else %}\n 1\n{% endif %}\n"
I have some other automations that turn the device on/off if balcony door is touched, and turn it to night mode at night etc.
How it looks:
Thanks a lot!
If someone interested external air quality monitor on Banggood now discounted to $67.99 using coupon BGTYOJ758.
If you want real time values, you need to write some bash loop with this python-miio command:
python3 miio/cli.py airpurifiermiot --ip 192.168.x.y --token xxxxxxxxxxx raw_command set_properties "[{'did': 'MYDID', 'siid': 13, 'piid': 9, 'value': 65534 }]"
siid:13 / piid:9 command set parameter named: aqi-updata-heartbeat
After this command Purifier will respond with real time values for next 65534 seconds. Itâs maximum value, we canât set infinity, so loop is needed.
Official Xiaomi Home App set value: 60, when app is started
This should do the trick
automation.yaml
- id: '1640969350049'
alias: HeartbeatUpdater
description: ''
trigger:
- platform: time_pattern
hours: /1
condition: []
action:
- service: shell_command.heartbeatup
mode: single
configuration.yaml
shell_command:
heartbeatup: "miiocli airpurifiermiot --ip 192.168.x.y --token xxxx raw_command set_properties \"[{'did': 'MYDID', 'siid': 13, 'piid': 9, 'value': 60000 }]\""
Seems to be working! You saved me
Posted on github
EDIT: Seems to have worked the first time, but not working anymore
To check if automation works, you can execute this command. You should get non-zero value.
miiocli airpurifiermiot --ip 192.168.x.y --token xxxx raw_command get_properties â[{âdidâ: âMYDIDâ, âsiidâ: 13, âpiidâ: 9 }]â
If you have non-zero value, but still PM2.5 is updated only every 30 minutes, then I was wrong about everything.
Did the favorite level entity disappear for anyone else with 2021.12.8?
Not sure why, but now works flawlessy, i canât express how much i am grateful to you
Hopefully they can insert this in the integration
How did you find out about this?
I updated from 12.6 to 12.8 and Favorite, Fan and Brightness level are gone.
After downgrade to 12.7 everything is back, so 12.8 messed something
I canât find original link right now. It was somewhere mentioned on Github, when people worked on initial support for this device. Itâs known fact since 2020.
Full API for 3H v1 is available here: https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-mb3:1
I can see on Github that it will be fixed in the next release. I might roll back to 2021.12.7 for now.
Opened another Github report
Could you please give me an help here? Iâm not as good as i would like me to be