5 Star Service
The Fibaro Home Center 2 has a few limitations on the Sunset and Sunrise times you can use in your scenes. For instance you can select 15, 30, 45 and 60 minutes before sunrise and 15, 30, 45 and 60 minutes after sunset. But you can't select 60 minutes before sunset or any other values.
It is actually very easy to change a single line of LUA code to extend the Sunset/Sunrise times to any time you like.
As an example we will use the Sunset scene we used in Application Note 28 -
This scene turns on a light exactly at Sunset. This works well for outside lights, but if you used the same scene for an indoor light you would probably want it to be activated before sunset as it gets darker inside a building.
So lets change this so the scene is activated 1 hour before Sunset.
To do this we need to change one line of the LUA code that actually runs this scene.
( ((currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == fibaro:getValue(1, "sunsetHour")) )
( ((currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6) and os.date("%H:%M", os.time()+60*60) == fibaro:getValue(1, "sunsetHour")) )
To change the LUA code to use our new line of code (line 14) we need to turn on the LUA Editing mode.
Important - I would suggest you do this after you have the rest of the scene working correctly - you cannot go from the LUA based editor back to the Graphic Block editor.
When you are ready - change the editor to LUA based.
The scene will now run 60 minutes before sunset.
Using this simple code change we can have our scenes running before or after Sunset/Sunrise and at what ever time we like.