@sobczynski in your config and auto, appear 2 errors in HA 0.105.4
Invalid option: auto (possible options: Auto, Silent, Favorite)
and
Error rendering data template: UndefinedError: 'input_number' is undefined
how too solved
@sobczynski in your config and auto, appear 2 errors in HA 0.105.4
Invalid option: auto (possible options: Auto, Silent, Favorite)
and
Error rendering data template: UndefinedError: 'input_number' is undefined
how too solved
I’m not sure how to solve it, but I had already noticed that the Xiaomi purifier has a small issue: it provides status as lowercase (auto, silent, favourite), but accepts status setting using capitals (Auto, Silent, Favorite).
This way when the automations compare the value seti in Lovelace with the value reported from Xiaomi, the two don’t match perfectly due to capitalization.
Or at least this was what I got from the error logs, then I temporarily abandoned the issue because I don’t change settings from Lovelace anyway, but I know they one day I’ll have to find out how to solve the issue.
Other issue, i put the auto of OP, but the Airpurifier not turn OFF !! eny idea?
same here.
Invalid option: auto (possible options: Auto, Silent, Favorite)
The config is the following:
input_select:
# Xiaomi Air Purifier 2S
xiaomi_airpurifier_mode:
name: Modalità
options:
- Auto
- Silent
- Favorite
icon: "mdi:animation-outline"
Any hint?
I won’t have access to my server for a while, but try this: stop HA, go to the folder where HA is installed, look for the components subfolder, then for xiaomi_miio, then edit the file fan.py.
In that file look for the text “Silent” (it appears only in few lines) and replace all occurrences of the uppercase Auto, Silent, Favourite with the lowercase equivalents.
Start HA and see if the fan still works and accept the new statuses. The automations should be adapted to also have everything lowercase.
If it works, the Xiaomi component should be updated. If not, the component needs to implement a case conversion.
Forget my suggestion.
The thread linked provided the solution.
Alternative solution: Capitalize()
Sorry but just to be sure.
So this
speed: '{{ states.input_select.xiaomi_airpurifier_mode.state }}'
will become this
speed: '{{ states.input_select.xiaomi_airpurifier_mode.state | capitalize }}'
and so on. Right?
That syntax is deprecated as far as I know. You should use “state_attr()”
This is mine:
alias: 'Air Purifier: mode changed to UI'
trigger:
platform: state
entity_id: fan.air_purifier_living_room
condition:
condition: and
conditions:
- condition: template
value_template: '{{ (state_attr(''fan.air_purifier_living_room'', ''mode'') | string | capitalize)
!= (states(''input_select.air_purifier_living_room_mode'') | string)
}}'
action:
- service: input_select.select_option
entity_id: input_select.air_purifier_living_room_mode
data_template:
option: '{{ state_attr(''fan.air_purifier_living_room'', ''mode'') | capitalize }}'
The " | string " may not be necessary
Maybe someone will come in handy, works on Home Assistant 0.105.5 and air purifier 2s
configuration.yaml
fan:
- platform: xiaomi_miio
name: fan.air_purifier_2s
host: your ip
token: your token
input_select:
xiaomi_airpurifier_mode:
name: Mode
options:
- Auto
- Silent
- Favorite
icon: "mdi:animation-outline"
input_number:
xiaomi_airpurifie_favorite_level:
name: "Favorite level"
initial: 0
min: 0
max: 14
step: 1
icon: "mdi:weather-windy"
sensors.yaml
- 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"
xiaomi_airpurifier_illuminance:
friendly_name: "Filter illuminance"
value_template: "{{ state_attr('fan.xiaomi_miio_device', 'illuminance') }}"
unit_of_measurement: "lx"
icon_template: "mdi:brightness-5"
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_miio_device
speed: '{{ states.input_select.xiaomi_airpurifier_mode.state }}'
- alias: Air Purifier favorite level change
trigger:
entity_id: input_number.xiaomi_airpurifie_favorite_level
platform: state
action:
service: xiaomi_miio.fan_set_favorite_level
data_template:
entity_id: fan.xiaomi_miio_device
level: '{{ states.input_number.xiaomi_airpurifie_favorite_level.state | int }}'
switch.yaml
- 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"
ui-lovelace.yaml
- type: entities
show_header_toggle: false
entities:
- entity: fan.xiaomi_miio_device
name: fanь
- entity: sensor.xiaomi_airpurifier_speed
name: speed
- entity: switch.xiaomi_airpurifier_led
name: led
- entity: switch.xiaomi_airpurifier_buzzer
name: buzzer
- entity: switch.xiaomi_airpurifier_child_lock
name: child lock
- entity: sensor.xiaomi_airpurifier_illuminance
name: illuminance
- entity: input_select.xiaomi_airpurifier_mode
name: mode
- entity: input_number.xiaomi_airpurifie_favorite_level
name: favorite level
- entity: sensor.xiaomi_airpurifier_temp
name: temp
icon: mdi:temperature-celsius
- entity: sensor.xiaomi_airpurifier_humidity
name: humidity
icon: mdi:water-percent
- entity: sensor.xiaomi_airpurifier_air_quality_pm25
name: PM2.5
icon: mdi:hexagon-multiple
Hey guys, i have 2 purifiers a 2s and a pro. I cannot get both of them to work at the same time, if only 1 is added it works, the moment i define the second one, the first goes offline.
i define each as a separate entity, do i need to use
fan:
fans:
purifier1:
purifier2:
?
Hi,
Write it like this:
fan:
- platform: xiaomi_miio
name: Air Purifier 1
host: Your IP
token: Your token
- platform: xiaomi_miio
name: Air Purifier 2
host: Your IP
token: Your token
Hey guys! Sorry I didnt receive any mails for this post. They made breaking changes so the names of the services have changed and some buttons were no more working. I updated my initial post so now everythings works again!
What never worked for me is the “Fan speed”. When rebooting hass.io it shows the current value but then never gets updated. Someone has an idea for that?
Yes you can have more than one. I have two. Unfortunately you have to duplicate the configuration but set a different name. I tried to keep mine organized by making comments with #
.
For example my configuration.yaml.
fan:
# Xiaomi Air Purifier 2S (bedroom)
- platform: xiaomi_miio
host: 192.168.178.101
token: d40e9fc6e92a34cdd92aad38c90b2ed6
name: "Air Purifier 2S (bedroom)"
# Xiaomi Air Purifier 2S (living room)
- platform: xiaomi_miio
host: 192.168.178.102
token: 46bd5a3951a607d21710a10e1b47c86b
name: "Air Purifier 2S (living room)"
And then my devices are named fan.air_purifier_2s_bedroom
and fan.air_purifier_2s_living_room
. You can find the names developer tools -> entity autocomplete.
Maybe I did something wrong, but when I start the application, the favorite mode’s slider is set to 0 (initial: 0) despite of checking the actual value. Is it possible to query its setting and start with that one?
That are the two things I didnt figure out yet:
Thanks all, that worked.
Now onto my next question, how do i setup the sensors independently.
This is what i use for one
sensor:
- platform: template
sensors:
mi_aqi:
friendly_name: "Upstairs Air Purifier"
unit_of_measurement: 'AQI'
value_template: "{{ state_attr('fan.xiaomi_miio_device', 'aqi') }}"
i cant get the second one to show separately
Hi @MickL,
Hi everybody,
Last month I’ve bought a brand new Xiaomi Mi Air Purifier 2H (European model) and since then I’m using it with your settings recommendations without any issue. It works flawlessly and I’m very happy.
The problem is my ‘configuration.yaml’ file. It is a real mess and I would like to keep it clean the more I can.
So I’m wondering if I may I use the ‘!include’ function for keep it clean, moving all the “purifier commands” stored in ‘configuration.yaml’ to a new file called ‘mi_purifier_2H.yaml’ (for instance).
In other words, I’m talking about writing a command line (inside my ‘configuration.yaml’ file) as the one below:
fan: !include mi_purifier_2H.yaml
Until now, the best I could was moving the ‘switch:’ command to a ‘switch.yaml’ file and the ‘sensor:’ command to a ‘sensor.yaml’ file.
Instead, ‘fan:’, ‘input_select:’ and ‘input_number’ commands are stored into ‘configuration.yaml’ file.
Any help?
I know I’m THE real noob…
Luca
P.S.
sorry for my poor English