I created the scene in the following way: I have Aeon labs hidden door sensor on the front door. When the sensor is triggered (from sunset until 2359) it triggers the hallway light (controlled by a GE/JASCO wall switch) to come on. Then I set a delay to turn the hallway light off 5 minutes later. I entered the code contained below in the scene under the LUUP tab.
local minute = math.floor((ssTime % 3600) / 60)
local startTime = hour * 100 + minute
hour = tonumber( endTime:sub( endTime:find("%d+") ) )
minute = tonumber(endTime:sub(-2))
if hour and minute then
endTime = hour * 100 + minute
else
luup.log("ERROR: invalid end time")
return false
end
local currentTime = os.date("*t")
currentTime = currentTime.hour * 100 + currentTime.min
luup.log("startTime = " .. startTime .. "; currentTime = " .. currentTime .. "; endTime = " .. endTime)
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
return false