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

Persistent data, communication between UI elements in VD


Question

Posted

I really miss the ability to store persistent data in a VD (such as state), and to have proper communication between UI elements such as a button and the main code. The workarounds I have found, is to use a label to share and store data, or serialize a table to a string and store in a global variable. Is there really no better solution?

6 answers to this question

Recommended Posts

  • 0
Posted

I think converting a table to a json object (string) and storing it in a global variable is the only viable solution for the moment.

  • 0
Posted

Yeah sadly global is the only way. Or the IP address and TCP port fields if not in use. Not sure how they go storing json tables though.

Posted an idea that about changes to VD programming that sh/would solve this problem here

Please login or register to see this link.

  • 0
Posted

I found if you dont use variable type local 

Please login or register to see this code.

and if you use classic variable

Please login or register to see this code.

 then data are stored in such variables even if main code in VD start again.

 

Try code below in VD if you want to test it.

Please login or register to see this code.

  • 0
  • Inquirer
  • Posted

    Thank you for your replies. The last code is an infinite loop, I am not sure if we're talking about the same thing here?

    • 0
    Posted

    Thank you for your replies. The last code is an infinite loop, I am not sure if we're talking about the same thing here?

     

    Yeah, It's an infinite loop. If I understand it corectly, that you need to get some state saved. this will save it, that you do not need to save it elsewhere (if using main code only). For connection between button and main code is Label good idea, but i would place something there via REST API (JSON) in front of the code for something, that you do not want another peaople to see in label, but it is desired for another user to use that device.

    • 0
  • Inquirer
  • Posted (edited)

    I used the approach from Krikroff's Sonos VD, and coded this yesterday. It seems to fit my needs, but be aware that it is not thoroughly tested yet!

    Please login or register to see this code.

    Edited by cecolon

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