Different coloured lights on different days

Hello,

I have some Hue lights and use an automation to have different coloured lights if its day or night. I would like to have a different coloured light during the day for each week day so something like

if between 06:00 and 00:10
and day = Mon
colour = yellow
or = day = Tue
colour = red

ect…

I’m hoping there is a way of using the if statement and Time condition in the automations but I’m not sure how to do it.

my current automation is:

- id: '001'
  alias: Hall Lights On Day
  description: ''
  trigger:
  - entity_id: binary_sensor.hue_motion_sensor_1_motion
    platform: state
    to: 'on'
  condition:
  - below: '100'
    condition: numeric_state
    entity_id: sensor.hue_motion_sensor_1_light_level
  - condition: and
    conditions:
    - after: 06:00
      before: 00:00
      condition: time
  action:
  - alias: ''
    data:
      brightness: 200
      rgb_color:
      - 255
      - 240
      - 240
    entity_id: light.hall_upstairs_3
    service: light.turn_on
  - data:
      brightness: 200
      rgb_color:
      - 255
      - 240
      - 240
    entity_id: light.hall_downstairs_3
    service: light.turn_on

What’s the purpose of having the exact same action twice?

One is for the upstairs light the other is downstairs :slight_smile:

- id: '001'
  alias: Hall Lights On Day
  trigger:
    platform: state
    entity_id: binary_sensor.hue_motion_sensor_1_motion
    to: 'on'
  condition:
    - condition: numeric_state
      entity_id: sensor.hue_motion_sensor_1_light_level
      below: 100
    - condition: time
      after: '06:00:00' 
      before: '00:00:00' 
  action:
    service: light.turn_on
    data_template:
      entity_id:
        - light.hall_downstairs_3
        - light.hall_upstairs_3
      brightness: 200
      color_name: >
        {% set day = now().weekday() %}
        {% if day == 0 %} yellow 
        {% elif day == 1 %} red
        {% elif day == 2 %} blue
        {% elif day == 3 %} green 
        {% elif day == 4 %} orange
        {% else %} purple {% endif %} 
2 Likes

Hi Sorry for the delay in reply, Thank you for this it works great and a much cleaner way from what I had before

:smiley:

1 Like

No worries, glad you’re sorted :+1: