Light control

hi guys.

Can someone tell me why this code wont work?

  • alias: deactivate lamp at 06.30, if the color is blue
    trigger:
    - platform: time
    at: ‘06:30:00’
    condition:
    - condition: state
    entity_id: light.kokken_bord_lampe_hojre
    state: ‘on’
    attribute: rgb_color
    value: [0, 0, 255]
    action:
    - service: light.turn_off
    entity_id: light.light.kokken_bord_lampe_hojre

Welcome to the HA community. Can you please correctly format your code as per:

Thank you!

Hi. do you need it to turn off if the light is on and the color is red?

hi. yes, but if the color is blue

Use the developer tools > states to check if your light really is blue. Also, what does the trace for the automation say ?

Hi Rofo.
I can see that the color not is 100% blue. it is [11, 0, 255] . I have change the color in the script, but still nothing happens.
I cant see any fault in the automation log

Now it works.

alias: deactivate lampe at 06.30, if the color is blue

description: ‘’

trigger:

  • platform: time

    at: ‘06:30:00’

condition:

  • condition: state

    entity_id: light.kokken_bord_lampe_hojre

    state: ‘on’

  • condition: template

    value_template: ‘{{ state_attr(’‘light.kokken_bord_lampe_hojre’’, ‘‘rgb_color’’)

    [2] == 255 }}’

action:

  • service: light.turn_off

    entity_id: light.kokken_bord_lampe_hojre

mode: single

Thats one way of doing it. But thats not really the solution. You are just checking if the RGB Blue component is set to 255, and ignoring the rest, which means white (for example, which is 255,255,255 would also trigger it.

Infact any colour that also uses the full blue channel will trigger it.

If you checked the automation trace history it would have told you why the original failed to fire. I suspect its still something to do with how you set the colour.

FYI, you can set the colour to exact values (not using the colour wheel) by using the pencil icon next to the colour wheel.