Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 將檔案放在package內
- # 這邊有做以下自動化&腳本:
- # 1. 先掃地後再自動拖地
- # 2. 根據房門開關來決定清掃哪些區域
- # 3. 掃地的區域順序與拖地的順序不同
- # 4. 拖地完成後會清洗兩次拖布再烘乾兩次
- # 有用額外的input boolean來做判斷以及用notify做line通知
- ###############################################################################
- # Automation
- ###############################################################################
- automation:
- - id: vacuum_button_click_start_clean
- alias: vacuum_button_click_start_clean
- description: 掃地機-按鈕後開始掃地
- trigger:
- - platform: state
- entity_id: input_button.start_vacuum
- - platform: state
- entity_id: sensor.click_vacuumctrl_action
- to: 'on'
- condition:
- - condition: state
- entity_id: vacuum.xiaomi_x10
- state: 'docked'
- action:
- - service: vacuum.set_fan_speed
- data:
- entity_id: vacuum.xiaomi_x10
- fan_speed: 'Turbo'
- - service: select.select_option
- data:
- option: sweeping
- target:
- entity_id: select.xiaomi_x10_cleaning_mode
- - service: input_boolean.turn_on
- data:
- entity_id: input_boolean.vacuum_start_clean
- - service: notify.simon_home_notify
- data:
- message: "開始掃地"
- - service: script.turn_on
- data:
- entity_id: script.choose_clean_area
- - id: vacuum_button_click_start_mopping
- alias: vacuum_button_click_start_mopping
- description: 掃地機-按鈕後開始拖地
- trigger:
- - platform: state
- entity_id: input_button.strat_mop
- - platform: state
- entity_id: sensor.click_vacuumctrl_action
- to: 'off' #'brightness_move_down'
- - platform: state
- entity_id: input_boolean.vacuum_is_mopping
- to: 'on'
- condition:
- condition: and
- conditions:
- - condition: state
- entity_id: vacuum.xiaomi_x10
- state: 'docked'
- #避免第一次先按拖地,必須先掃地後才能按拖地
- - condition: state
- entity_id: input_boolean.vacuum_start_clean
- state: 'on'
- action:
- - service: vacuum.set_fan_speed
- data:
- entity_id: vacuum.xiaomi_x10
- fan_speed: 'Silent'
- - service: select.select_option
- data:
- option: mopping
- target:
- entity_id: select.xiaomi_x10_cleaning_mode
- - data:
- entity_id: input_boolean.vacuum_start_clean
- service: input_boolean.turn_off
- - delay:
- seconds: 1
- - service: select.select_option
- data:
- option: slightly_dry
- target:
- entity_id: select.xiaomi_x10_mop_pad_humidity
- - delay:
- milliseconds: 300
- - service: script.turn_on
- data:
- entity_id: script.choose_clean_area
- - id: vacuum_clean_finish_notify
- alias: "通知-掃地機器人完成清掃發送通知"
- trigger:
- - entity_id: vacuum.xiaomi_x10
- platform: state
- from: 'returning'
- to: 'docked'
- condition:
- condition: and
- conditions:
- - condition: state
- entity_id: input_boolean.vacuum_start_clean
- state: 'on'
- - condition: template
- value_template: "{{ int(states('sensor.xiaomi_x10_cleaning_time')) > 1 }}"
- action:
- - service: notify.line_notify
- data:
- message: >
- 《掃地機》 {{ '\n' -}}
- 掃地完成! 一共花了 {{ states('sensor.xiaomi_x10_cleaning_time') }} 分鐘清掃 {{ states('sensor.xiaomi_x10_cleaned_area') }} m²
- {% if int(states('sensor.xiaomi_x10_sensor_dirty_time_left')) < 1 %}
- {{ '\n' -}}感應器需要清潔囉!
- {% endif %}
- {% if int(states('sensor.xiaomi_x10_main_brush_time_left')) < 5 %}
- {{ '\n' -}}主刷頭剩下{{ int(states('sensor.xiaomi_x10_main_brush_time_left')) }}小時需要更換囉,記得購買!
- {% endif %}
- {% if int(states('sensor.xiaomi_x10_side_brush_time_left')) < 5 %}
- {{ '\n' -}}側刷頭剩下{{ int(states('sensor.xiaomi_x10_side_brush_time_left')) }}小時需要更換囉,記得購買!
- {% endif %}
- {% if int(states('sensor.xiaomi_x10_filter_time_left')) < 5 %}
- {{ '\n' -}}濾網剩下{{ int(states('sensor.xiaomi_x10_filter_time_left')) }}小時需要更換囉,記得購買!
- {% endif %}
- {% if int(states('sensor.xiaomi_x10_mop_pad_time_left')) < 5 %}
- {{ '\n' -}}拖布剩下{{ int(states('sensor.xiaomi_x10_mop_pad_time_left')) }}小時需要更換囉,記得購買!
- {% endif %}
- - service: input_text.set_value
- target:
- entity_id: input_text.vacuum_area
- data:
- value: " "
- - service: button.press
- data: {}
- target:
- entity_id: button.xiaomi_x10_start_auto_empty
- - wait_for_trigger:
- - platform: state
- entity_id: sensor.xiaomi_x10_auto_empty_status
- from: 'active'
- to: 'idle'
- timeout:
- minutes: 1
- continue_on_timeout: true
- - if: #如果id==0表示有成功觸發
- - "{{ wait.trigger.id != '0' }}"
- then:
- - service: notify.simon_home_notify
- data:
- message: "《掃地機》 集塵超時,繼續執行"
- else:
- - service: notify.simon_home_notify
- data:
- message: "《掃地機》 集塵完畢"
- - data:
- entity_id: input_boolean.vacuum_is_mopping
- service: input_boolean.turn_on
- - service: notify.simon_home_notify
- data:
- message: "《掃地機》 開始拖地"
- - id: vacuum_mopping_finish_notify
- alias: "通知-掃地機器人完成拖地發送通知"
- trigger:
- - platform: state
- entity_id: sensor.xiaomi_x10_self_wash_base_status
- from: 'idle'
- to: 'washing'
- condition:
- - condition: state
- entity_id: input_boolean.vacuum_is_mopping
- state: 'on'
- - condition: template
- value_template: "{{ int(states('sensor.xiaomi_x10_cleaning_time')) > 1 }}"
- - condition: state
- entity_id: sensor.xiaomi_x10_task_status
- state: 'completed'
- action:
- - data:
- entity_id: input_boolean.vacuum_is_mopping
- service: input_boolean.turn_off
- - service: input_text.set_value
- target:
- entity_id: input_text.vacuum_area
- data:
- value: " "
- - service: notify.line_notify
- data:
- message: >
- 《掃地機》 {{ '\n' -}} 拖地完成! 一共花了 {{ states('sensor.xiaomi_x10_cleaning_time') }} 分鐘清掃 {{ states('sensor.xiaomi_x10_cleaned_area') }} m²
- - service: vacuum.set_fan_speed
- data:
- entity_id: vacuum.xiaomi_x10
- fan_speed: 'Turbo'
- - id: vacuum_mop_washing_drying_twice
- alias: vacuum_mop_washing_drying_twice
- description: 掃地機-拖布清洗兩次後再烘乾兩次
- trigger:
- - platform: state
- entity_id: sensor.xiaomi_x10_state
- from: 'washing'
- to: 'drying'
- condition:
- - condition: state
- entity_id: select.xiaomi_x10_cleaning_mode
- state: 'mopping'
- action:
- - service: automation.turn_off
- data:
- entity_id: automation.vacuum_second_drying
- #避免重複觸發此自動化
- - service: select.select_option
- data:
- option: sweeping
- target:
- entity_id: select.xiaomi_x10_cleaning_mode
- - service: notify.simon_home_notify
- data:
- message: "第一次清洗完第一次烘乾"
- - service: button.press
- data: {}
- target:
- entity_id: button.xiaomi_x10_manual_drying
- - wait_for_trigger:
- - platform: state
- entity_id: sensor.xiaomi_x10_state
- from: 'drying'
- to: 'charging'
- timeout:
- minutes: 2
- continue_on_timeout: true
- - if: #如果id==0表示有成功觸發
- - "{{ wait.trigger.id != '0' }}"
- then:
- - service: notify.simon_home_notify
- data:
- message: "第一次烘乾暫停超時,繼續執行"
- else:
- - service: notify.simon_home_notify
- data:
- message: "第一次烘乾暫停"
- - service: button.press
- data: {}
- target:
- entity_id: button.xiaomi_x10_self_clean
- - service: notify.simon_home_notify
- data:
- message: "第二次清洗開始"
- - wait_for_trigger:
- - platform: state
- entity_id: sensor.xiaomi_x10_state
- from: 'washing'
- to: 'drying'
- timeout:
- minutes: 5
- continue_on_timeout: true
- - if: #如果id==0表示有成功觸發
- - "{{ wait.trigger.id != '0' }}"
- then:
- - service: notify.simon_home_notify
- data:
- message: "第二次清洗超時,繼續執行"
- else:
- - service: notify.simon_home_notify
- data:
- message: "第二次清洗完成,開始第一次烘乾"
- - service: automation.turn_on
- data:
- entity_id: automation.vacuum_second_drying
- - id: vacuum_second_drying
- alias: vacuum_second_drying
- description: 掃地機-拖布烘乾第二次
- initial_state: false
- trigger:
- - platform: state
- entity_id: sensor.xiaomi_x10_self_wash_base_status
- from: 'drying'
- to: 'idle'
- condition: []
- action:
- - service: notify.simon_home_notify
- data:
- message: "第二次烘乾開始"
- - service: button.press
- data: {}
- target:
- entity_id: button.xiaomi_x10_manual_drying
- - delay:
- seconds: 1
- - service: automation.turn_off
- data:
- entity_id: automation.vacuum_second_drying
- - id: vacuum_start_clean_reset
- alias: vacuum_start_clean_reset
- description: 掃地機-午夜布林重設
- trigger:
- - platform: time
- at: "00:01:00"
- condition:
- - or:
- - condition: state
- entity_id: input_boolean.vacuum_start_clean
- state: 'on'
- - condition: state
- entity_id: input_boolean.vacuum_is_mopping
- state: 'on'
- action:
- - data:
- entity_id:
- - input_boolean.vacuum_start_clean
- - input_boolean.vacuum_is_mopping
- service: input_boolean.turn_off
- ###############################################################################
- # Script
- ###############################################################################
- script:
- choose_clean_area:
- alias: "根據房門的開關來選擇清掃區域"
- sequence:
- - choose:
- - alias: "全區清掃"
- conditions:
- - condition: state
- entity_id: binary_sensor.door_mainroom_contact
- state: 'on'
- - condition: state
- entity_id: binary_sensor.door_guestroom_contact
- state: 'on'
- sequence:
- - service: input_text.set_value
- target:
- entity_id: input_text.vacuum_area
- data:
- value: "全區清掃"
- - service: notify.simon_home_notify
- data:
- message: "清掃區域:全區清掃"
- - service: script.turn_on
- data:
- entity_id: script.vacuum_area_all
- - alias: "排除主臥"
- conditions:
- - condition: state
- entity_id: binary_sensor.door_mainroom_contact
- state: 'off'
- - condition: state
- entity_id: binary_sensor.door_guestroom_contact
- state: 'on'
- sequence:
- - service: input_text.set_value
- target:
- entity_id: input_text.vacuum_area
- data:
- value: "排除主臥"
- - service: notify.simon_home_notify
- data:
- message: "清掃區域:排除主臥"
- - service: script.turn_on
- data:
- entity_id: script.vacuum_area_except_master_room
- - alias: "排除客房"
- conditions:
- - condition: state
- entity_id: binary_sensor.door_mainroom_contact
- state: 'on'
- - condition: state
- entity_id: binary_sensor.door_guestroom_contact
- state: 'off'
- sequence:
- - service: input_text.set_value
- target:
- entity_id: input_text.vacuum_area
- data:
- value: "排除客房"
- - service: notify.simon_home_notify
- data:
- message: "清掃區域:排除客房"
- - service: script.turn_on
- data:
- entity_id: script.vacuum_area_except_guest_room
- - alias: "排除主臥及客房"
- conditions:
- - condition: state
- entity_id: binary_sensor.door_mainroom_contact
- state: 'off'
- - condition: state
- entity_id: binary_sensor.door_guestroom_contact
- state: 'off'
- sequence:
- - service: input_text.set_value
- target:
- entity_id: input_text.vacuum_area
- data:
- value: "排除主臥及客房"
- - service: notify.simon_home_notify
- data:
- message: "清掃區域:排除主臥及客房"
- - service: script.turn_on
- data:
- entity_id: script.vacuum_area_except_master_guest
- vacuum_area_except_guest_room:
- alias: "區域清掃-排除客房"
- sequence:
- - choose:
- - alias: "掃地"
- conditions:
- - condition: state
- entity_id: select.xiaomi_x10_cleaning_mode
- state: 'sweeping'
- sequence:
- - service: dreame_vacuum.vacuum_clean_segment
- data:
- segments:
- - 2
- - 3
- - 4
- - 5
- - 7
- - 6
- target:
- entity_id: vacuum.xiaomi_x10
- - alias: "拖地"
- conditions:
- - condition: state
- entity_id: select.xiaomi_x10_cleaning_mode
- state: 'mopping'
- sequence:
- - service: dreame_vacuum.vacuum_clean_segment
- data:
- segments:
- - 4
- - 2
- - 3
- - 5
- - 7
- - 6
- target:
- entity_id: vacuum.xiaomi_x10
- vacuum_area_except_master_room:
- alias: "區域清掃-排除主臥"
- sequence:
- - choose:
- - alias: "掃地"
- conditions:
- - condition: state
- entity_id: select.xiaomi_x10_cleaning_mode
- state: 'sweeping'
- sequence:
- - service: dreame_vacuum.vacuum_clean_segment
- data:
- segments:
- - 1
- - 3
- - 4
- - 5
- - 7
- - 6
- target:
- entity_id: vacuum.xiaomi_x10
- - alias: "拖地"
- conditions:
- - condition: state
- entity_id: select.xiaomi_x10_cleaning_mode
- state: 'mopping'
- sequence:
- - service: dreame_vacuum.vacuum_clean_segment
- data:
- segments:
- - 4
- - 1
- - 3
- - 5
- - 7
- - 6
- target:
- entity_id: vacuum.xiaomi_x10
- vacuum_area_except_master_guest:
- alias: "區域清掃-排除主臥及客房"
- sequence:
- - choose:
- - alias: "掃地"
- conditions:
- - condition: state
- entity_id: select.xiaomi_x10_cleaning_mode
- state: 'sweeping'
- sequence:
- - service: dreame_vacuum.vacuum_clean_segment
- data:
- segments:
- - 3
- - 4
- - 5
- - 7
- - 6
- target:
- entity_id: vacuum.xiaomi_x10
- - alias: "拖地"
- conditions:
- - condition: state
- entity_id: select.xiaomi_x10_cleaning_mode
- state: 'mopping'
- sequence:
- - service: dreame_vacuum.vacuum_clean_segment
- data:
- segments:
- - 4
- - 3
- - 5
- - 7
- - 6
- target:
- entity_id: vacuum.xiaomi_x10
- vacuum_area_all:
- alias: "區域清掃-全區"
- sequence:
- - choose:
- - alias: "掃地"
- conditions:
- - condition: state
- entity_id: select.xiaomi_x10_cleaning_mode
- state: 'sweeping'
- sequence:
- - service: dreame_vacuum.vacuum_clean_segment
- data:
- segments:
- - 2
- - 1
- - 3
- - 4
- - 5
- - 7
- - 6
- target:
- entity_id: vacuum.xiaomi_x10
- - alias: "拖地"
- conditions:
- - condition: state
- entity_id: select.xiaomi_x10_cleaning_mode
- state: 'mopping'
- sequence:
- - service: dreame_vacuum.vacuum_clean_segment
- data:
- segments:
- - 4
- - 2
- - 1
- - 3
- - 5
- - 7
- - 6
- target:
- entity_id: vacuum.xiaomi_x10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement