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
Szakos 0
Dear All,
I'm confused to run scene with or without "while true do" cycle to use scene all triggered command change.
I have the following easy code without "while true do" to change the airfresh working status if the alarm system is on or off. Work without an problem, if the alarm system status ( thrue smart implant input ) is changed the wall plug of the airfresh also changed
Here is the LUA code:
--[[
%% autostart
%% properties
34 value
%% events
%% globals
--]]
local alarm
local airfreshId = 55;
local airfreshStatus
function airfresh()
alarm = tonumber(fibaro:getValue(34, 'value'));
airfreshStatus = tonumber(fibaro:getValue(airfreshId, 'value'));
if ( alarm == 0 and airfreshStatus == 0 )
then
fibaro:call(airfreshId, "turnOn");
elseif ( alarm == 1 and airfreshStatus == 1 )
then
fibaro:call(airfreshId, "turnOff");
end;
end;
-- Main program
airfresh();
And here is the similar LUA code when I need to switch on or off the bathroom electrical radiator heating. If I use this LUA code without "while true do" cycle and I change the termostat adjustment no any action happened. If I use the same code with "while true do" cycle this work perfect.
--[[
%% autostart
%% properties
28 value
29 value
281 value
272 value
%% events
%% globals
--]]
local thermostat -- id:28 radiator thermosztat
local roomtemp -- id:29 room temperature
local radiatorheatId = 54; -- id:54 radiator heating
local heatingwater -- id:281 boiler heating water temp
local heatingwaterpump -- id:272 heating water pump
local tempswitch = true;
function radiator()
thermostat = tonumber(fibaro:getValue(28, 'value'));
roomtemp = tonumber(fibaro:getValue(29, 'value'));
heatingwater = tonumber(fibaro:getValue(281, "value"));
heatingwaterpump = tonumber(fibaro:getValue(272, "value"));
if ( (roomtemp - thermostat) >= 0 )
then
tempswitch = false;
else
tempswitch = true;
end;
if (
( tempswitch == true and
heatingwater < 30 and
heatingwaterpump == 0 )
)
then
fibaro:call(radiatorheatId, "turnOn");
else
fibaro:call(radiatorheatId, "turnOff");
end;
end;
-- Main program
while true do
radiator();
fibaro:sleep(60000); -- Wait 1 minute
end;
Can you please advise why I need to run while true do cycle in the 2nd program, if the 1st program run without this cycle perfect ?
Thank you
Link to comment
Share on other sites
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.