Skip to content

Instantly share code, notes, and snippets.

@Evshved
Last active April 12, 2016 23:06
Show Gist options
  • Select an option

  • Save Evshved/c51d8ab14dd68395cc0d9918c83d448d to your computer and use it in GitHub Desktop.

Select an option

Save Evshved/c51d8ab14dd68395cc0d9918c83d448d to your computer and use it in GitHub Desktop.
--[[
%% autostart
%% properties
%% globals
--]]
while true do
local IdDeviceOfLamp = 1;
local currentDate = os.date("*t");
local sunriseHour = fibaro:getValue(1, 'sunriseHour');
local sunsetHour = fibaro:getValue(1, 'sunsetHour');
local currentSec = tonumber(currentDate.hour) * 60 + tonumber(currentDate.min);
local sunriseSec = tonumber(string.sub(sunriseHour, 1, 2)) * 60 + tonumber(string.sub(sunriseHour, 4));
local sunsetSec = tonumber(string.sub(sunsetHour, 1, 2)) * 60 + tonumber(string.sub(sunsetHour, 4));
if (currentSec>sunriseSec and currentSec<sunsetSec) then
fibaro:call(IdDeviceOfLamp, 'turnOn')
else
fibaro:setGlobal(IdDeviceOfLamp, 'turnOff');
end
fibaro:sleep(60000*10);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment