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
lukaszzyla 0
Hi!
I am a beginner in LUA and this is one of my first approaches.
I would like to have my roller shutters opened when move is detected and some other conditions are met.
Currently I get too many instances in my scene all the time and it does really what IT wants - usually opens all the rollers up whenever movement is detected and all conditions are met.
It doesnt wait between tries.
I would like this scene to be run every 5 minutes and not 30 seconds as it runs default.
Now, HC2 doesnt care about my fibaro:sleep - it just opens rollers constantly and after few minutes I get information about exceeded instances.
How to make this scene work every 5 minutes?
Do you know any other scene that does it written by someone with better LUA skills than mine?
It shouldn't be difficult
POZ_ROL are my rollers.
334,238 are my motion sensors
336 is LUX sensor
-[[
%% properties
336 value
157 value
159 value
161 value
181 value
%% weather
Temperature
%% events
%% globals
TimeofDay
--]]
local POZ_ROL5 = tonumber(fibaro:getValue(157,"value"))
local POZ_ROL6 = tonumber(fibaro:getValue(159,"value"))
local POZ_ROL7 = tonumber(fibaro:getValue(161,"value"))
local POZ_ROLK = tonumber(fibaro:getValue(181,"value"))
local LUX = tonumber(fibaro:getValue(336,"value"))
local startSource = fibaro:getSourceTrigger();
if (
-- (api.get('/weather')['WeatherCondition'] ~= "cloudy" and api.get('/weather')['WeatherCondition'] ~= "storm" )
-- and
(( fibaro:getGlobalValue("TimeofDay") == "Morning" or fibaro:getGlobalValue("TimeofDay") == "Afternoon" ))
and
(( tonumber(fibaro:getValue(157, "value")) < 99 or tonumber(fibaro:getValue(159, "value")) < 99 or tonumber(fibaro:getValue(161, "value")) < 99 or tonumber(fibaro:getValue(181, "value")) < 99 ))
and
( tonumber(api.get('/weather')['Temperature']) <= tonumber(20) )
and
( ( tonumber(fibaro:getValue(334, "value")) > 0 ) or ( tonumber(fibaro:getValue(238, "value")) > 0 ) )
and
(LUX < 250)
)
or
startSource["type"] == "automatic"
then
fibaro:call(157, "setValue", POZ_ROL5+25);
fibaro:call(159, "setValue", POZ_ROL6+25);
fibaro:call(161, "setValue", POZ_ROL7+25);
fibaro:call(181, "setValue", POZ_ROLK+25);
fibaro:debug(POZ_ROL5)
fibaro:debug(POZ_ROL6)
fibaro:debug(POZ_ROL7)
fibaro:debug(POZ_ROLK)
fibaro:debug(LUX)
fibaro:sleep(300000)
else
fibaro:debug("Warunki niespelnione")
print "TimeofDay:"fibaro:debug(fibaro:getGlobalValue("TimeofDay"))
print "Temperatura:"fibaro:debug( (api.get('/weather')['Temperature'] ))
print "Rolety:"
fibaro:debug(POZ_ROL5)
fibaro:debug(POZ_ROL6)
fibaro:debug(POZ_ROL7)
fibaro:debug(POZ_ROLK)
print "Światło [LUX]:"fibaro:debug(LUX)
end
0 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.