Switch on the light when door trigger is activated with luup.is_night

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

Any suggestions? Thanks chris

luup.sunset is not available in the current version of UI5 1.5.346. It was just recently added to a private beta.

  • Garrett

See also the prior topic (and firmware requirement on the wiki page).

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 ::slight_smile:

Sadly you will just have to sit tight and wait it out a little longer. Hopefully soon, but no dates can be given.

  • Garrett

chris66,

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.

Great tip futzle!

  • Garrett

Thanks futzle, I will try this.

chris

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.

Don’t sell yourself short. That’s a very good way to solve the problem.

Thanks all. @Video321, I think it’s elegant enough for me :wink: a nice day! chris