I have been trying to piece this together form a couple of sources. The goal is to look at a calendar and if there is a specific holiday set 1 to 3 different sets of lights to a certain color 15 minutes before sunset. Otherwise set 2 sets of lights to a different random color.
When I go to save I get this error: Message malformed: extra keys not allowed @ data[‘automation’]
automation:
- alias: Outside lights
description: Sets lights to different colors on a holiday and randoms colors on non-holidays
trigger:
- event: sunset
offset: "-00:15:00"
trigger: sun
condition:
- condition: template
value_template: >-
{% set calendar1 = state_attr('calendar.holidays_in_united_states', 'all_day') %}
{% if calendar1 %}
{% for event in calendar1 %}
{% set holiday = event.summary %}
{% if holiday == 'New Year\u0027s Eve' or holiday == 'Valentine\u0027s Day' or holiday == 'Saint Patrick\u0027s Day' or holiday == 'Cinco de Mayo' or holiday == 'Memorial Day' or holiday == 'Juneteenth' or holiday == 'Independence Day' or holiday == 'Halloween' or holiday == 'Veterans Day' %}
{{ true }}
{% endif %}
{% endfor %}
{% else %}
{{ false }}
{% endif %}
action:
- choose:
- conditions:
- condition: template
value_template: >-
{{ state_attr('calendar.calendar1', 'all_day') |
selectattr('summary', 'eq', 'New Year\u0027s Eve') | list | count >
0 }}
sequence:
- service: light.turn_on
target:
entity_id: >-
light.entryway_wall_2, light.entryway_window_2,
light.walkway_entry_light, light.walkway_garage_light,
light.garage_far_2, light.garage_walkway_2
data:
color_name: gold
- conditions:
- condition: template
value_template: >-
{{ state_attr('calendar.calendar1', 'all_day') |
selectattr('summary', 'eq', 'Valentine\u0027s Day') | list | count
> 0 }}
sequence:
- service: light.turn_on
target:
entity_id: >-
light.entryway_wall_2, light.entryway_window_2,
light.garage_far_2, light.garage_walkway_2
data:
color_name: hotpink
- service: light.turn_on
target:
entity_id: light.walkway_entry_light, light.walkway_garage_light
data:
color_name: red
- conditions:
- condition: template
value_template: >-
{{ state_attr('calendar.calendar1', 'all_day') | selectattr('summary', 'eq', 'Saint Patrick\u0027s Day') | list | count > 0 }}
sequence:
- service: light.turn_on
target:
entity_id: >-
light.entryway_wall_2, light.entryway_window_2,
light.walkway_entry_light, light.walkway_garage_light,
light.garage_far_2, light.garage_walkway_2
data:
color_name: lawngreen
- conditions:
- condition: template
value_template: >-
{{ state_attr('calendar.calendar1', 'all_day') |
selectattr('summary', 'eq', 'Cinco de Mayo') | list | count >
0 }}
sequence:
- service: light.turn_on
target:
entity_id: >-
light.entryway_wall_2, light.entryway_window_2,
light.garage_far_2, light.garage_walkway_2
data:
color_name: green
- service: light.turn_on
target:
entity_id: light.walkway_entry_light, light.walkway_garage_light
data:
color_name: white
- service: light.turn_on
target:
entity_id: light.garage_far_2, light.garage_walkway_2
data:
color_name: red
- conditions:
- condition: template
value_template: >-
{{ state_attr('calendar.calendar1', 'all_day') |
selectattr('summary', 'eq', 'Memorial Day') | list | count > 0
or state_attr('calendar.calendar1', 'all_day') |
selectattr('summary', 'eq', 'Independence Day') | list | count
> 0 or state_attr('calendar.calendar1', 'all_day') |
selectattr('summary', 'eq', 'Veterans Day') | list | count > 0
}}
sequence:
- service: light.turn_on
target:
entity_id: >-
light.entryway_wall_2, light.entryway_window_2,
light.garage_far_2, light.garage_walkway_2
data:
color_name: red
- service: light.turn_on
target:
entity_id: light.walkway_entry_light, light.walkway_garage_light
data:
color_name: white
- service: light.turn_on
target:
entity_id: light.garage_far_2, light.garage_walkway_2
data:
color_name: mediumblue
- conditions:
- condition: template
value_template: >-
{{ state_attr('calendar.calendar1', 'all_day') |
selectattr('summary', 'eq', 'Juneteenth') | list | count > 0
}}
sequence:
- service: light.turn_on
target:
entity_id: >-
light.entryway_wall_2, light.entryway_window_2,
light.garage_far_2, light.garage_walkway_2
data:
color_name: firebrick
- service: light.turn_on
target:
entity_id: light.walkway_entry_light, light.walkway_garage_light
data:
color_name: orange
- service: light.turn_on
target:
entity_id: light.garage_far_2, light.garage_walkway_2
data:
color_name: darkgreen
- conditions:
- condition: template
value_template: >-
{{ state_attr('calendar.calendar1', 'all_day') | selectattr('summary', 'eq', 'Halloween') | list | count > 0 }}
sequence:
- service: light.turn_on
target:
entity_id: >-
light.entryway_wall_2, light.entryway_window_2,
light.garage_far_2, light.garage_walkway_2
data:
color_name: purple
- service: light.turn_on
target:
entity_id: light.walkway_entry_light, light.walkway_garage_light
data:
color_name: orange
default:
- service: light.turn_on
target:
entity_id: light.entryway_wall_2, light.entryway_window_2, light.garage_far_2, light.garage_walkway_2
data_template:
rgb_color: >-
[
{{ range(0, 255) | random }},
{{ range(0, 255) | random }},
{{ range(0, 255) | random }}
]
brightness_pct: 75
- service: light.turn_on
target:
entity_id: light.walkway_entry_light, light.walkway_garage_light
data_template:
rgb_color: >-
[
{{ range(0, 255) | random }},
{{ range(0, 255) | random }},
{{ range(0, 255) | random }}
]
brightness_pct: 75