Skip to content

Instantly share code, notes, and snippets.

@xangin
Last active August 26, 2021 06:47
Show Gist options
  • Save xangin/8199ea535c213f0882bbe198efaa1ae1 to your computer and use it in GitHub Desktop.
Save xangin/8199ea535c213f0882bbe198efaa1ae1 to your computer and use it in GitHub Desktop.
- id: smart_light_offline_autorestart
alias: "燈斷線超過時間自動重開"
description: "當智慧燈具斷線超過設定的時間,將自動重新開關一次牆壁開關,並透過Line發送通知執行結果"
initial_state: true
trigger:
- platform: state
entity_id:
- light.room
to: 'unavailable'
for:
minutes: 5
action:
- service: notify.line_notify
data:
message: "燈已斷線!正進行重開..."
- service: switch.turn_off
entity_id: switch.room_light_switch_switch
- delay:
seconds: 20
- service: switch.turn_on
entity_id: switch.room_light_switch_switch
- wait_template: "{{ is_state('light.room', 'off') or is_state('light.room', 'on') }}"
timeout: "00:05:00"
- choose:
- conditions: "{{ wait.completed }}"
sequence:
- service: notify.line_notify
data:
message: "燈已自動重新開關!"
- conditions: "{{ not wait.completed }}"
sequence:
- service: notify.line_notify
data:
message: "燈重新開關無效!"
default:
- service: notify.line_notify
data:
message: "燈發生未知錯誤!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment