Running scene only if the device is not already on.

I am attempting to setup a night light scenario. That itself is simple yet if the light is already on (you’re staying up late) then the night light scene runs, it then turn off the light.

Example: Nightlight runs based on motion and runs the light for 10 minutes then turns the light off. If you already had the light on the all you have done is turn off the light when you did not mean to. The proper logic is “run scene nightlight if the light is not already turned on”. I assume Luup code is required but I have not seen an example of this specifically.

any help appreciated. :slight_smile:

this is the thread you want:,18679.0.html

Specifically, this one calls out running or not running a scene depending on the state of a switch:,18679.msg141959.html#msg141959

I would suggest using PLEG, which allows complex logic including AND. Easier (to me) than learning LUA.

Or use ALTUI with workflows. Even easier.