Announcement

Collapse
No announcement yet.

How do I get a device value?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I get a device value?

    Hi,

    I have been searching around trying everything, this should be simple but I cant solve it.

    When I set the value of a device created from my plugin I do:
    Util.hs.SetDeviceValueByRef(Util.Indicator, tempData, true);
    Util.Indicator contains the device reference to the device I change the value of.

    I now want to read and check the device value to see if the user has changed it so that I may send an update to the physical device. I would expect to do something like:
    double returnData = Util.hs.GetDeviceValueByRef(Util.Indicator);
    But that does not exist. Googling around tells me to use this: PollDevice(Util.Indicator).Value;
    But that always returns 0.

    I should be able to do:
    Util.hs.SetDeviceValueByRef(Util.Device4, 4, true);
    Util.hs.SetDeviceValueByRef(Util.Indicator, PollDevice(Util.Device4).Value, true);
    First setting a device to 4, then reading the same device and setting that value to another device. The first device gets a value of 4, but the second only always 0.

    Can anyone help me?

  • #2
    In the plugin SDK you should read about the SetIOMulti call back function. It is called everytime a user changes a device value. Your plugin method should look something like this:

    Code:
     public void SetIOMulti(System.Collections.Generic.List<HomeSeerAPI.CAPI.CAPIControl> colSend)
            {
                foreach (CAPI.CAPIControl CC in colSend)
                {
                    Log("SetIOMulti set value: " + CC.ControlValue.ToString() + "->ref:" + CC.Ref.ToString(), HSPI.LogType.Debug);
                    updateTheRealDevice(CC.ControlValue);
    }
    }
    Check the sample plugin code for more examples.

    Comment


    • #3
      Great, thanks, that was what I should have been looking for. I can now readback information when the user changes them.

      Comment

      Working...
      X