Nightlight change color depending on traffic

Hi all, I’ve got an automation you’d might like. I have the limitlessled bridge on my night stand (but you can use any other controlable bulb), and programmed it so that it shows a color depending on the traffic to my work. If there are a lot of traffic jams it turns red (I have to hurry, or stay in bed and first work from home) if there are no traffic jams it is green. And it turns orange when there is a light delay. And all in two simple automations!

- id: bridge_off
  alias: 'Bridge off'
  trigger:
platform: time
at: '09:00:01'
  condition:
  action:
service: light.turn_off
entity_id: light.bridge

- id: traffic
  alias: 'traffic'
  trigger:
platform: state
entity_id: sensor.to_work
  condition:
condition: time
after: '06:30:00'
before: '09:00:00'
weekday:
  - mon
  - tue
  - wed
  - thu
  - fri
  action:
- service: light.turn_on
  data_template:
    entity_id: light.bridge
    brightness: 09
    transition: 2  
    color_name: >
      {% if states.sensor.to_work.state|int < 64 %}
      green
      {% elif states.sensor.to_work.state|int >= 64 and states.sensor.to_work.state|int <= 74 %}
      orange
      {% else %}
      red
      {% endif %}
5 Likes