Welcome to Smart Home Forum by FIBARO
Dear Guest,
as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.
As a member you can:
- Start new topics and reply to others
- Follow topics and users to get email updates
- Get your own profile page and make new friends
- Send personal messages
- ... and learn a lot about our system!
Regards,
Smart Home Forum by FIBARO Team

Question
Sjakie 156
Hi guys,
I am stucked can you please help me?
In below code the GV will stay on "Ochtendgloren"
Thanks in advanced for your help
--[[
%% autostart
%% properties
%% globals
--]]
local sourceTrigger = fibaro:getSourceTrigger();
if (sourceTrigger["type"] == "autostart") then
local debug = true;
-- check script instance count in memory
if (tonumber(fibaro:countScenes()) > 1) then
if debug then fibaro:debug("Script already running."); end
fibaro:abort();
end
if debug then fibaro:debug("HC2 start script at " .. os.date()); end
while true do
local ochtendgloren = os.date("%H:%M", os.time()+50*60)
local gordijnopen = os.date("%H:%M", os.time()+15*60)
local sunrise = fibaro:getValue(1, "sunriseHour")
local sunset = fibaro:getValue(1, "sunsetHour")
local gordijndicht =os.date("%H:%M", os.time()-50*60)
local avondrood = os.date("%H:%M", os.time()-50*60)
local currentTime = os.date("%H:%M");
local TimeOfDay = fibaro:getGlobal("TijdStip");
--Sunrise
if ( ochtendgloren >= sunrise and currentTime < gordijnopen and TijdStip ~= "Ochtendgloren" )
then
fibaro:setGlobal("TijdStip", "Ochtendgloren");
if debug then fibaro:debug("Ochtendgloren"); end
if ( gordijnopen >= sunrise and currentTime < sunrise and TijdStip ~= "GordijnOpen" )
then
fibaro:setGlobal("TijdStip", "GordijnOpen");
if debug then fibaro:debug("GordijnOpen"); end
--sunset
elseif ( gordijndicht >= sunset and currentTime > sunset and TijdStip ~= "GordijnDicht" )
then
fibaro:setGlobal("TijdStip", "GordijnDicht");
if debug then fibaro:debug("GordijnDicht"); end
elseif ( avondrood >= sunset and currentTime > sunset and TijdStip ~= "Avondrood" )
then
fibaro:setGlobal("TijdStip", "Avondrood");
if debug then fibaro:debug("Avondrood"); end
end
fibaro:sleep(60*1000);
end
end
else
fibaro:debug("Script can only be run via autostart")
end
32 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.