Condition: Brightness of the lamp is above/below X value

I hate it when the brightness is turned up to maximum in the middle of the night. Could it be possible to add a condition: brightness of the lamp is above (or below) X. This would allow me to create the automation I want.

I currently use a motion sensor to activate what I want, but I would have to buy more, and they are quite expensive. Adding this condition would save me a lot.