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

Long Variables - won't allow IP addresses


Question

Posted

When creating Variables the system won't let you type in a long variable with .

 

Ie you start typing Variable 198.165.1.112

 

it will allow 198.165 then will delete the next . and only allow numbers.

 

work around was to copy and paste into field.

 

Minor but could really confuse someone..

8 answers to this question

Recommended Posts

  • 0
Posted

Please use predefined variables.

Don't worry they could be changed on the fly same as regular variables.

By the way you should use variables for numeric values only, and predefined variables could keep any type of value (string, numeric, table and etc.)

  • 0
  • Inquirer
  • Posted

    So if I want a predefined variable to always be the same i just put same value in field 1 and 2 ? system reboot etc won't clear value?

    • 0
    Posted

    Yes and you can delete the second value.

    • 0
    Posted

    Please use predefined variables.

    Don't worry they could be changed on the fly same as regular variables.

    By the way you should use variables for numeric values only, and predefined variables could keep any type of value (string, numeric, table and etc.)

    Seriously? Can I use this kind of global variable to store a table from, lets say, a VD? Without the content being corrupted when the variable panel is saved?

     

    If so, I was looking for this solution for quit some time!

    • 0
    Posted

    Seriously? Can I use this kind of global variable to store a table from, lets say, a VD? Without the content being corrupted when the variable panel is saved?

     

    If so, I was looking for this solution for quit some time!

    Yes it works very well.

    I'm using this variable to store JSON table of all my devices. Very helpful when you re-include the device- no need to change any code.

     

    Here an example of the variable as printed by fibaro:debug() function:

      [DEBUG] 03:15:13: {"room":[{"GMC":"taiMC","AC":392,"name":"tai","roomTemp":207,"RCState":211,"GAC":"AC3","powerStatus":540,"TV":415,"lumens":208,"ACRC":209,"motion":206},{"GMC":"JonMC","GAC":"AC5","motion":214,"roomTemp":215,"AC":408,"ACRC":220,"RCState":222}

     

     

    Just use json.encode and json.decode functions

    • 0
    Posted (edited)

    Yes it works very well.

    I'm using this variable to store JSON table of all my devices. Very helpful when you re-include the device- no need to change any code.

    Just use json.encode and json.decode functions

    Just to be clear, can I store a table (with different values) to a predefined global variable?

     

    EDIT: by using lua in a VD.

    Edited by Lambik
    • 0
    Posted

    Yes, you can used in lua (VD or scenes), but as I mentioned you need to use json.encode and json.decode functions.

    Basically what the functions do is convert the table to string and vise versa.

     

    You can see this at Fibaro new function example:

     

    ids = fibaro:getDevicesId({visible = true, enabled = true}) -- the ids variable is a table.

     print(json.encode(ids)) -- convert table to a string and print it out.

     

    To make the story short use as following:

    Please login or register to see this code.

     

     

    Once you have stored the table as global variable, you can get it at any other scene or VD.

     

    Hope it helps

    • 0
    Posted

    Yes, you can used in lua (VD or scenes), but as I mentioned you need to use json.encode and json.decode functions.

    Basically what the functions do is convert the table to string and vise versa.

     

    You can see this at Fibaro new function example:

     

    ids = fibaro:getDevicesId({visible = true, enabled = true}) -- the ids variable is a table.

     print(json.encode(ids)) -- convert table to a string and print it out.

     

    To make the story short use as following:

    Please login or register to see this code.

     

     

    Once you have stored the table as global variable, you can get it at any other scene or VD.

     

    Hope it helps

    You just made my day!

    Please login or register to see this image.

    /emoticons/default_icon_mrgreen.gif" alt=":mrgreen:" />

     

    Ik know the principle of storing and retrieving value from tables, stored in global variables. I use it in my Presence Detector VD. The problem I got is that values are corrupted when savings are done in the variable panel.

    Check this discussions:

    Please login or register to see this link.

    Please login or register to see this link.

     

    I will try your solution to store it to a predefined global variable solves my problems.

    Why didn't I think of that...

    Please login or register to see this image.

    /emoticons/default_rolleyes.gif" alt=":rolleyes:" />

    Please login or register to see this image.

    /emoticons/default_icon_redface.gif" alt=":oops:" /> 

     

    Thank you so very much!

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