Jump to content
Guides for the Forum Read more... ×
Poradniki na Forum Read more... ×
  • 0
tinman

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

Question

Posted (edited)

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
  • Thanks 6

Share this post


Link to post
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? 

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
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.

    Share this post


    Link to post
    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

    Share this post


    Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    ×