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

Help using a variable for temperature in LUA


Question

Posted

Hi all, I have a number of LUA scenes that take action when a thermostat is <= a value. I want to be able to easily change the value for temperature without the need to edit all the scenes. To do this I thought I could use a global variable with tonumber.  However I cannot get any syntax to work and allow the scene to save. Can anyone advise me on whether this is possible please. I’m very new to this. 
 

This is the criteria where I want to replace the 18 with a variable that I can maintain in global variables. I created a variable called MHtempWD with a value of 18. I tried to replace the value = 18 with value = tonumber (hub.getGlobalVariable("MHtempWD"'))

 

Please login or register to see this image.

/monthly_2025_09/image.png.9e225d15b048630898a1ccfcb94524ff.png" />

4 answers to this question

Recommended Posts

  • 0
Posted (edited)

As far as I know there is no way to include variables in scene's condition.

As I see the temperature device is not a trigger for the scene, so...

I suggest just get the value of the temperature device inside your scenes.

 

if hub.getValue(103,"value)<=tonumber (hub.getGlobalVariable("MHtempWD"')) then

... your actions...

end

Compare to your global temperature limit and perform required actions.

 

 

Edited by cag014
  • Thanks 1
  • 0
Posted

I understand he needs <= globalVariable

In scene you have just two options "==" or  "!="

 

But maybe I am wrong

  • 0
Posted

Thanks for the response. I am using a HCL3 lite. If I read the response correctly I can put this code in the actions section. I am using a time trigger and based on this time trigger then check the temperature. So if I understand it right I would leave the time trigger in the conditions and put the if statement in the actions. Then it would only perform the actions if the temperature was below the global variable. 

  • 0
  • Inquirer
  • Posted

    Thanks for the help. I have the concept working in this example. I triggered the event at a set time. Then used the if statement to tell me if it was above or below the variable

     

    Please login or register to see this attachment.

    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...