Announcement

Collapse
No announcement yet.

PlugExtraData_Get returning Null

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

    PlugExtraData_Get returning Null

    I am creating a new root device(type: eDeviceType_Thermostat.Root) and I want to place a named object in the device's PlugExtraData. When I call get_PlugExtraData_Get (see below) it returns a null.
    This call works fine once the device is created and I'm checking to see if it a root device that contains the Thermostat Data. I have tried calling SaveEventsDevices() and getting a fresh device ref before making the call. Nothing seems to help. I am running the plugin remotely so that I can debug it.


    PlugExtraData.clsPlugExtraData EDO = null;
    EDO = dv.get_PlugExtraData_Get(null);
    if (EDO != null) This is always null!
    {
    if (EDO.AddNamed("Thermostat Data", statData))
    {
    dv.set_PlugExtraData_Set(Util.hs, EDO);
    Util.hs.SaveEventsDevices();
    }
    else
    {
    Util.Log("Error adding named data object to plug-in sample device!", Util.LogType.LOG_TYPE_ERROR);
    }
    }

    Any help would be appreciated.

    #2
    Originally posted by Kirby View Post
    EDO = dv.get_PlugExtraData_Get(null);
    dv.set_PlugExtraData_Set(Util.hs, EDO);
    Note that when you did the _Get, you provided null for the hs reference, which means it is going to get the EDO from the device object currently in memory in your plug-in, so updates that you have made to the device are not going to show until you refresh (re-get) the device object. So provide your Util.hs object on the get, so that it always gets the latest version, and then always provide it on the _Set like you did here so that the changes you made are applied to the "real" device back in HomeSeer.
    Regards,

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

    Comment


      #3
      Thanks, Rick.
      I'm finally getting a handle on the hs vs null in the calls. I had actually tried it both ways.
      The problem turned out to be that I was expecting that HomeSeer had instantiated the clsPlugExtraData object. After going back and examining the VB.NET example I saw that the plugin was instantiating the object. Once I did that everything started working.
      The revised code became:

      PlugExtraData.clsPlugExtraData EDO = new PlugExtraData.clsPlugExtraData();
      if (EDO != null)
      {
      if (EDO.AddNamed("Thermostat Data", statData))
      {
      dv.set_PlugExtraData_Set(Util.hs, EDO);
      }
      else
      {
      Util.Log("Error adding named data object to plug-in device!", Util.LogType.LOG_TYPE_ERROR);
      }
      }
      Util.hs.SaveEventsDevices();

      Comment


        #4
        I'm having this same issue, but your fix did not make a difference. When I go to write the EDO back to the device it fails saying it is null.

        Comment


          #5
          Solution found in http://forums.homeseer.com/showthread.php?t=173585 and after Tinkering

          I Posted a More Detailed note on thread

          Comment

          Working...
          X