Thank you @bangali for these examples.
I’ve just set this up, and read through the whole thread.
I have it working with my motion sensor and 1 light.
What I want to do, is to apply this to multiple lights.
If they’re all OFF, turn them all ON for X minutes. Then turn OFF. (Which I can do with the piston in the first post)
If they’re all ON, then effectively do nothing. (Which I can do with the piston in the first post)
If some are ON and some are OFF, then turn those that are OFF, ON for X minutes, and only turn OFF those that were previously OFF, leaving those that were previously ON, still ON.
Any help would be appreciated.