Manual override of motion sensor automation

I have a simple automation that when my motion sensor detects occupancy, my light switch turns on, then 2 minutes after its state clears it turns the light off.

I would like to create some sort of override so that if you manually turn on the light it will stay on for at least an hour (maybe end of day). No matter is that is using the z-wave switch, the HA panels, or triggering it via Alexa.

Right now if you override the setting at a switch, the motion clear state still turns off the light and starts the motion automation over.

(So far I think I am looking at setting an input_boolean helper, then just having automations that toggle it, and having the motion automation look at that boolean state in an if/then conditional… Though I am curious if there is a cleaner way.)

Thank you!

There are a lot of different ways to approach it, but you’re going to need to have some way to have HA “remember” whether the light was turned on by the motion sensor or not.

Here’s one way with an input_boolean: set it to “true” in the automation that turns the light on with motion. In the automation that turns the light off when motion ceases, only turn the light off if the Boolean is true. Create an automation that triggers with the state of the light going off, which sets the input_boolean off.

This way your automations turn the light off based on the motion sensor only if the light was actually turned on by the motion sensor.