Setting Colours in Automations

Hi all, I have a basic automation to turn my bed lights on @ sunset and off @ sunrise.

I’d like to expand on them a little but cannot find any reference to setting colours from within the YAML code nor the Visual Editor. I’d like to see the evening light be red & the morning light be blue.

alias: Bed Light ON Sun SET  Red
description: ''
trigger:
  - platform: sun
    event: sunset
    offset: '5'
condition: []
action:
  - type: turn_on
    device_id: 2568a50ed9536883605056aacb511d85
    entity_id: light.bedroom_light
    domain: light
    brightness_pct: 5

mode: single

If anyone can assist, I’d be extremely grateful :slight_smile:

Use the light.turn_on service. All of the available options you can set are listed here:

https://www.home-assistant.io/integrations/light/#service-lightturn_on

There are examples below that as well.

Thank you, I had tried the rgb_colour: [255,0,0] but it keeps spewing this error up…

Message malformed: extra keys not allowed @ data[‘rgb_color’]

… whenever I add that line (or similar ones found on the link you’ve supplied).

action:
  - type: turn_on
    device_id: 2568a50ed9536883605056aacb511d85
    entity_id: light.bedroom_light
    domain: light
    brightness_pct: 5
    rgb_color: [255,0,0]
mode: single

As far as I can tell, this should work just fine here, but it just won’t.

Because you are not using

You are attempting to use the device action, which may not support that option (IDK I never use device actions, they’re awful).

Look at the examples in the link I posted.

Thank you!

Apologies for having made you repeat yourself… I’d somehow skipped the initial suggestion to use the light.turn_on service… and instead went straight to the link…

Anyway, although not directly able to test/run at this time (due to SunSet having long gone) I have now a working instance, apparently, at least.

alias: Bed Light ON Sun SET  Red
description: ''
trigger:
  - platform: sun
    event: sunset
    offset: '5'
condition: []
action:
  - service: light.turn_on
#   device_id: 2568a50ed9536883605056aacb511d85
    target:
      entity_id: light.bedroom_light
    data:
      brightness: 5
      rgb_color: [255,0,0]
mode: single

You can trigger the automation manually to test the action.

https://www.home-assistant.io/docs/automation/troubleshooting/#testing-your-automation