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

another way to store any value, table in userDescription instead of using variable


tinman

Question

One can for sure use global variable to store information, but i don't like them, as they will get overwritten (NaN) when the set value is not numeric and one or more variables with get changed via UI.

 

But there is something else what can be used, every device have property "userDescription", which can be used by user to store what so ever information about that device.

Everybody have at least device 1 (the HC2 itself), and the data can be stored there. Sure, one can use any other device to store information. Finally this is device property, so one can trigger on changes as well. 

 

Example set property:

Please login or register to see this code.

Example read/trigger property:

 

Please login or register to see this code.

userDescription can be used as well as filter, e.g. to search for all devices where we set something (e.g. "spare device")

 

Please login or register to see this code.

I haven't found yet size restriction, so let's go find it :), but remember, size matters (as data will be displayed in UI, the HCx is reading it each time and displaying - good for fast edit/patch, bad for UI speed, so hidden devices as e.g. HCx itself are better to store data).

Edited by tinman
  • Like 1
  • Thanks 6
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Interesting, thanks. 

 

Do you know of any way to avoid hardcoding id's in the header of you scripts? 

Link to comment
Share on other sites

  • 0

So, this code used the user description field to describe where in the 'homeTable' struct devices should be inserted. It's pretty handy and I'm using a version of this myself at the moment. One could of course extend it with other device properties.

Please login or register to see this link.

See T.makeIdTable().

It also tried to overcome the hardcoded id's in the header by using an elaborate scheme that autogenerated a device proxy - the code worked but I'm not using the code myself at the moment, so it's not fully tested.

And yes, I try to stay away from global variables too... :-) 

/J

Edited by jgab
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 0

Hi,

 

is there any information on the number of write cycles we can have here? I'd be cautious to write on a regular basis.

 

Cheers,

jayrock

Link to comment
Share on other sites

  • 0
  • Inquirer
  • On ‎8‎/‎8‎/‎2018 at 9:46 PM, jayrock said:

    is there any information on the number of write cycles we can have here? I'd be cautious to write on a regular basis.

     

    description is device property, exact as value or power is, so you might have thousands of changes per day with (let say) no issues.

    Link to comment
    Share on other sites

    • 0

    OK, thanks.

     

    Let me rephrase: Is UserDescr stored on the physical device, or is it soley kept in the logical device meta data on HC2?

     

    Cheers,

    jayrock

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