Switch off lights after X minutes of no motion

I have installed an Aeotec multi sensor and would like to switch off my lights after 23h30 after e.g. 30 minutes without any motion. But as soon as there’s motion, it should reset the 30 minutes and start counting from zero.
My idea is this:
I guess I can use the Better Logic app for that, so I will have one flow to increase a number variable when there’s motion when the time is 23.30 or later. And if not, it decreases the number variable.

And another flow that, when the time is 23.30, starts checking the value of this variable every 5 minutes or so. If the motion value hasnt surpassed a predefined value, it switches off the lights.

It feels a bit complicated to do it like this.
What do you think. Could I make it more simple or is this the way to go?

I think the most simple method is to use zone activity. Basic function in Homey without any app.


I do this with the Chronograph app. A 30 minute timer can be created there. As soon as another movement triggers the timer again, it starts counting again.


Do you know what zone activity really is?
For example, it uses motion sensors and cameras attached to homey to see if there is any activity. But when a motion sensor sees activity in a zone, for how long will “zone activity” say that this zone is active?

In other words: how long will the zone activity stay ‘valid’?

As long as a motion alarm or contact alarm is active, the zone will be and stay active, there is no timeout for this, this includes alarms that are in a sub zone (zone inside the zone that is active) of that zone that is active.

Okay thanks! So what would you suggest if I want to keep my lights on during zone activity and a delay of eg 20 minutes after zone activity turned off?

Use the “zone has been inactive for…” card, not sure 20 minutes is an option though.

Thanks. But where do you find that card? I only see ‘zone is active’ or ‘zone is inactive’. (in the ‘AND’ column).
update: AH, i now see these cards in the WHEN column.