Advertisement
Einstine1984

Untitled

Dec 9th, 2021
1,296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.95 KB | None | 0 0
  1. alias: Bathroom Lights
  2. description: ''
  3. trigger:
  4.   - platform: template
  5.     value_template: >-
  6.       {{ states.binary_sensor.bathroom_motion_1.state == 'on' or
  7.       states.binary_sensor.bathroom_motion_2.state == 'on' }}
  8.     id: Occupied
  9.   - platform: template
  10.     value_template: >-
  11.       {{ states.binary_sensor.bathroom_motion_1_occupancy.state == 'off' and
  12.       states.binary_sensor.bathroom_motion_2_occupancy.state == 'off' }}
  13.     id: Unoccupied
  14.   - type: opened
  15.     platform: device
  16.     device_id: cf384d7c10de3db58ce79ae585476390
  17.     entity_id: binary_sensor.bathroom_door
  18.     domain: binary_sensor
  19.     id: Door Opened
  20.   - type: not_opened
  21.     platform: device
  22.     device_id: cf384d7c10de3db58ce79ae585476390
  23.     entity_id: binary_sensor.bathroom_door
  24.     domain: binary_sensor
  25.     id: Door Closed
  26. condition: []
  27. action:
  28.   - choose:
  29.       - conditions:
  30.           - condition: trigger
  31.             id: Occupied
  32.         sequence:
  33.           - service: switch.turn_on
  34.             target:
  35.               area_id: bathroom
  36.       - conditions:
  37.           - condition: trigger
  38.             id: Door Opened
  39.         sequence:
  40.           - service: switch.turn_on
  41.             target:
  42.               area_id: bathroom
  43.       - conditions:
  44.           - condition: trigger
  45.             id: Unoccupied
  46.         sequence:
  47.           - service: switch.turn_off
  48.             target:
  49.               area_id: bathroom
  50.       - conditions:
  51.           - condition: trigger
  52.             id: Door Closed
  53.         sequence:
  54.           - wait_for_trigger:
  55.               - platform: template
  56.                 value_template: >-
  57.                   {{ states.binary_sensor.bathroom_motion_1.state == 'off' and
  58.                   states.binary_sensor.bathroom_motion_2.state == 'off' }}
  59.             timeout: '00:02:00'
  60.             continue_on_timeout: false
  61.           - service: switch.turn_off
  62.             target:
  63.               area_id: bathroom
  64.     default: []
  65. mode: single
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement