My first HASS project has been to add remote controls for my Xiaomi Gen 1 vacuum, so I don’t have to pick it up when doing spot clean-up. I also added a link to a Calendar on my Nextcloud install to visually schedule cleans. If there is an all day event called Vacuum
it will begin cleaning at 8:30am.
Buttons (starting top left):
- Manual mode (lowers fan speed to min for driving)
- Double forward
- Start Cleanup
- Turn left 15 deg
- Single forward
- Turn right 15 deg
- Turn left 45 deg
- Stop
- Turn right 45 deg
- Spot clean
- Single reverse
- Go back to the dock
It’s not 100% done yet ( Fan speed isn’t reset if you press Spot cleanup, Go back to the dock or Start Cleanup ) but I felt like showing it off anyway
Requires:
https://github.com/c727/home-assistant-tiles
Contents of configuration.yaml
[ Click to Expand ]
vacuum:
- platform: xiaomi_miio
host: 10.1.1.99
token: !secret xiaomi
calendar:
- platform: caldav
url: https://example.tld/remote.php/dav
username: dugite
password: !secret caldav
custom_calendars:
- name: vacuum
calendar: House and Home
search: 'Vacuum'
input_boolean:
control_tiles:
switch:
- platform: template
switches:
vac_clean:
value_template: "{{ states.vacuum.xiaomi_vacuum_cleaner.state == 'on' }}"
turn_on:
service: vacuum.start_pause
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
turn_off:
service: vacuum.stop
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
vac_manual:
value_template: "{{ states.vacuum.xiaomi_vacuum_cleaner.attributes.status == 'Manual mode' }}"
turn_on:
service: script.vac_man_on
turn_off:
service: script.vac_man_off
Contents of customize.yml
[ Click to Expand ]
input_boolean.control_tiles:
custom_ui_state_card: state-card-tiles
config:
columns: 3
entities:
- entity: switch.vac_manual
icon: mdi:robot-vacuum
row: 1
column: 1
- entity: input_boolean.switch1
icon: mdi:chevron-double-up
row: 1
column: 2
color_off: "#607D8B"
service: vacuum.xiaomi_remote_control_move
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
velocity: 0.29
rotation: 0
duration: 6000
- entity: switch.vac_clean
icon_template: "if (state === 'on') return 'mdi:stop-circle-outline'; else return 'mdi:play-speed'"
row: 1
column: 3
- entity: input_boolean.switch1
icon: mdi:rotate-left
row: 2
column: 1
color_off: "#607D8B"
service: vacuum.xiaomi_remote_control_move
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
velocity: 0
rotation: 15
duration: 1500
- entity: input_boolean.switch1
icon: mdi:chevron-up
row: 2
column: 2
color_off: "#607D8B"
service: vacuum.xiaomi_remote_control_move
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
rotation: 0
velocity: 0.29
duration: 1500
- entity: input_boolean.switch1
icon: mdi:rotate-right
row: 2
column: 3
color_off: "#607D8B"
service: vacuum.xiaomi_remote_control_move
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
velocity: 0
rotation: -15
duration: 1500
- entity: input_boolean.switch1
icon: mdi:hexagon
row: 3
column: 2
color_off: "#607D8B"
text_color_off: "#f44336"
service: vacuum.xiaomi_remote_control_move
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
velocity: 0
rotation: 0
duration: 100
- entity: input_boolean.switch1
icon: mdi:arrow-left-bold-circle-outline
row: 3
column: 1
color_off: "#607D8B"
service: vacuum.xiaomi_remote_control_move
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
velocity: 0
rotation: 45
duration: 1500
- entity: input_boolean.switch1
icon: mdi:arrow-right-bold-circle-outline
row: 3
column: 3
color_off: "#607D8B"
service: vacuum.xiaomi_remote_control_move
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
velocity: 0
rotation: -45
duration: 1500
- entity: input_boolean.switch1
icon: mdi:bullseye
row: 4
column: 1
color_off: "#C5E1A5"
service: vacuum.clean_spot
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
- entity: input_boolean.switch1
icon: mdi:chevron-down
row: 4
column: 2
color_off: "#607D8B"
service: vacuum.xiaomi_remote_control_move
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
velocity: -0.29
rotation: 0
duration: 1500
- entity: input_boolean.switch1
icon: mdi:home-map-marker
row: 4
column: 3
color_off: "#80CBC4"
service: vacuum.return_to_base
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
Contents of automation.yaml
[ Click to Expand ]
id: '1525941249222'
alias: Vacuum 8:30 Auto Start
trigger:
- at: '8:30:00'
platform: time
condition:
- condition: state
entity_id: calendar.house_and_home_vacuum
state: 'on'
- condition: template
value_template: '{{ states.calendar.house_and_home_vacuum.attributes.all_day }}'
action:
service: vacuum.turn_on
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
Contents of scripts.yml
[ Click to Expand ]
vac_man_on:
sequence:
- service: vacuum.set_fan_speed
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
fan_speed: 10
- service: vacuum.xiaomi_remote_control_start
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
vac_man_off:
sequence:
- service: vacuum.set_fan_speed
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
fan_speed: 90
- service: vacuum.xiaomi_remote_control_stop
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
2 Edits
- Added the script.yaml config I had forgotten
- fixed some text I truncated in configuration.yaml
nput_boolean:
control_tiles:
to
input_boolean:
control_tiles:
Zone cleaning with the Calendar
I added zone cleaning capabilities see: Howto: Xiaomi vacuum zoned cleaning
First:
I added the following to the previous automation
- condition: template
value_template: '{{ states.calendar.house_and_home_vacuum.attributes.message == "Vacuum"}}'
Second:
Using this helper script:
Third:
I added the following automation
- id: 'zone_auto'
alias: Vacuum Zone 10:30 Auto Start
trigger:
- at: '10:30:00'
platform: time
condition:
- condition: state
entity_id: calendar.house_and_home_vacuum
state: 'on'
- condition: template
value_template: '{{ states.calendar.house_and_home_vacuum.attributes.all_day }}'
- condition: template
value_template: '{{ "Vacuum -" in states.calendar.house_and_home_vacuum.attributes.message }}'
action:
service: python_script.zone_clean
data_template:
entity_id: vacuum.xiaomi_vacuum_cleaner
zone_list: '{{ states.calendar.house_and_home_vacuum.attributes.message }}'