Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 298 lines (287 sloc) 10 KB
###############################################################################
# @author : Trent Stanton
# @date : 19/05/2018
# @package : Xiaomi Robot Vacuum
# @description : Xiaomi Robot Vacuum Control, Zones and Schedule
###############################################################################
homeassistant:
customize:
input_boolean.disable_daily_vacuum:
icon: mdi:stop-circle-outline
input_boolean.disable_dustbin_notification:
icon: mdi:delete-empty
binary_sensor.vacuum_room:
custom_ui_state_card: state-card-floorplan
config: !include ../floorplan_vacuum.yaml
binary_sensor:
- platform: mqtt
state_topic: dummy/floorplan/sensor
name: Vacuum Room
frontend:
extra_html_url:
- /local/custom_ui/state-card-floorplan.html
group:
Robot Vacuum:
control: hidden
entities:
- vacuum.xiaomi_vacuum_cleaner
- input_boolean.disable_daily_vacuum
Vacuum a Room:
control: hidden
entities:
- input_select.vacuum_room
- binary_sensor.vacuum_room
vacuum:
- platform: xiaomi_miio
host: !secret xiaomi_vacuum_ip
token: !secret xiaomi_vacuum_token
input_boolean:
daily_vacuum_first_run:
name: Daily Vacuum First Run
initial: off
disable_daily_vacuum:
name: Disable Daily Vacuum Automation
initial: on
disable_dustbin_notification:
name: Disable Dustbin Notification
initial: off
input_select:
vacuum_room:
name: Choose a room to clean
options:
- Select Input
- All Except Bedroom and Ensuite
- Bedroom
- Dining Room
- Ensuite Bathroom
- Entryway
- Kitchen
- Living Room
- Main Bathroom
- Mopping Surfaces
- Projector Room
- Study
initial: Select Input
script:
vacuum_all_except_bedroom_and_ensuite:
alias: "Vacuum All Except Bedroom and Ensuite"
sequence:
- service: vacuum.send_command
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
command: app_zoned_clean
params: [[16034,19737,26234,29237,1],[19487,29248,26237,32198,1]]
vacuum_bedroom:
alias: "Vacuum Bedroom"
sequence:
- service: vacuum.send_command
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
command: app_zoned_clean
params: [[12038,27467,16088,32017,1]]
vacuum_dining_room:
alias: "Vacuum Dining Room"
sequence:
- service: vacuum.send_command
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
command: app_zoned_clean
params: [[16079,24984,19679,28134,1]]
vacuum_ensuite_bathroom:
alias: "Vacuum Ensuite Bathroom"
sequence:
- service: vacuum.send_command
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
command: app_zoned_clean
params: [[12038,27467,16088,32017,1]]
# Entryway not working correctly
vacuum_entryway:
alias: "Vacuum Entryway"
sequence:
- service: vacuum.send_command
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
command: app_zoned_clean
params: [[22948,22862,24798,25062,1]]
vacuum_kitchen:
alias: "Vacuum Kitchen"
sequence:
- service: vacuum.send_command
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
command: app_zoned_clean
params: [[19444,24947,21444,27997,1]]
vacuum_living_room:
alias: "Vacuum Living Room"
sequence:
- service: vacuum.send_command
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
command: app_zoned_clean
params: [[18266,19661,23016,25061,1]]
vacuum_main_bathroom:
alias: "Vacuum Main Bathroom"
sequence:
- service: vacuum.send_command
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
command: app_zoned_clean
params: [[19501,29139,22051,31789,1]]
vacuum_mopping_surfaces:
alias: "Vacuum Mopping Surfaces"
sequence:
- service: vacuum.send_command
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
command: app_zoned_clean
params: [[16602,29163,22052,32313,1],[16028,24951,21578,28151,1],[22975,22737,24375,25087,1]]
vacuum_projector_room:
alias: "Vacuum Projector Room"
sequence:
- service: vacuum.send_command
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
command: app_zoned_clean
params: [[22058,28711,26208,32061,1]]
vacuum_study:
alias: "Vacuum Study"
sequence:
- service: vacuum.send_command
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
command: app_zoned_clean
params: [[23004,25042,26404,28442,1]]
sensor:
- platform: template
sensors:
xiaomi_vacuum_cleaner_status:
entity_id:
- vacuum.xiaomi_vacuum_cleaner
friendly_name: "Xiaomi Vacuum Cleaner Status"
value_template: "{{ states.vacuum.xiaomi_vacuum_cleaner }}"
###############################################################################
# Automations
###############################################################################
automation:
- alias: Start Daily Vacuum
trigger:
- platform: state
entity_id: group.family_presence
from: 'home'
to: 'not_home'
for:
minutes: 2
- platform: time
at: '7:02:00'
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.daily_vacuum_first_run
state: 'off'
- condition: time
after: '07:00:00'
before: '22:00:00'
- condition: state
entity_id: group.family_presence
state: 'not_home'
- condition: state
entity_id: input_boolean.disable_daily_vacuum
state: 'off'
action:
- delay: '00:00:30'
- service: vacuum.turn_on
entity_id: vacuum.xiaomi_vacuum_cleaner
- service: homeassistant.turn_on
entity_id: input_boolean.daily_vacuum_first_run
- alias: Reset Daily Vacuum First Run state at midnight
trigger:
- platform: time
at: '0:00:00'
action:
- service: homeassistant.turn_off
entity_id: input_boolean.daily_vacuum_first_run
- alias: Send alert after daily vacuum to empty the dustbin
trigger:
- platform: state
entity_id: group.family_presence
to: 'home'
for:
minutes: 2
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.daily_vacuum_first_run
state: 'on'
- condition: time
after: '08:30:00'
before: '22:30:00'
- condition: template
value_template: >
{% if states.automation.send_alert_after_daily_vacuum_to_empty_the_dustbin.last_triggered is not none %}
{% if as_timestamp(now()) | int - as_timestamp(states.automation.send_alert_after_daily_vacuum_to_empty_the_dustbin.attributes.last_triggered) | int > 1800 %} true {% else %} false
{% endif %}
{% else %}
false
{% endif %}
- condition: state
entity_id: input_boolean.disable_dustbin_notification
state: 'off'
action:
- service: script.speech_processing
data_template:
speech_message: >
{% if (is_state('person.trent', 'home')) or (is_state('person.rachel', 'home')) %}
Attention!: the vacuum dustbin needs to be cleared.
{% endif %}
- service_template: >
{% if (is_state('person.trent', 'home')) and (is_state('person.rachel', 'home')) %}
notify.trent_and_rachel
{% elif is_state('person.trent', 'home') %}
notify.telegram_trent
{% elif is_state('person.rachel', 'home') %}
notify.rachel
{% endif %}
data:
message: 'Hey, the vacuum dustbin needs to be cleared'
title: 'Vacuum Dustbin'
- alias: Start Cleaning Room
hide_entity: True
trigger:
- platform: state
entity_id: input_select.vacuum_room
from: 'Select Input'
action:
- service: script.turn_on
data_template:
entity_id: >
{% if is_state("input_select.vacuum_room", "All Except Bedroom and Ensuite") %}
script.vacuum_all_except_bedroom_and_ensuite
{% elif is_state("input_select.vacuum_room", "Bedroom") %}
script.vacuum_bedroom
{% elif is_state("input_select.vacuum_room", "Dining Room") %}
script.vacuum_dining_room
{% elif is_state("input_select.vacuum_room", "Ensuite Bathroom") %}
script.vacuum_ensuite_bathroom
{% elif is_state("input_select.vacuum_room", "Entryway") %}
script.vacuum_entryway
{% elif is_state("input_select.vacuum_room", "Kitchen") %}
script.vacuum_kitchen
{% elif is_state("input_select.vacuum_room", "Living Room") %}
script.vacuum_living_room
{% elif is_state("input_select.vacuum_room", "Main Bathroom") %}
script.vacuum_main_bathroom
{% elif is_state("input_select.vacuum_room", "Mopping Surfaces") %}
script.vacuum_mopping_surfaces
{% elif is_state("input_select.vacuum_room", "Projector Room") %}
script.vacuum_projector_room
{% elif is_state("input_select.vacuum_room", "Study") %}
script.vacuum_study
{% else %}
{% endif %}
- service: input_select.select_option
data:
entity_id: input_select.vacuum_room
option: "Select Input"
You can’t perform that action at this time.