Announcement

Collapse
No announcement yet.

Device Class

Collapse
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Device Class

    Folks,

    Rich put something important in the documentation for the device class, and he may have even posted here somewhere, but it is important enough that I wanted to post it and stick it so that everybody would notice...

    We had two ways of taking care of the fact that you all wanted access to the device class object, but the interface we are using would not allow it to happen as you are used to it being in HS2 and previous versions.

    Because plug-ins can run on different machines than HomeSeer, access to other plug-ins AND objects within HomeSeer such as the device class go through an interface which converts the object into a data stream, transmits it to the other end, and then converts it back.

    This means that if we allowed you to access the device class objects directly, you would make changes to properties of the device class object without realizing that you were changing a copy and were not affecting the real object back in HomeSeer-land. Our choices were to eliminate access to the device class objects and provide scripting functions to make changes to a device, or to do as we have done which is to put an argument of the hs object whenever you want to access the latest version of a property value.

    Since people read from the device class objects quite a bit, we decided to go with this latter option - HOWEVER (and I am finally getting to the point of this post) there is something important that you need to realize about the use of that parameter.

    Since when you access a device class object you are working with a COPY of that object, the hs parameter allows you to make sure you have the latest data, but using the hs parameter means that two-way communication over the interface will take place, which is much, much, much slower than using your local copy.

    So, for example, if you want to see what the device's name is, then use this:
    dv.Name(Nothing)
    rather than this
    dv.Name(hs)

    If you are worried that your plug-in has had the object for a long time and the user may have changed something, then you could always create a separate thread as a background process that wakes up every hour or so and updates the references to devices to get the latest ones.

    However, if you want to make a change, such as to change a device's location from "First Floor" to "Second Floor", then you MUST include the hs object or the change will not happen:
    dv.Location(hs) = "Second Floor"

    So please remember, once you get a device class object, unless you really need to know that you have the latest data from it, use "Nothing" (null object) rather than "hs" and the plug-in will operate MUCH more quickly.

    Attached is an excerpt from the help file for further reading and more examples.
    Attached Files
    Regards,

    Rick Tinker (a.k.a. "Tink")
Working...
X