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.
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.
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:
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.