Skip to content

Instantly share code, notes, and snippets.

@Didgeridrew
Last active March 24, 2021 19:26
Show Gist options
  • Save Didgeridrew/14b0731990c828343aff41bd7db3e4b4 to your computer and use it in GitHub Desktop.
Save Didgeridrew/14b0731990c828343aff41bd7db3e4b4 to your computer and use it in GitHub Desktop.
HA Automations: Example of using trigger templates as conditions in Choose actions
## Documentation for this function can be found at: https://www.home-assistant.io/docs/automation/templating/
alias: Master Bedroom Lights on at Night
description: 'Master Bedroom Lights on at Night'
trigger:
- platform: time
at: '20:00:00'
- platform: time
at: '21:45:00'
- platform: time
at: '22:00:00'
condition: []
action:
- choose:
- conditions:
- condition: template
value_template: '{{ ((trigger.now.time()| string)[:5]) == ''20:00'' }}'
sequence:
- domain: light
entity_id: light.leviton_unknown_type_1706_id_0334_level
device_id: 8f2eecb039ba09229a946987c58e944c
type: turn_on
brightness_pct: 100
- type: turn_on
device_id: 9e00ce7c4268ff2891c940e3ce863497
entity_id: light.leviton_unknown_type_1706_id_0334_level_2
domain: light
brightness_pct: 50
- conditions:
- condition: template
value_template: '{{ ((trigger.now.time()| string)[:5]) == ''21:45'' }}'
sequence:
- domain: light
entity_id: light.leviton_unknown_type_1706_id_0334_level
device_id: 8f2eecb039ba09229a946987c58e944c
type: turn_off
brightness_pct: 0
- conditions:
- condition: template
value_template: '{{ ((trigger.now.time()| string)[:5]) == ''22:00'' }}'
sequence:
- type: turn_off
device_id: 9e00ce7c4268ff2891c940e3ce863497
entity_id: light.leviton_unknown_type_1706_id_0334_level_2
domain: light
brightness_pct: 0
default: []
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment