Non-YAML Motion Light Over Ride Help

Hi All,

I am trying to create a motion light automation that when you come into the room, it turns on (to 95%) and off automatically. The reason for the 95% is that I want to use that as a test condition to turn off the light.

So the turn off condition would only work if the motion stopped and the percentage was set to 95%.

I tried using the state function to validate 95% but then the automation dies. What am I not doing right?

The brightness attribute is not a percentage, it’s an integer between 0 and 255 for how bright the light should be, where 0 means the light is off, 1 is the minimum brightness and 255 is the maximum brightness supported by the light.

Oh dear. That makes a lot of sense. How would I go figuring out what that number should be? .95 x 255 = 242.25, rounded down to 242?

Yes, it should be 242.

Thank you! I’ll test it today and report back.

Bummer. Didn’t work out. Is there a better way?

You can check the attribute in developer tools for the right value, it might be different for your light. Also check the automation trace, it too will show why the automation did not execute the way you needed.

I’m going to need to plead dumb on this one. The internet is full of noise and this why I came to dig around in the forums.

I can read though. :smiling_face:

I have a Lutron Caseta switch. Where might I find the documentation for those?

Best.

I feel like I’m still missing something. I did the trace and this is what I got.

Ahh, I think you might be hurt by the automation editor putting quotes around everything. Fine for states, those are always string, not for attributes, those can have any type. In this case int. You could try to remove the quotes in the yaml, but the automtion editor will keep putting them back.

Try this as a template condition instead of a state condition:

{{ state_attr('light.living_roommotion_lights') | int(0) == 229 }}

Check the entity name and change it to yours, I cannot see what it is from your screenshots.

It is fascinating. I did remove the “x” (parentheses) and…it works. But it is -1 of what the set point is for some reason. Not sure why. Thanks for your help.

Because the real light will likely not support the set brightness exactly, the light will pick something close and return that as the brightness. And/or there will be rounding errors with the brightness the light returns.