Advertisement
xangin

Door open notify

Mar 10th, 2022
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 0.93 KB | None | 0 0
  1. - id: main_bath_door_open_long_time_notify
  2.   alias: main_bath_door_open_long_time_notify
  3.   description: 門開太久發通知    
  4.   trigger:
  5.     - entity_id: binary_sensor.door_mainbath_contact
  6.       platform: state
  7.       to: 'on'    
  8.       for:
  9.         minutes: 10
  10.   condition: []      
  11.   mode: single
  12.   action:
  13.     - repeat:
  14.         while:
  15.           - condition: state
  16.             entity_id: binary_sensor.door_mainbath_contact
  17.             state: 'on'
  18.           # Don't do it too many times
  19.           - condition: template
  20.             value_template: "{{ repeat.index <= 10 }}"  
  21.         sequence:      
  22.           - service: notify.line_notify
  23.             data:
  24.               message: 門開,趕快關!
  25.           # Wait for sensor to change to 'off' up to 10 minutes before continuing to execute
  26.           - wait_template: "{{ is_state('binary_sensor.door_mainbath_contact', 'off') }}"
  27.             timeout: "00:10:00"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement