I use this function to activate a light on a door trigger:
if (luup.is_night()) then
return true
else
return false
end
It’s ok, but I would like to swich the light on 30 minutes before luup.is_night is true. What’s the procedure?
I tried someting like that but no success:
local TimeSunset = luup.sunset()
local TimeNow = os.time()
local SecBefSunset = tonumber(TimeSunset) - tonumber(TimeNow)
if SecBefSunset < 1800 then -- 30 minutes
return true
else
return false
end
wow, thanks, but how to get the firmware 1.5.353?? Doing some incantations to MCV? ;D Or maybe when I’ll be back from holidays there will be an 1.5.4 with fuzzy logic code fully implemented :
If you need something right now, you can approximate this with the Heliotrope plugin. 30 minutes before sunset corresponds to a sun altitude of about 7 degrees, depending on your latitude. If you alter your trigger to check (Altitude < 7 and Azimuth < 0) or (Altitude < 0) then you’ve got boolean truth from 30 minutes before sunset all night until sunrise.
Maybe not elegant, but being the noob I am I created a virtual switch to turn on 1 hour before sunset and off 1 hour after sunrise to be checked for status just for scenes like this.