How to add light brightness as a condition in visual editor

I have an automation that sets the living room lights to a “medium” brightness when motion is detected. This works reliably.

The problem is that if someone uses a smart switch, dashboard, or voice to set the lights to 100% brightness, the light turn bright until motion is detected and then they are set by the automation to “medium”.

I’d like to place the “fix” into the motion detection automation. I tried to add a condition to the automation that said “and is less than 50” but got an error saying the state “on” can not be compared to a number. Appearenlty the light has only on/off state. How do I compare a light’s brightness to a constant 50.

I’d like to continue using the visual editor because I have at least some hope of teaching that to others.

Select Numeric State as condition, select the light entity and then brightness as attribute.

As above, but I have found the best solution to this practical problem is:

If the lights are on at all, by whatever mechanism, someone wants them that way. Having fiddled around with a lot of variants, the whole experience is a lot smoother when I ignore motion at all if lights are already on, however dimly.

I decided to go with the idea that if the lights are on, even dimly, then walking into a room should not change the lights.

This seemed good except for a corner case where this happens: The sensor clears and the automation is set to turn the lights off after 5 minutes of being clear. Then the transition period is set to some number of seconds. But another person walks in durring the transition and the lights don’t come back on. I can live with this odd case but a client who just paid $$$ expects perfection.

So I am back to thinking about what is best. Conclusion is to track WHY the lights are as they are rather than simply look at the current state. If a human wants the lights diim, they should stay dim but if an automation wants the lights dim then motion overrides. So we have a rank system with human operated control at the top, automations at the bottom and sensors between. Commands from the highest rank always win. Now I need to figure this out, how to do it, possibly with helpers.

I’m going for ther last bit of perfection because people are asking me to set this stuff up. People have very high exppectations for lighting to “just work”, even my corner case glitch is not good.

That doesn’t really happen if it is set up properly. The timer only starts when motion has been cleared for 5 minutes. Some sensors will have a very long recovery period before retriggering so you will need to know what that is and work with it.

This doesn’t deal with not doing an action when lights are already on but the overall explanation is good and see various other videos by this man