Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alias: Auto Office Lights
- description: ""
- trigger:
- - platform: state
- id: light_off_to_on
- entity_id:
- - light.office_lights
- from: "off"
- to: "on"
- - platform: state
- id: light_on_to_off
- entity_id:
- - light.office_lights
- from: "on"
- to: "off"
- - platform: state
- entity_id:
- - binary_sensor.office_motion_detector_motion
- from: "off"
- to: "on"
- id: motion_detected
- - platform: state
- entity_id:
- - binary_sensor.office_motion_detector_motion
- from: "on"
- to: "off"
- id: motion_cleared
- - platform: event
- event_type: timer.finished
- event_data:
- entity_id: timer.automation_auto_office_lights
- id: timer_finished
- - platform: state
- entity_id:
- - input_boolean.automation_auto_office_lights
- id: toggle_automation_off_to_on
- from: "off"
- to: "on"
- - platform: state
- entity_id:
- - input_boolean.automation_auto_office_lights
- from: "on"
- to: "off"
- id: toggle_automation_on_to_off
- condition:
- - alias: Automation enabled or just recently turned off
- condition: or
- conditions:
- - condition: state
- entity_id: input_boolean.automation_auto_office_lights
- state: "on"
- - condition: template
- value_template: |-
- {{ is_state('input_boolean.automation_auto_office_lights', 'off') and
- (now() - states.input_boolean.automation_auto_office_lights.last_changed).total_seconds() < 10 }}
- action:
- - alias: Choose between the 6 triggers
- choose:
- - conditions:
- - condition: trigger
- id:
- - light_off_to_on
- sequence:
- - service: timer.start
- data:
- duration: >-
- {{
- states.input_number.automation_auto_office_lights_duration.state
- | int(0)*60 }}
- target:
- entity_id: timer.automation_auto_office_lights
- - conditions:
- - condition: trigger
- id:
- - light_on_to_off
- sequence:
- - service: timer.cancel
- data: {}
- target:
- entity_id: timer.automation_auto_office_lights
- - conditions:
- - condition: trigger
- id:
- - motion_detected
- sequence:
- - if:
- - condition: state
- entity_id: light.office_lights
- state: "off"
- then:
- - service: light.turn_on
- data: {}
- target:
- entity_id: light.office_lights
- alias: Are the lights on or off?
- - if:
- - condition: state
- entity_id: timer.automation_auto_office_lights
- state: active
- then:
- - service: timer.cancel
- data: {}
- target:
- entity_id: timer.automation_auto_office_lights
- alias: Is the timer already running?
- - conditions:
- - condition: trigger
- id:
- - motion_cleared
- sequence:
- - if:
- - condition: state
- entity_id: light.office_lights
- state: "on"
- then:
- - service: timer.start
- data:
- duration: >
- {{
- states.input_number.automation_auto_office_lights_duration.state
- | int(0)*60 }}
- target:
- entity_id: timer.automation_auto_office_lights
- - conditions:
- - condition: trigger
- id:
- - timer_finished
- sequence:
- - service: light.turn_off
- data: {}
- target:
- entity_id: light.office_lights
- - conditions:
- - condition: trigger
- id:
- - toggle_automation_off_to_on
- - condition: state
- entity_id: light.office_lights
- state: "on"
- sequence:
- - if:
- - condition: state
- entity_id: light.office_lights
- state: "on"
- then:
- - service: timer.start
- data: {}
- target:
- entity_id: timer.automation_auto_office_lights
- - conditions:
- - condition: trigger
- id:
- - toggle_automation_on_to_off
- - condition: state
- entity_id: light.office_lights
- state: "on"
- sequence:
- - service: timer.cancel
- data: {}
- target:
- entity_id: timer.automation_auto_office_lights
- mode: single
Advertisement
Add Comment
Please, Sign In to add comment