I have latest HA (104.2) and device is: fan.xiaomi… but most of services are xiaomi_miio.fan_…. but fan speed is still fan.set_speed
Bit of confusing
I have latest HA (104.2) and device is: fan.xiaomi… but most of services are xiaomi_miio.fan_…. but fan speed is still fan.set_speed
Bit of confusing
Does anybody have an idea how to realize some kind of “scan_interval” for the template sensors or the integration itself? I don’t need the chatty 30 seconds updates in my database. So of course I could delete the template sensors not really needed (e.g. fan speed), but the main integration will update itself every 30 seconds and I assume that the attributes are also recorded and saved in the the database all the time?
Edit: Okay that was too obvious. Just add scan_interval to the configuration.yaml. It works, even it’s not documented.
does anybody know if version 3 / 3h is supported?
@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: