Here is my variant where I have removed some sensors and the switches (LED, buzzer etc) I dont use, with a picture that works on both dark and light theme. Two air purifiers, one version 3H (Bedroom) and one version 2S (Living Room).
configuration.yaml
#################################################################################################
# Xiaomi Air Purifiers, Bedroom 3H, Living Room 2S
#################################################################################################
- platform: xiaomi_miio # Mi Air Purifier 2S
name: "Living Room Air Purifier" # entity fan.living_room_air_purifier
host: XXX.XXX.XXX.XXX
token: xxxxxxxxxxxxxxxxxxxxxxxx
model: zhimi.airpurifier.m1
- platform: xiaomi_miio
name: "Bedroom Air Purifier" # Mi Air Purifier 3H
host: YYY.YYY.YYY.YYY # entity fan.bedroom_air_purifier
token: yyyyyyyyyyyyyyyyyyyyyyyy
model: zhimi.airpurifier.mb3
sensor:
#===================================#
# Mi Air Purifier Living Room (2S) #
#===================================#
- platform: template
sensors:
living_room_air_purifier_temp:
friendly_name: "Temperature"
value_template: "{{ state_attr('fan.living_room_air_purifier', 'temperature') }}"
unit_of_measurement: "°C"
device_class: "temperature"
living_room_air_purifier_humidity:
friendly_name: "Humidity"
value_template: "{{ state_attr('fan.living_room_air_purifier', 'humidity') }}"
unit_of_measurement: "%"
device_class: "humidity"
living_room_air_purifier_air_quality_pm25:
friendly_name: "Air Quality Index (AQI) PM2.5 (μg/m³)"
# value_template: "{{ state_attr('fan.living_room_air_purifier', 'aqi') }}"
value_template: >-
{% if state_attr('fan.living_room_air_purifier', 'aqi') == None %}
{{ 0 }}
{% else %}
{{ state_attr('fan.living_room_air_purifier', 'aqi') }}
{% endif %}
unit_of_measurement: " "
# unit_of_measurement: "μg/m³"
icon_template: "mdi:air-purifier"
living_room_air_purifier_favorite_level:
friendly_name: "Favorite Level"
value_template: "{{ state_attr('fan.living_room_air_purifier', 'favorite_level') }}"
living_room_air_purifier_avg_air_quality_pm25:
friendly_name: "Average air quality (AvgAQI) PM2.5"
value_template: "{{ state_attr('fan.living_room_air_purifier', 'average_aqi') }}"
unit_of_measurement: "μg/m³"
icon_template: "mdi:weather-hazy"
living_room_air_purifier_filter_remaining:
friendly_name: "Filter remaining"
value_template: "{{ state_attr('fan.living_room_air_purifier', 'filter_life_remaining') }}"
unit_of_measurement: "%"
icon_template: "mdi:air-filter"
#================================#
# Mi Air Purifier Bedroom (3H) #
#================================#
- platform: template
sensors:
bedroom_air_purifier_temp:
friendly_name: "Temperature"
value_template: "{{ state_attr('fan.bedroom_air_purifier', 'temperature') }}"
unit_of_measurement: "°C"
device_class: "temperature"
bedroom_air_purifier_humidity:
friendly_name: "Humidity"
value_template: "{{ state_attr('fan.bedroom_air_purifier', 'humidity') }}"
unit_of_measurement: "%"
device_class: "humidity"
bedroom_air_purifier_air_quality_pm25:
friendly_name: "Air Quality Index (AQI) PM2.5 (μg/m³)"
# value_template: "{{ state_attr('fan.bedroom_air_purifier', 'aqi') }}"
value_template: >-
{% if state_attr('fan.bedroom_air_purifier', 'aqi') == None %}
{{ 0 }}
{% else %}
{{ state_attr('fan.bedroom_air_purifier', 'aqi') }}
{% endif %}
unit_of_measurement: " "
# unit_of_measurement: "μg/m³"
icon_template: "mdi:air-purifier"
bedroom_air_purifier_favorite_level:
friendly_name: "Favorite Level"
value_template: "{{ state_attr('fan.bedroom_air_purifier', 'favorite_level') }}"
bedroom_air_purifier_avg_air_quality_pm25:
friendly_name: "Average air quality (AvgAQI) PM2.5"
value_template: "{{ state_attr('fan.bedroom_air_purifier', 'average_aqi') }}"
unit_of_measurement: "μg/m³"
icon_template: "mdi:weather-hazy"
bedroom_air_purifier_filter_remaining:
friendly_name: "Filter remaining"
value_template: "{{ state_attr('fan.bedroom_air_purifier', 'filter_life_remaining') }}"
unit_of_measurement: "%"
icon_template: "mdi:air-filter"
binary_sensor:
#===================================#
# Mi Air Purifier Living Room (2S) #
#===================================#
- platform: template
sensors:
living_room_air_purifier_mode_off:
friendly_name: "Purifier Off"
value_template: "{{ is_state('fan.living_room_air_purifier', 'off') }}"
living_room_air_purifier_mode_auto:
friendly_name: "Purifier Auto mode"
value_template: "{{ is_state_attr('fan.living_room_air_purifier', 'mode', 'auto') and is_state('fan.living_room_air_purifier', 'on') }}"
living_room_air_purifier_mode_silent:
friendly_name: "Purifier Silent mode"
value_template: "{{ is_state_attr('fan.living_room_air_purifier', 'mode', 'silent') and is_state('fan.living_room_air_purifier', 'on') }}"
living_room_air_purifier_mode_favorite:
friendly_name: "Purifier Favorite mode"
value_template: "{{ is_state_attr('fan.living_room_air_purifier', 'mode', 'favorite') and is_state('fan.living_room_air_purifier', 'on') }}"
#================================#
# Mi Air Purifier Bedroom (3H) #
#================================#
- platform: template
sensors:
bedroom_air_purifier_mode_off:
friendly_name: "Purifier Off"
value_template: "{{ is_state('fan.bedroom_air_purifier', 'off') }}"
bedroom_air_purifier_mode_auto:
friendly_name: "Purifier Auto mode"
value_template: "{{ is_state_attr('fan.bedroom_air_purifier', 'mode', 0) and is_state('fan.bedroom_air_purifier', 'on') }}"
bedroom_air_purifier_mode_silent:
friendly_name: "Purifier Silent mode"
value_template: "{{ is_state_attr('fan.bedroom_air_purifier', 'mode', 1) and is_state('fan.bedroom_air_purifier', 'on') }}"
bedroom_air_purifier_mode_favorite:
friendly_name: "Purifier Favorite mode"
value_template: "{{ is_state_attr('fan.bedroom_air_purifier', 'mode', 2) and is_state('fan.bedroom_air_purifier', 'on') }}"
bedroom_air_purifier_mode_fan:
friendly_name: "Purifier Fan mode"
value_template: "{{ is_state_attr('fan.bedroom_air_purifier', 'mode', 3) and is_state('fan.bedroom_air_purifier', 'on') }}"
bedroom_air_purifier_mode_fan_1:
friendly_name: "Purifier Fan mode 1"
value_template: "{{ is_state_attr('fan.bedroom_air_purifier', 'mode', 3) and is_state_attr('fan.bedroom_air_purifier', 'fan_level', 1) and is_state('fan.bedroom_air_purifier', 'on') }}"
bedroom_air_purifier_mode_fan_2:
friendly_name: "Purifier Fan mode 2"
value_template: "{{ is_state_attr('fan.bedroom_air_purifier', 'mode', 3) and is_state_attr('fan.bedroom_air_purifier', 'fan_level', 2) and is_state('fan.bedroom_air_purifier', 'on') }}"
bedroom_air_purifier_mode_fan_3:
friendly_name: "Purifier Fan mode 3"
value_template: "{{ is_state_attr('fan.bedroom_air_purifier', 'mode', 3) and is_state_attr('fan.bedroom_air_purifier', 'fan_level', 3) and is_state('fan.bedroom_air_purifier', 'on') }}"
scripts.yaml
bedroom_air_purifier_favorite_up:
sequence:
- service: xiaomi_miio.fan_set_favorite_level
data:
level: '{% if (state_attr(''fan.bedroom_air_purifier'',''favorite_level'') +
step | int) < 14 -%} {{ state_attr(''fan.bedroom_air_purifier'', ''favorite_level'')
+ step | int }} {%- else -%} {{ 14 }} {%- endif %}'
entity_id: fan.bedroom_air_purifier
mode: single
bedroom_air_purifier_favorite_down:
sequence:
- service: xiaomi_miio.fan_set_favorite_level
data:
level: '{% if (state_attr(''fan.bedroom_air_purifier'',''favorite_level'') -
step | int) > 0 -%} {{ state_attr(''fan.bedroom_air_purifier'', ''favorite_level'')
- step | int }} {%- else -%} {{ 0 }} {%- endif %}'
entity_id: fan.bedroom_air_purifier
mode: single
living_room_air_purifier_favorite_up:
sequence:
- service: xiaomi_miio.fan_set_favorite_level
data:
level: '{% if (state_attr(''fan.living_room_air_purifier'',''favorite_level'')
+ step | int) < 14 -%} {{ state_attr(''fan.living_room_air_purifier'', ''favorite_level'')
+ step | int }} {%- else -%} {{ 14 }} {%- endif %}'
entity_id: fan.living_room_air_purifier
mode: single
living_room_air_purifier_favorite_down:
sequence:
- service: xiaomi_miio.fan_set_favorite_level
data:
level: '{% if (state_attr(''fan.living_room_air_purifier'',''favorite_level'')
- step | int) > 0 -%} {{ state_attr(''fan.living_room_air_purifier'', ''favorite_level'')
- step | int }} {%- else -%} {{ 0 }} {%- endif %}'
entity_id: fan.living_room_air_purifier
mode: single
3H (Bedroom) Lovelace card
type: picture-elements
title: Bedroom Air-Purifier
image: local/mi_air_purifier_big_circle_2.png
elements:
- type: state-icon
entity: binary_sensor.bedroom_air_purifier_mode_off
title: 'Off'
icon: 'mdi:power-standby'
tap_action:
action: call-service
service: fan.turn_off
service_data:
entity_id: fan.bedroom_air_purifier
style:
top: 10%
left: 20%
transform: 'translate(-50%, 0)'
'--paper-item-icon-color': 'rgb(128, 128, 128)'
'--paper-item-icon-active-color': 'rgb(255, 128, 0)'
- type: state-icon
entity: fan.bedroom_air_purifier
title: More Info
icon: 'mdi:dots-vertical'
tap_action:
action: more-info
style:
top: 10%
left: 82%
transform: 'translate(-50%, 0)'
'--paper-item-icon-color': 'rgb(128, 128, 128)'
'--paper-item-icon-active-color': 'rgb(128, 128, 128)'
- type: conditional
conditions:
- entity: binary_sensor.bedroom_air_purifier_mode_off
state: 'off'
elements:
- type: state-label
entity: sensor.bedroom_air_purifier_air_quality_pm25
title: PM2.5
tap_action:
action: more-info
style:
top: 18%
left: 50%
min-width: 40px
min-height: 40px
text-align: center
font-size: 400%
transform: 'translate(-50%, 0)'
color: 'rgb(255,255,255)'
- type: state-label
entity: sensor.bedroom_air_purifier_temp
title: Temperature
tap_action:
action: more-info
style:
top: 36%
left: 42%
min-width: 40px
min-height: 40px
text-align: center
font-size: 110%
transform: 'translate(-50%, 0)'
color: 'rgb(255,255,255)'
- type: state-label
entity: sensor.bedroom_air_purifier_humidity
title: Humidity
tap_action:
action: more-info
style:
top: 36%
left: 58%
min-width: 40px
min-height: 40px
text-align: center
font-size: 110%
transform: 'translate(-50%, 0)'
color: 'rgb(255,255,255)'
- type: conditional
conditions:
- entity: binary_sensor.bedroom_air_purifier_mode_off
state: 'on'
elements:
- type: state-label
entity: sensor.bedroom_air_purifier_air_quality_pm25
title: PM2.5
tap_action:
action: more-info
style:
top: 18%
left: 50%
min-width: 40px
min-height: 40px
text-align: center
font-size: 400%
transform: 'translate(-50%, 0)'
color: 'rgb(128, 128, 128)'
- type: state-label
entity: sensor.bedroom_air_purifier_temp
title: Temperature
tap_action:
action: more-info
style:
top: 36%
left: 42%
min-width: 40px
min-height: 40px
text-align: center
font-size: 110%
transform: 'translate(-50%, 0)'
color: 'rgb(128, 128, 128)'
- type: state-label
entity: sensor.bedroom_air_purifier_humidity
title: Humidity
tap_action:
action: more-info
style:
top: 36%
left: 58%
min-width: 40px
min-height: 40px
text-align: center
font-size: 110%
transform: 'translate(-50%, 0)'
color: 'rgb(128, 128, 128)'
- type: state-icon
entity: binary_sensor.bedroom_air_purifier_mode_auto
title: Auto
icon: 'mdi:autorenew'
tap_action:
action: call-service
service: fan.set_speed
service_data:
entity_id: fan.bedroom_air_purifier
speed: Auto
style:
top: 50%
left: 37%
transform: 'translate(-50%, 0)'
'--paper-item-icon-color': 'rgb(192, 192, 192)'
'--paper-item-icon-active-color': 'rgb(255, 128, 0)'
- type: state-icon
entity: binary_sensor.bedroom_air_purifier_mode_silent
title: Silent
icon: 'mdi:power-sleep'
tap_action:
action: call-service
service: fan.set_speed
service_data:
entity_id: fan.bedroom_air_purifier
speed: Silent
style:
top: 50%
left: 46%
transform: 'translate(-50%, 0)'
'--paper-item-icon-color': 'rgb(192, 192, 192)'
'--paper-item-icon-active-color': 'rgb(255, 128, 0)'
- type: state-icon
entity: binary_sensor.bedroom_air_purifier_mode_fan
title: Fan
icon: 'mdi:fan'
tap_action:
action: call-service
service: fan.set_speed
service_data:
entity_id: fan.bedroom_air_purifier
speed: Fan
style:
top: 50%
left: 54%
transform: 'translate(-50%, 0)'
'--paper-item-icon-color': 'rgb(192, 192, 192)'
'--paper-item-icon-active-color': 'rgb(255, 128, 0)'
- type: state-icon
entity: binary_sensor.bedroom_air_purifier_mode_favorite
title: Favorite
icon: 'mdi:heart'
tap_action:
action: call-service
service: fan.set_speed
service_data:
entity_id: fan.bedroom_air_purifier
speed: Favorite
style:
top: 50%
left: 63%
transform: 'translate(-50%, 0)'
'--paper-item-icon-color': 'rgb(192, 192, 192)'
'--paper-item-icon-active-color': 'rgb(255, 128, 0)'
- type: conditional
conditions:
- entity: binary_sensor.bedroom_air_purifier_mode_fan
state: 'on'
elements:
- type: state-icon
entity: binary_sensor.bedroom_air_purifier_mode_fan_1
title: Fan level 1
icon: 'mdi:fan-speed-1'
tap_action:
action: call-service
service: xiaomi_miio.fan_set_fan_level
service_data:
entity_id: fan.bedroom_air_purifier
level: 1
style:
top: 65%
left: 42%
transform: 'translate(-50%, 0)'
'--paper-item-icon-color': 'rgb(192, 192, 192)'
'--paper-item-icon-active-color': 'rgb(255, 128, 0)'
- type: state-icon
entity: binary_sensor.bedroom_air_purifier_mode_fan_2
title: Fan level 2
icon: 'mdi:fan-speed-2'
tap_action:
action: call-service
service: xiaomi_miio.fan_set_fan_level
service_data:
entity_id: fan.bedroom_air_purifier
level: 2
style:
top: 65%
left: 50%
transform: 'translate(-50%, 0)'
'--paper-item-icon-color': 'rgb(192, 192, 192)'
'--paper-item-icon-active-color': 'rgb(255, 128, 0)'
- type: state-icon
entity: binary_sensor.bedroom_air_purifier_mode_fan_3
title: Fan level 3
icon: 'mdi:fan-speed-3'
tap_action:
action: call-service
service: xiaomi_miio.fan_set_fan_level
service_data:
entity_id: fan.bedroom_air_purifier
level: 3
style:
top: 65%
left: 58%
transform: 'translate(-50%, 0)'
'--paper-item-icon-color': 'rgb(192, 192, 192)'
'--paper-item-icon-active-color': 'rgb(255, 128, 0)'
- type: conditional
conditions:
- entity: binary_sensor.bedroom_air_purifier_mode_favorite
state: 'on'
elements:
- type: state-label
entity: sensor.bedroom_air_purifier_favorite_level
title: Favorite level
tap_action:
action: none
style:
top: 67%
left: 50%
min-width: 40px
min-height: 40px
text-align: center
font-size: 200%
transform: 'translate(-50%, 0)'
color: 'rgb(255, 128, 0)'
- type: icon
icon: 'mdi:plus'
title: Favorite level +
tap_action:
action: call-service
service: script.bedroom_air_purifier_favorite_up
service_data:
entity_id: fan.bedroom_air_purifier
step: 1
style:
top: 69%
left: 60%
min-width: 40px
min-height: 40px
transform: 'translate(-50%, 0)'
color: 'rgb(192, 192, 192)'
color_off: 'rgb(255, 128, 0)'
- type: icon
icon: 'mdi:minus'
title: Favorite level -
tap_action:
action: call-service
service: script.bedroom_air_purifier_favorite_down
service_data:
entity_id: fan.bedroom_air_purifier
step: 1
style:
top: 69%
left: 44%
min-width: 40px
min-height: 40px
transform: 'translate(-50%, 0)'
color: 'rgb(192, 192, 192)'
color_off: 'rgb(255, 128, 0)'
2S (Living Room) Lovelace card
type: picture-elements
title: Living Room Air-Purifier
image: local/mi_air_purifier_big_circle_2.png
elements:
- type: state-icon
entity: binary_sensor.living_room_air_purifier_mode_off
title: 'Off'
icon: 'mdi:power-standby'
tap_action:
action: call-service
service: fan.turn_off
service_data:
entity_id: fan.living_room_air_purifier
style:
top: 10%
left: 20%
transform: 'translate(-50%, 0)'
'--paper-item-icon-color': 'rgb(128, 128, 128)'
'--paper-item-icon-active-color': 'rgb(255, 128, 0)'
- type: state-icon
entity: fan.living_room_air_purifier
title: More Info
icon: 'mdi:dots-vertical'
tap_action:
action: more-info
style:
top: 10%
left: 82%
transform: 'translate(-50%, 0)'
'--paper-item-icon-color': 'rgb(128, 128, 128)'
'--paper-item-icon-active-color': 'rgb(128, 128, 128)'
- type: conditional
conditions:
- entity: binary_sensor.living_room_air_purifier_mode_off
state: 'off'
elements:
- type: state-label
entity: sensor.living_room_air_purifier_air_quality_pm25
title: PM2.5
tap_action:
action: more-info
style:
top: 18%
left: 50%
min-width: 40px
min-height: 40px
text-align: center
font-size: 400%
transform: 'translate(-50%, 0)'
color: 'rgb(255,255,255)'
- type: state-label
entity: sensor.living_room_air_purifier_temp
title: Temperature
tap_action:
action: more-info
style:
top: 36%
left: 42%
min-width: 40px
min-height: 40px
text-align: center
font-size: 110%
transform: 'translate(-50%, 0)'
color: 'rgb(255,255,255)'
- type: state-label
entity: sensor.living_room_air_purifier_humidity
title: Humidity
tap_action:
action: more-info
style:
top: 36%
left: 58%
min-width: 40px
min-height: 40px
text-align: center
font-size: 110%
transform: 'translate(-50%, 0)'
color: 'rgb(255,255,255)'
- type: conditional
conditions:
- entity: binary_sensor.living_room_air_purifier_mode_off
state: 'on'
elements:
- type: state-label
entity: sensor.living_room_air_purifier_air_quality_pm25
title: PM2.5
tap_action:
action: more-info
style:
top: 18%
left: 50%
min-width: 40px
min-height: 40px
text-align: center
font-size: 400%
transform: 'translate(-50%, 0)'
color: 'rgb(128, 128, 128)'
- type: state-label
entity: sensor.living_room_air_purifier_temp
title: Temperature
tap_action:
action: more-info
style:
top: 36%
left: 42%
min-width: 40px
min-height: 40px
text-align: center
font-size: 100%
transform: 'translate(-50%, 0)'
color: 'rgb(128, 128, 128)'
- type: state-label
entity: sensor.living_room_air_purifier_humidity
title: Humidity
tap_action:
action: more-info
style:
top: 36%
left: 58%
min-width: 40px
min-height: 40px
text-align: center
font-size: 100%
transform: 'translate(-50%, 0)'
color: 'rgb(128, 128, 128)'
- type: state-icon
entity: binary_sensor.living_room_air_purifier_mode_auto
title: Auto
icon: 'mdi:autorenew'
tap_action:
action: call-service
service: fan.set_speed
service_data:
entity_id: fan.living_room_air_purifier
speed: Auto
style:
top: 50%
left: 37%
transform: 'translate(-50%, 0)'
'--paper-item-icon-color': 'rgb(192, 192, 192)'
'--paper-item-icon-active-color': 'rgb(255, 128, 0)'
- type: state-icon
entity: binary_sensor.living_room_air_purifier_mode_silent
title: Silent
icon: 'mdi:power-sleep'
tap_action:
action: call-service
service: fan.set_speed
service_data:
entity_id: fan.living_room_air_purifier
speed: Silent
style:
top: 50%
left: 50%
transform: 'translate(-50%, 0)'
'--paper-item-icon-color': 'rgb(192, 192, 192)'
'--paper-item-icon-active-color': 'rgb(255, 128, 0)'
- type: state-icon
entity: binary_sensor.living_room_air_purifier_mode_favorite
title: Favorite
icon: 'mdi:heart'
tap_action:
action: call-service
service: fan.set_speed
service_data:
entity_id: fan.living_room_air_purifier
speed: Favorite
style:
top: 50%
left: 63%
transform: 'translate(-50%, 0)'
'--paper-item-icon-color': 'rgb(192, 192, 192)'
'--paper-item-icon-active-color': 'rgb(255, 128, 0)'
- type: conditional
conditions:
- entity: binary_sensor.living_room_air_purifier_mode_favorite
state: 'on'
elements:
- type: state-label
entity: sensor.living_room_air_purifier_favorite_level
title: Favorite level
tap_action:
action: none
style:
top: 67%
left: 50%
min-width: 40px
min-height: 40px
text-align: center
font-size: 200%
transform: 'translate(-50%, 0)'
color: 'rgb(255, 128, 0)'
- type: icon
icon: 'mdi:plus'
title: Favorite level +
tap_action:
action: call-service
service: script.living_room_air_purifier_favorite_up
service_data:
entity_id: fan.living_room_air_purifier
step: 1
style:
top: 69%
left: 60%
min-width: 40px
min-height: 40px
transform: 'translate(-50%, 0)'
color: 'rgb(192, 192, 192)'
color_off: 'rgb(255, 128, 0)'
- type: icon
icon: 'mdi:minus'
title: Favorite level -
tap_action:
action: call-service
service: script.living_room_air_purifier_favorite_down
service_data:
entity_id: fan.living_room_air_purifier
step: 1
style:
top: 69%
left: 44%
min-width: 40px
min-height: 40px
transform: 'translate(-50%, 0)'
color: 'rgb(192, 192, 192)'
color_off: 'rgb(255, 128, 0)'
Picture to be put in config/www