Last active
August 19, 2022 08:23
-
-
Save deskoh/eac6f6bd723226dc26d6910cc292c49e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Timer Switch (Lights) | |
description: Turn off switch after specified duration when lights are off. | |
domain: automation | |
input: | |
switch: | |
name: Switch | |
description: Switch entity | |
selector: | |
entity: | |
domain: switch | |
multiple: false | |
light: | |
name: Light | |
description: Light entity | |
selector: | |
entity: | |
domain: light | |
multiple: false | |
duration: | |
name: Duration | |
description: If lights are off, duration to wait before turning off switch | |
default: | |
hours: 0 | |
minutes: 10 | |
seconds: 0 | |
selector: | |
duration: | |
duration_light: | |
name: Duration | |
description: If lights are on, duration to wait after light is off before turning off switch | |
default: | |
hours: 0 | |
minutes: 2 | |
seconds: 0 | |
selector: | |
duration: | |
mode: restart | |
max_exceeded: silent | |
trigger: | |
- platform: state | |
entity_id: !input 'switch' | |
to: 'on' | |
action: | |
- if: | |
- condition: state | |
entity_id: !input 'light' | |
state: 'on' | |
then: | |
- wait_for_trigger: | |
- platform: state | |
entity_id: !input 'light' | |
to: 'off' | |
continue_on_timeout: true | |
timeout: '00:20:00' | |
- wait_for_trigger: | |
- platform: state | |
entity_id: !input 'switch' | |
to: 'off' | |
continue_on_timeout: true | |
timeout: !input 'duration_light' | |
else: | |
- wait_for_trigger: | |
- platform: state | |
entity_id: !input 'switch' | |
to: 'off' | |
continue_on_timeout: true | |
timeout: !input 'duration' | |
- service: switch.turn_off | |
target: | |
entity_id: !input 'switch' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment