Not sure how I missed that. Thanks. I’ll continue to test.
So how would I store these template conditions in a dictionary?
Not sure how I missed that. Thanks. I’ll continue to test.
So how would I store these template conditions in a dictionary?
So I was able to get this working using the template condition in Choose actions (one for each holiday). As long as the message matches the calendar event, it returns true
. Thanks again @123 for pointing me in the right direction.
alias: Lighting - Holidays
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.holiday_lights_time
condition: []
action:
- choose:
- conditions:
- condition: template
value_template: >-
{{ is_state_attr('calendar.holiday_lights', 'message',
'Christmas') }}
sequence:
- service: light.turn_{{ trigger.to_state.state }}
target:
entity_id:
- light.house_wled
- light.front_porch_light
- light.front_yard_light
- service: select.select_option
target:
entity_id: select.house_wled_preset
data:
option: Chunchun
- conditions:
- condition: template
value_template: >-
{{ is_state_attr('calendar.holiday_lights', 'message',
'Valentines') }}
sequence:
- service: light.turn_{{ trigger.to_state.state }}
target:
entity_id:
- light.house_wled
- light.front_porch_light
- light.front_yard_light
mode: single
FWIW, this does exactly the same thing as your posted example.
alias: Lighting - Holidays
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.holiday_lights_time
condition:
- condition: template
value_template: >
{{ state_attr('calendar.holiday_lights', 'message') in ['Christmas', 'Valentines'] }}
action:
- service: light.turn_{{ trigger.to_state.state }}
target:
entity_id:
- light.house_wled
- light.front_porch_light
- light.front_yard_light
- condition: "{{ is_state_attr('calendar.holiday_lights', 'message', 'Christmas') }}"
- service: select.select_option
target:
entity_id: select.house_wled_preset
data:
option: Chunchun
mode: single
One thing to note, I’ll have different WLED preset based on the calendar event. I haven’t added them all yet.
That important detail wasn’t obvious from the example you posted.
If each holiday has a different combination of lights, it can be templated in the (single) service call. Any additional things done on a per holiday basis may still need a choose
. I’ll refrain from making more suggestions until I see the complete version of your automation.