Jump to content

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


  • 0

FGT-001 LUA assistance ;)


Blackdog65

Question

Hi all,

 

I'm new to HC2 having migrated from Domoticz. I've a limited knowledge of LUA and so rely heavily on copy and paste ;)

I am trying to create a scene whereby if any of my heat controllers are calling for heat a fibaro relay will switch on my boiler... and if all off... turn it off again i.e. " if A or B or C = On then set H = On elsif A and B and C = Off then set H = Off"

My attempt at code is as follows

Please login or register to see this code.

This appears to run without bugs but just turns the boiler (device 48) on and stays on.

Does anyone have any idea where I am going wrong?

Any help/tips would be greatly appreciated.

 

Many thanks

Sean

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0
44 minutes ago, Blackdog65 said:

Hi all,

 

I'm new to HC2 having migrated from Domoticz. I've a limited knowledge of LUA and so rely heavily on copy and paste ;)

I am trying to create a scene whereby if any of my heat controllers are calling for heat a fibaro relay will switch on my boiler... and if all off... turn it off again i.e. " if A or B or C = On then set H = On elsif A and B and C = Off then set H = Off"

My attempt at code is as follows

Please login or register to see this code.

This appears to run without bugs but just turns the boiler (device 48) on and stays on.

Does anyone have any idea where I am going wrong?

Any help/tips would be greatly appreciated.

 

Many thanks

Sean

The only 'fault' I can find is that you use "and
startSource["type"] == "other"" twice, which would mean that you could get problems when you start the scene manually.

I have a similar scene that does the same thing (with a Secure boilerswitch, not a fibaro relay, but that should make no difference)

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Hi

    Please login or register to see this link.

    ,

    Many thanks for the quick answer!

    I removed the extra line but it has made no difference. I think the script is seeing the heat controllers as always on. When I used them with a Zipabox, they gave an "On" signal when calling for heat which worked well with the Zipato smart stat so I assumed that when they were in "Heat" mode

    Please login or register to see this code.

    that they would be giving the equivalent of an "On" signal. Maybe I'm not understanding the functions of the FGT-001 correctly.

    I've searched the forum (and Google) and I'm more confused :roll:

    Link to comment
    Share on other sites

    • 0
    11 minutes ago, Blackdog65 said:

    Hi

    Please login or register to see this link.

    ,

    Many thanks for the quick answer!

    I removed the extra line but it has made no difference. I think the script is seeing the heat controllers as always on. When I used them with a Zipabox, they gave an "On" signal when calling for heat which worked well with the Zipato smart stat so I assumed that when they were in "Heat" mode

    Please login or register to see this code.

    that they would be giving the equivalent of an "On" signal. Maybe I'm not understanding the functions of the FGT-001 correctly.

    I've searched the forum (and Google) and I'm more confused :roll:

    Are you sure that your variable "operatingmode" does indeed change to 0 sometimes ?

    I have 5 rooms controlled by the FGT and use 5 different variable names (same first 5 characters but then two characters that are referring to the room where the FGT is in like OperatMB for the master Bedroom.

    I don't see very well how you get your values of your variables, why they have the same names and whij you convert them to strings ??

    My code for the living room is:

     

    --[[
    %% killOtherInstances
    %% properties
    172 value
    169 value
    18 value
    %% weather
    %% events
    %% globals
    WwarmZH
    Home
    --]]

    local startSource = fibaro:getSourceTrigger();
    local boileraan = (fibaro:getValue(198, "mode") == "1")
    if (
     ( fibaro:getGlobalValue("WwarmZH") == "20,6"  and  fibaro:getGlobalValue("Home") == "Home"  and  tonumber(fibaro:getValue(172, "value")) == 0  and  tonumber(fibaro:getValue(169, "value")) == 0  and  tonumber(fibaro:getValue(18, "value")) < 20.6 and fibaro:getGlobalValue("BoilervraagZH") == "Nee")
    or
     ( fibaro:getGlobalValue("WwarmZH") == "17"  and  fibaro:getGlobalValue("Home") ~= "Home"  and  tonumber(fibaro:getValue(172, "value")) == 0  and  tonumber(fibaro:getValue(169, "value")) == 0  and  tonumber(fibaro:getValue(18, "value")) < 17 and fibaro:getGlobalValue("BoilervraagZH") == "Nee")
    or
    startSource["type"] == "other"
    )
    then
        fibaro:setGlobal("BoilervraagZH", "Ja");
          fibaro:call(106, "setMode", 1);
        fibaro:call(106, "setTargetLevel", 30);
        fibaro:call(190, "setMode", 1);
        fibaro:call(190, "setTargetLevel", 30);
    elseif
     (fibaro:getGlobalValue("WwarmZH") == "20,6"  and  (fibaro:getGlobalValue("Home") ~= "Home"  or  tonumber(fibaro:getValue(172, "value")) ~= 0  or  tonumber(fibaro:getValue(169, "value")) ~= 0  or  tonumber(fibaro:getValue(18, "value")) >= 20.6 ) and fibaro:getGlobalValue("BoilervraagZH") == "Ja")
    or
     (fibaro:getGlobalValue("WwarmZH") == "17"  and  (fibaro:getGlobalValue("Home") ~= "Home"  or tonumber(fibaro:getValue(172, "value")) ~= 0  or  tonumber(fibaro:getValue(169, "value")) ~= 0  or  tonumber(fibaro:getValue(18, "value")) >= 17 )and fibaro:getGlobalValue("BoilervraagZH") == "Ja")
    or
      fibaro:getGlobalValue("WwarmZH") == "Uit"
    then
      fibaro:setGlobal("BoilervraagZH", "Nee");
      setTimeout(function()
        fibaro:call(106, "setMode", 1);
        fibaro:call(106, "setTargetLevel", 10);
        fibaro:call(190, "setMode", 1);
        fibaro:call(190, "setTargetLevel", 10);
        end, 300000)
    end

     

     

    The boiler is witched on when the temperature is below the setpoint (20,6 when hom, 17 when away) on condition that all windows are closed.

    When the room temperature is lower than the setpoint I change a variable (boilervraagZH, which means demand for heat from the living room) to "yes".

     

    an other part of the code then looks up all the variables of the different rooms and, if one or more rooms have this variable on yes, the boiler is witched on ("setmode" iq set to "1") and, for debugging purposes  I send an email and a push message to tell me that the boiler is switched on or off. This only in the beginning to make sure the boiler is not consuming gas while I am not home or the windows are open, due to some error in the code somewhere.

     

    --[[
    %% killOtherInstances
    %% properties
    %% weather
    %% events
    %% globals
    BoilervraagBK
    BoilervraagDR
    BoilervraagKE
    BoilervraagMB
    BoilervraagZH
    --]]

    local startSource = fibaro:getSourceTrigger();
    if (
     ( fibaro:getGlobalValue("BoilervraagBK") == "Ja"  or  fibaro:getGlobalValue("BoilervraagDR") == "Ja"  or  fibaro:getGlobalValue("BoilervraagKE") == "Ja"  or  fibaro:getGlobalValue("BoilervraagMB") == "Ja"  or  fibaro:getGlobalValue("BoilervraagZH") == "Ja" )
    or
    startSource["type"] == "other"
    )
    then
        fibaro:call(198, "setMode", "1");
          fibaro:call(2, "sendDefinedEmailNotification", "35");
        fibaro:call(11, "sendDefinedPushNotification", "35");
    else
          fibaro:call(198, "setMode", "0");
          fibaro:call(2, "sendDefinedEmailNotification", "36");
        fibaro:call(11, "sendDefinedPushNotification", "36");
    end
     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Thank you again for a great reply!

    So, I started by constructing my scene using the graphic block system and found that there was no "elseif" option. I then opted to convert to LUA and found that it had written the first half for me so I assumed it was correct... it appears not :lol:

    I thought I was directly reading the state of the stat rather than a variable.

    Looking at your code, are your temperature settings fixed in the LUA and not adjustable in the Heating Panel?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Great news! I found this link

    Please login or register to see this link.

    with lua code for any z-wave thermostat head and can be used for a Fibaro relay OR a Secure Actuator. It doesn't need external variable and works with the Heating Panel. It took a bit of Googling to translate the Slovak comments to English... but I got there AND IT WORKS!

    My version is as follows

    Please login or register to see this code.

    To run with a Secure Actuator the last section that deals with the "TurnOn" "TurnOff" needs to be changed to

    Please login or register to see this code.

    This may be a little late to help you but I hope that it will help someone ;D

    Once again, many thanks for your replies!

    Sean

    Link to comment
    Share on other sites

    • 0

    Interesting post ! Will look up the link and see what I can do with it.

     

    Thanks and glad that you managed to get your system working.

    Link to comment
    Share on other sites

    • 0

    Hi, 

     

    I constructed my solution a little differently. I have used a virtual device and put my code in the main loop, see below:

     

    --[[
    %% properties
    %% events
    %% globals
    --]]
    local LivingRoomHeatReq
    local DiningRoomHeatReq
    local MainBedHeatReq
    local AlfieRoomHeatReq
    local ChrisRoomHeatReq
    local GamesRoomHeatReq

    if fibaro:getValue(76, "value") > fibaro:getValue(77, "value") then
      LivingRoomHeatReq = 1;
      else
      LivingRoomHeatReq = 0;
      end

    fibaro:debug('Living Room Target Temperature: ' ..fibaro:getValue(76, "value"));
    fibaro:debug('Living Room Acutal Temperature: ' ..fibaro:getValue(77, "value"));
    fibaro:debug('Living rooom heat request: ' ..LivingRoomHeatReq);  

    if fibaro:getValue(81, "value") > fibaro:getValue(82, "value") then
      DiningRoomHeatReq = 1;
      else
      DiningRoomHeatReq = 0;
      end

    fibaro:debug('Dining Room Target Temperature: ' ..fibaro:getValue(81, "value"));
    fibaro:debug('Dining Room Acutal Temperature: ' ..fibaro:getValue(82, "value"));
    fibaro:debug('Dining rooom heat request: ' ..DiningRoomHeatReq);  

    if fibaro:getValue(71, "value") > fibaro:getValue(72, "value") then
      AlfieRoomHeatReq = 1;
      else
      AlfieRoomHeatReq = 0;
      end

    fibaro:debug('Alfie Bedroom Target Temperature: ' ..fibaro:getValue(71, "value"));
    fibaro:debug('Alfie Bedroom Acutal Temperature: ' ..fibaro:getValue(72, "value"));
    fibaro:debug('Alfie bedrooom heat request: ' ..AlfieRoomHeatReq);  

    if fibaro:getValue(61, "value") > fibaro:getValue(62, "value") then
      MainBedHeatReq = 1;
      else
      MainBedHeatReq = 0;
      end

    fibaro:debug('Main Bedrrom Target Temperature: ' ..fibaro:getValue(61, "value"));
    fibaro:debug('Main Bedroom Acutal Temperature: ' ..fibaro:getValue(62, "value"));
    fibaro:debug('Main bedrooom heat request: ' ..MainBedHeatReq);  

    if fibaro:getValue(66, "value") > fibaro:getValue(67, "value") then
      ChrisRoomHeatReq = 1;
      else
      ChrisRoomHeatReq = 0;
      end

    fibaro:debug('Chris Bedroom Target Temperature: ' ..fibaro:getValue(66, "value"));
    fibaro:debug('Chris Bedroom Acutal Temperature: ' ..fibaro:getValue(67, "value"));
    fibaro:debug('Chris bedrooom heat request: ' ..ChrisRoomHeatReq);  

    if fibaro:getValue(56, "value") > fibaro:getValue(57, "value") then
      GamesRoomHeatReq = 1;
      else
      GamesRoomHeatReq = 0;
      end

    fibaro:debug('Games Room Target Temperature: ' ..fibaro:getValue(56, "value"));
    fibaro:debug('Games Room Acutal Temperature: ' ..fibaro:getValue(57, "value"));
    fibaro:debug('Games rooom heat request: ' ..GamesRoomHeatReq);  

    if LivingRoomHeatReq == 1
      or DiningRoomHeatReq == 1
      or AlfieRoomHeatReq == 1
      or MainBedHeatReq == 1
      or ChrisRoomHeatReq == 1
      or GamesRoomHeatReq == 1
      then
      fibaro:call(86, "turnOn");
      elseif LivingRoomHeatReq == 0
      and DiningRoomHeatReq == 0
      and AlfieRoomHeatReq == 0
      and MainBedHeatReq == 0
      and ChrisRoomHeatReq == 0
      and GamesRoomHeatReq == 0
      then
      fibaro:sleep(300000);
      fibaro:call(86, "turnOff");
      end

    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...