Exemple de code lua
Noter dans une variable le coucher du soleil avec 45′ de décalage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| --[[
%% autostart
%% properties
%% globals
--]]
while true do
local sunUp = os.date("%H:%M", os.time()-45*60) --Off 45min after sunrise
local sunDown = os.date("%H:%M", os.time()+45*60) --On 45min before sunset
local currentDate = os.date("*t");
if ( sunUp == fibaro:getValue(1, "sunriseHour") )
then
fibaro:setGlobal("NightTime", "0");
elseif ( sunDown == fibaro:getValue(1, "sunsetHour") )
then
fibaro:setGlobal("NightTime", "1");
end
fibaro:sleep(60*1000);
end |
--[[
%% autostart
%% properties
%% globals
--]] while true do
local sunUp = os.date("%H:%M", os.time()-45*60) --Off 45min after sunrise
local sunDown = os.date("%H:%M", os.time()+45*60) --On 45min before sunset
local currentDate = os.date("*t"); if ( sunUp == fibaro:getValue(1, "sunriseHour") )
then
fibaro:setGlobal("NightTime", "0");
elseif ( sunDown == fibaro:getValue(1, "sunsetHour") )
then
fibaro:setGlobal("NightTime", "1");
end fibaro:sleep(60*1000);
end