I have some code on a scene to turn off a light unless it is night time. I would like to modify it to allow the light to go on up to 1/2 hour before night. Can anyone make a suggestion for how to improve this. Note I am using UI4:
– Run the scene only at day
if ( luup.is_night() ) then
return false – exit without doing anything.
else
return true – run the scene
end
I should add that I would have preferred to have it work only between 30 minutes before sundown to 2:00 a.m. Any ideas?
You do not really need a Luup code to achieve this as it is embedded functionality.
Try creating one scene to setup trigger 30 minutes before sunset and another scene to turn off at 2am as per attachments.
I am not sure that will do what I am trying to achieve. What I want is the system to prevent the light from being turned on unless it is night time. The Luup code is doing that as it is written. But I would like it to allow lights to be turned on a bit earlier, like at dusk. And if possible to prevent it from being left on all night. This is a pool light and is difficult to see if it is on during the day.
If you use luup is night it is either true or false and you can not set another condition of 30 minutes before luup.is_night() and therefore, the solution maybe to use one of the pre-defined conditions. If you have an estimate between sunset and what you determine as night, I would use that. Have a look at the first trigger and there are various condition that can be select, At sunset, after sunset x minute etc, that may suit better.
I would recommend a second scene that has your predetermine time e.g. 2am to swtich and not embedded both condition in one scene. You could even set up multiple scenes to ensure it is off if your worried that one may not fire and turn off the lights. e.g. another at sunrise…
Thanks. I will try that out for a few days to see how it goes.