I have a motion detector set to trigger the “turn lights on” scene when motion is detected and light level is lower than 10% (luup code). The lights then stay on until I manually turn them off when I go to bed. This is OK, as I wanted. The problem is if I go to the toilet at night, the lights turn on and then I have to manually turn them off (or they will be on all night).
How do I modify the scene to turn the lights off automatically after 5 minutes but only during the night (between 00:00 and 06:00)?
What version of the UI are you running? If you are running UI5, you can edit the scene that you want to add a time. To the right of the scene name in the editor mode, you will see a drop down menu with the words immediate. Click on the drop down menu and click on manage delays. There you can enter 5 minutes. Once you enter the 5 minutes and click close, you can then select the light that you want to turn off. Once done, just click on the confirm changes button and then the save button.
I am using UI5, yes. I know about this feature you mentioned… but if I do that, then the lights will alway go off after 5 minutes which is not what I want.
I want the lights to go off after 5 minutes only during the night (from 00:00 to 06:00)… otherwise the lights should stay on “forever” / until I turn them of manually.
I was looking into “schedules” but there is no way to specify this option that I want. I think there should be some kind of a luup code that checks the time when sensor is tripped and if the time is in this interval (00:00 - 06:00) the timer is set to 5 minutes and then the “lights off” scene is triggered. This is my logical thinking, but unfortunately I don’t know how to program this
I also would like to know what time period “is.night” defines?
Because now there is another issue: every time a light is turned on, the scene switches it off after 5 minutes (the way i set it). Even if I turn on the light myself. So, if this is happening before 00:00 it is not OK… how can I tell Vera that is.night is actually after 00:00?
Basically you want to convert the current time and the time that you want to seconds and compare from there.
Garrett
I made this a long time ago and not sure if it works or not. But another way of doing it. You give it a start time and an end time. This will work for you as your start time is before midnight and the end time is after midnight.
local startTime = "10:30"
local endTime = "22:00"
local startHour = tonumber( startTime:sub( startTime:find("%d+") ) )
local startMinute = tonumber(startTime:sub(-2))
if startHour and startMinute then
startTime = startHour * 100 + startMinute
else
luup.log("ERROR: invalid start time")
return false
end
endHour = tonumber( endTime:sub( endTime:find("%d+") ) )
endMinute = tonumber(endTime:sub(-2))
if endHour and endMinute then
endTime = endHour * 100 + endMinute
else
luup.log("ERROR: invalid end time")
return false
end
local currentTime = os.date("*t")
currentTime = currentTime.hour * 100 + currentTime.min
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
-- YOUR CODE HERE --
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
-- YOUR CODE HERE --
return true
end
end
return false
Best Home Automation shopping experience. Shop at Ezlo!