Hi,
I have external lights. I use geolocation with ifttt. When I arrive near my house my lights turn on automatically. But it must light up when it is dark. At sunset.
I created one variable :
I created 3 scenes.
First scene :
--[[
%% autostart
%% properties
%% weather
%% events
%% globals
--]]
local sourceTrigger = fibaro:getSourceTrigger();
function tempFunc()
local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();
if (
( ((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == fibaro:getValue(1, "sunsetHour")) )
)
then
fibaro:setGlobal("ext", "1");
end
setTimeout(tempFunc, 60*1000)
end
if (sourceTrigger["type"] == "autostart") then
tempFunc()
else
local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();
if (
startSource["type"] == "other"
)
then
fibaro:setGlobal("ext", "1");
end
end
My first scene
Sets my variable to 1 when the sun goes down
My second scene sets my variable to 0 when the sun rises.
--[[
%% autostart
%% properties
%% weather
%% events
%% globals
--]]
local sourceTrigger = fibaro:getSourceTrigger();
function tempFunc()
local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();
if (
( ((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == fibaro:getValue(1, "sunriseHour")) )
)
then
fibaro:setGlobal("ext", "0");
end
setTimeout(tempFunc, 60*1000)
end
if (sourceTrigger["type"] == "autostart") then
tempFunc()
else
local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();
if (
startSource["type"] == "other"
)
then
fibaro:setGlobal("ext", "0");
end
end
And My third scene that executes the lighting of my lights when ext = 1 and that the sun goes down.
--[[
%% properties
%% weather
%% events
%% globals
ext
--]]
local startSource = fibaro:getSourceTrigger();
if (
( tonumber(fibaro:getGlobalValue("ext")) == tonumber("1") )
or
startSource["type"] == "other"
)
then
fibaro:call(32, "turnOn");
end
I have a problem, It makes day or night my scene of lighting my lights work all the time. I don't understand.
One idea ? if you can help me please.
Thx.