I have a HA calendar that I use to set my WLED presets (the next few weeks will be fall colors and then in December will shift to Christmas). This works great if I don’t have overlapping events. I want to have exceptions, for example in the middle of December I might want to change the preset to a football team’s colors on the day they play. The automation I have needs there to be only one event per day (which makes me have to change the Christmas event to not occur on football days).
Here is what I’m using now.
condition:
action:
- choose:
- conditions:
- condition: state
entity_id: calendar.lighting_holidays
attribute: message
state: Eagles
sequence: - service: notify.mobile_app_scott_iphone_15_pro
data:
message: Setting preset to Eagles - device_id: bf6453e078f4ac144042d859fbb5e40e
domain: select
entity_id: 0bccd4f724596189f104c05ba8be3110
type: select_option
option: Eagles
- condition: state
- conditions:
- condition: state
entity_id: calendar.lighting_holidays
attribute: message
state: Thanksgiving
sequence: - service: notify.mobile_app_scott_iphone_15_pro
data:
message: Setting to Thanksgiving - device_id: bf6453e078f4ac144042d859fbb5e40e
domain: select
entity_id: 0bccd4f724596189f104c05ba8be3110
type: select_option
option: Thanksgiving
- condition: state
- conditions:
This is doing exactly what the state says. State only shows “Thanksgiving”. But if I call the service “List events” against that entity, I get two events “Eagles” and “Thanksgiving”.
So…I tried to call “List events” and store the response in a variable and then act conditionally on the response, but I can’t get it to work. Maybe I’m just not referencing the sections of the variable correctly. Here is the response from “List events” and the automation I have.
events:
- start: “2023-11-14”
end: “2023-11-17”
summary: Thanksgiving
description: “” - start: “2023-11-15”
end: “2023-11-16”
summary: Eagles
description: “”
action:
- service: calendar.list_events
data:
duration:
hours: 24
minutes: 0
seconds: 0
target:
entity_id: calendar.lighting_holidays
response_variable: calendar_events - choose:
- conditions:
- condition: template
value_template: “{{ calendar_events.events.summary == ‘Eagles’ }}”
sequence: - service: notify.mobile_app_scott_iphone_15_pro
data:
message: Set to Eagles
- condition: template
- conditions:
- condition: template
value_template: “{{ calendar_events.events.summary == ‘Thanksgiving’ }}”
sequence: - service: notify.mobile_app_scott_iphone_15_pro
data:
message: Set to Thanksgiving
- condition: template
- conditions:
My thinking was that if there are multiple entries, I could order the condition options to select the less frequently used presets first. For example…I see Christmas would be set for most of the month of December with a few days of a football team. I don’t think I need to account for two different special case settings on the same day.
Important stuff, I know. But thanks for any input.