Some quick feedback:
- condition: or
conditions:
- condition: time
after: '07:35:00'
- condition: time
before: '08:35:00'
I assume you want this to allow the actions to run only between 7:35 and 8:35. If so, you can do that like this:
- condition: time
after: '07:35:00'
before: '08:35:00'
(FWIW, the way you had it it would be true after 7:35 or before 8:35, which would be true all day. )
And this:
- service: light.turn_on
data_template:
entity_id: light.alcove_light
brightness_pct: 100
color_name: >
{% if is_state("sensor.me_traffic_density_to_work", "Normal") %} {"color_name": "green"}}
{%-elif is_state("sensor.me_traffic_density_to_work", "Moderate") %} {"color_name": "orange"}}
{%-elif is_state("sensor.me_traffic_density_to_work", "Heavy") %} {"color_name": "red"}}
{%-elif is_state("sensor.me_traffic_density_to_work", "unknown") %} {"color_name": {"white}}
{% endif %}
You make the same mistake a lot of people seem to make. When you’re using a template for a parameter, never use an if without an else. In this (and a lot of cases I see) the last elif is useless - just make it an else. Or, add an else with an appropriate value/statement.
But this can probably be “simplified” anyway like this:
- service: light.turn_on
data_template:
entity_id: light.alcove_light
brightness_pct: 100
color_name: >
{{ {'Normal': 'green', 'Moderate': 'orange',
'Heavy': 'red', 'unknown': 'white'
}[states('sensor.me_traffic_density_to_work')] }}
Or if you want to be more robust:
- service: light.turn_on
data_template:
entity_id: light.alcove_light
brightness_pct: 100
color_name: >
{% set map = {'Normal': 'green', 'Moderate': 'orange', 'Heavy': 'red'} %}
{% set state = states('sensor.me_traffic_density_to_work') %}
{{ map[state] if state in map else 'white' }}
Ok, this might not be that much simpler, but it’s certainly easier to extend by just changing the map/dictionary.