Author Topic: Creating Variables....need your expert advice!  (Read 1804 times)

Offline TimAlls

  • Hero Member
  • *****
  • Posts: 722
  • Karma: +0/-0
Creating Variables....need your expert advice!
« on: May 22, 2011, 02:03:35 pm »
I am adding a variable watch to my code generating program. I have added variables of my own to one of my security door sensors and then I poll the variables once a second to display status. It allows one to see the timers etc. in action. I don't know the full impact of what I am doing. Under advance tab we have the options to add variables. A matching service goes with the variable. If I create a variable with a service that really doesn't exist and then use it will it confuse any of the lower level processes?
I hope not because it really works well and eliminates the need for virtual devices.
Question 2
@guessed,
In my advanced tab there are variables such as TripPeriod which the wiki uses as a general purpose variable. How can we know what we can play with that the DSC code won't change? I hope that makes sense!
Regards
Tim Alls
AllSeas Yachts

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Creating Variables....need your expert advice!
« Reply #1 on: May 22, 2011, 02:40:09 pm »
I am adding a variable watch to my code generating program. I have added variables of my own to one of my security door sensors and then I poll the variables once a second to display status. It allows one to see the timers etc. in action. I don't know the full impact of what I am doing. Under advance tab we have the options to add variables. A matching service goes with the variable. If I create a variable with a service that really doesn't exist and then use it will it confuse any of the lower level processes?
I hope not because it really works well and eliminates the need for virtual devices.
Yes, variables within their own ServiceId's are effectively "separate", even if the Variable name is a duplicate (although, no guarantee's that all Plugin code will be "robust" enough, it should be but ya never know)

Within a given device, there's a "list" of the variables associated with it.  This list is of the form:

    (serviceId-1, variableName-1)
    (serviceId-2, variableName-2)
    ....
    (serviceId-n, variableName-n)

where uniqueness is guaranteed across the whole combo (serviceId-n, variableName-n)

They explicitly let you add your own for just the kinda of things you're looking at.

Quote
Question 2
@guessed,
In my advanced tab there are variables such as TripPeriod which the wiki uses as a general purpose variable. How can we know what we can play with that the DSC code won't change? I hope that makes sense!
AllSeas Yachts
Your question makes sense, but there's no clear definition of the "extensions" that various devices and/or Plugins use in terms of Service Variables.  Generally speaking, a Device exposes variables from the composite of Services it implements.

Each of these services is supposed to be well defined, and have a "fixed" number of Variables.  You can see these "fixed" definitions inside the various S_xxxxxx.xml files.

Unfortunately, many devices (and MiOS itself) use additional variables that aren't defined by the Service.  MiOS does this a LOT, especially on the micasaverde-com HaDevice1 serviceId.  In these cases, it's hard to know what the intended purposes is.  In some cases, setting one Variable might trigger another to get set also (I think this is where TripPeriod is coming from, for example)

The safe bet, is to never write to a variable that you didn't create, and always create any variables in a new/neutral serviceId.


Offline TimAlls

  • Hero Member
  • *****
  • Posts: 722
  • Karma: +0/-0
Re: Creating Variables....need your expert advice!
« Reply #2 on: May 22, 2011, 03:51:38 pm »
@guessed,
That's the info was looking for... Thanks
I have more bugs to work out but it is a relief that the direction I went is not going to cause problems.
Regards
Tim