Skip to content

Instantly share code, notes, and snippets.

@ophilips
Last active June 1, 2023 21:34
Show Gist options
  • Save ophilips/116a2cda6d4e10825826af9640a92199 to your computer and use it in GitHub Desktop.
Save ophilips/116a2cda6d4e10825826af9640a92199 to your computer and use it in GitHub Desktop.
Xiaomi Vacuum as "template fan" for Home Assistant/HomeKit. The fan slider (0-100) in HomeKit will be translated to the the corresponding vacuum presets or speeds (off, Silent, Standard, Medium, Turbo).
# Xiaomi HomeKit
fan:
- platform: template
fans:
xiaomi_fan:
friendly_name: "Xiaomi Vacuum"
value_template: "{%if states('vacuum.xiaomi_vacuum_cleaner') == 'cleaning' %}on{%elif states('vacuum.xiaomi_vacuum_cleaner') == 'paused' %}on{%else %}off{% endif %}"
speed_template: "{{ state_attr('vacuum.xiaomi_vacuum_cleaner', 'fan_speed') }}"
turn_on:
service: vacuum.start
entity_id: vacuum.xiaomi_vacuum_cleaner
# turn_on:
# service: xiaomi_miio.vacuum_clean_zone
# data_template:
# entity_id: vacuum.xiaomi_vacuum_cleaner
# repeats: 1
# zone: [[18724,22506,25440,24620],[23758,20813,24906,22506]]
turn_off:
service: vacuum.return_to_base
entity_id: vacuum.xiaomi_vacuum_cleaner
set_speed:
service: vacuum.set_fan_speed
data_template:
fan_speed: "{{ speed }}"
entity_id: vacuum.xiaomi_vacuum_cleaner
speeds:
- 'off'
- 'Silent'
- 'Standard'
- 'Medium'
- 'Turbo'
# - 'Gentle'
sensor:
- platform: template
sensors:
xiaomi_fan:
unit_of_measurement: '%'
value_template: "{{ state_attr('vacuum.xiaomi_vacuum_cleaner', 'battery_level') }}"
homekit:
entity_config:
fan.xiaomi_fan:
linked_battery_sensor: sensor.xiaomi_fan
@TerrorSource
Copy link

Doesnt work anymore.

Deprecated services: fan.set_speed
source: https://www.home-assistant.io/integrations/fan/

Does anyone have a working config for Homekit with latest HA versions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment