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

store list of ids in global var


pbillet

Question

hi, i.d like to store a list of ids so multiple scenes can use it, and make life easier when new ids are added.

i tried to store it as a string separated with points ( or spaces tried both), it works when i modify or create the var through my lua code, but if i go to var panel and hit save, my vars become truncated:

22 33 44 becomes 22

22.33.44 becomes 22.44

any suggestion on how to store this in a way that survives the panel save ?

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

This is a known issue.

Please login or register to see this link.

You'll have to use LUA or http api for now. I think you can create a new global var with POST and alter strings with GET.

I suggest you use the json functions to handle such data. That will make your life easier.

Please login or register to see this link.

Link to comment
Share on other sites

  • 0

_ or - won't work either as only numerical values are allowed. No strings (from the GUI).

Link to comment
Share on other sites

  • 0

I don't know if the LUA available supports string manipulation enough but one way would be to store all IDs as 2 or 3 digits (depending on size of installation) and simply concatenating them. Then one could check the length of the string and divide by 2/3 to get number of devices in the list and then stepping through the string and move values to an array or similar.

E.g. devices 13,15, 17 and 22 would be stored as 13151722 and then broken down from there to individual IDs.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Hey sure I can put a padding of 3 and just concatenate without any separation (high Ids are bigger than 99) I could store up to 79 Ids which is far more than needed for in my case.

    I've also some other case where lua code is used to store strings in global var ( ie text, keychain, ip address etc) and If the string is short enough, converting it to ascii then binary could be a solution, but the global vars are limited to 228 caracters , which is not much in ascii->binary.

    Anyway the real true solution would be that global var save doesn't alter the content of the vars.

    [ Added: 2014-05-06, 22:43 ]

    I suggest you use the json functions to handle such data. That will make your life easier.

    Please login or register to see this link.

    About the advice on json, I'm not sure i get It.

    I need to store list of ids so many scenes can use it and I have only one single point to maintain when Ids change or if I add new devices.

    Is there an alternate way to store persistent data using json ?

    Link to comment
    Share on other sites

    • 0

    Using json to format the data you would still use a global var. Json just makes handling the data easier and much more dynamic compared to doing your own custom string handling. You also save some time and lines of code as we have readily available json functions. The limit of the global vars will still limit the amount of data but if you're just storing ID's you'll probably have more than enough space using a single global var anyways.

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