#If condition never triggers action

1 messages · Page 1 of 1 (latest)

livid steppe
#

I am trying to make an automation where depending on the current colour of the light, it changes the lights to a different colour. I have tried using an IF statement for this but the IF statement never triggers the action. Am I doing something wrong? I checked that the RGB values of the bulb in the state menu match that in the IF statement but it still doesn't trigger the action.

worthy ruin
#

I don't think that state will be correct, you probably have to drop to YAML to do this.

#

Can you paste the YAML version of that code?

half estuary
#

its got something to do with it expecting a properly formatted list, but instead its just getting 255, 174, 92 and (seemingly) just checking against 255 and returning false.

#

in a template you can surround with parenthesis it will work normally, doesnt seem to do that in a condition, templated or untemplated when surrounded with either parenthesis or brackets

worthy ruin
#

I got this to work with a template condition. Couldn't figure out any syntax to make a state condition work:

{{ state_attr('light.kitchen_lights', 'rgb_color') == (255, 64, 112) }}
half estuary
#

same here

worthy ruin
#

I guess it's because the attribute is a tuple, and there's no syntax to represent a tuple in yaml, so I guess that's why state condition doesn't seem to be possible

livid steppe
#

So is there any way I could get round it?

livid steppe
#

Like

#

If purple, set blue

#

If blue, set red

#

If red set green

#

If green set white

#

If white set blue

livid steppe
#

If that makes any sense

worthy ruin
#

It makes sense, and the information I've already given should help you do that.

livid steppe
half estuary
#

you need to use a template condition

#

then you can enter the template straight from the ui

#

the template you have looks right, just need to put it in a template condition

worthy ruin
#

(just don't include outer quotation marks in the UI)

livid steppe
#

Ok thank you, I have got it semi working, the only issue I have now is that it changes to a colour value a few off of what I tell it to?!!!

livid steppe
#

It sets it to 255, 214, 161?

#

Any idea why>

livid steppe
half estuary
#

so it will just set it to the closest allowed value

#

so the answer is to change the condition to match what the bulb will actually set

livid steppe
#

Ok thank you

covert field
#

There is a custom macro "Color Multi-Tool" available in HACS that has a macro to get the closest color name from RGB.

livid steppe