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
geritz81 0
Hi all,
I am trying to learn the LUA scripting bit by bit based on what I can find online and by understanding the transformed code from building block into lua.
I am setting up my scenes in small bits and try to make it bigger when it works.
I have created a scene which is switching of 3 lights when the lux sensor is lower than 100 lux. This should only be active during daytime (8.00 and 23.00)
At 23.01 I have another scene active to switch all lights off.
Please login or register to see this code.
--[[
%% properties
38 value
%% globals
--]]
local sourceTrigger = fibaro:getSourceTrigger();
function tempFunc()
local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();
if (
( tonumber(fibaro:getValue(38, "value")) > 100 and (tonumber(os.date("%H%M")) >= tonumber(string.format("%02d%02d", "08", "00")) and tonumber(os.date("%H%M")) <= tonumber(string.format("%02d%02d", "23", "00"))) and (math.floor(os.time()/60)-math.floor(1441087200/60))%60 == 0 )
)
then
fibaro:call(20, "turnOff");
fibaro:call(28, "turnOff");
fibaro:call(16, "turnOff");
end
setTimeout(tempFunc, 60*1000)
end
if (sourceTrigger["type"] == "autostart") then
tempFunc()
else
local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();
if (
( tonumber(fibaro:getValue(38, "value")) > 100 and (tonumber(os.date("%H%M")) >= tonumber(string.format("%02d%02d", "08", "00")) and tonumber(os.date("%H%M")) <= tonumber(string.format("%02d%02d", "23", "00"))) )
or
startSource["type"] == "other"
)
then
fibaro:call(20, "turnOff");
fibaro:call(28, "turnOff");
fibaro:call(16, "turnOff");
end
end
What I am trying to understand is why the code is repeated twice. After the first 3 turnoff commands there is an additional block of code after
setTimeout(tempFunc, 60*1000)... can somebody tell me what it is for ? If I remove the code it does not work
Please login or register to see this image.
/emoticons/default_icon_smile.gif" alt=":-)" />1 answer 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.