if startTime <= endTime then
– Both the start time and the end time are in the same day:
– if the current time is in the given interval, run the scene.
if startTime <= currentTime and currentTime <= endTime then
return true
end
else
– The start time is before midnight, and the end time is after midnight:
– if the current time is not outside the given interval, run the scene.
if not (endTime < currentTime and currentTime < startTime) then
return true
end
end
This code will allow the actions you specified in the scene to commence if the current time is within the specified window; otherwise nothing is done. It needs a trigger to run.
(Example: allow a motion sensor to only turn on a light in a specified time frame. You’d create a scene, use the ‘tripped’ event from the motion sensor as the trigger, select the light you want to turn on, and put this code on the Luup tab.)
For UI4 See http://wiki.micasaverde.com/index.php/Timer.
The same logic should be applied to establish a scene and then scheduling the timer.
I would recommend still using two scene.