Hooks to observe or modify state changes

Have you considered adding some mechanism that would allow the configuration of hooks that can transform or even veto state changes?

Example of a use case: I have two children, and a couple of times at night I missed the switch for my bedroom lights and instead of turning them off, I turned the kids’ bedroom on. Oops.
I would love to be able to configure a “master switch” that prevents their lights from turning on between 8pm and 7am; regardless of whether the transition comes from the UI, automation or what have you.

I realize I can probably hack this in a few ways, but a clean API would be so much better.