Announcement

Collapse
No announcement yet.

New devices created each time plugin is started

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

  • New devices created each time plugin is started

    I have been working around this problem for a while now but deleting the devices before I restart the plugin. But is there a way of not having to delete the devices manually but rather reconnect to the already created devices since last time?

  • #2
    Is it ment to be created a list of the devices after the first start and then you store that list in a file to be read next time the plugin starts?

    Comment


    • #3
      This is where the root/child relationships of devices really help.

      You can store your 'root' device reference in an INI file.
      When your plugin starts, get your device class loaded with that reference. Something like:
      Code:
      pDev = hs.GetDeviceByRef(gparentDeviceRef)
      Now, pDev is your parent device. You can the request a list of all the child devices instead of iterating over every device in the system. Something like:
      Code:
      assocDevices = pDev.AssociatedDevices(hs)
      For x = 0 To pDev.AssociatedDevices_Count(hs) - 1
           dev = hs.GetDeviceByRef(assocDevices(x))
           .
           .
      Next x
      This assumes that you created the parent device first.
      You then create the child devices using something like:
      Code:
       dvp.AssociatedDevice_Add(hs, ref)
       dv.AssociatedDevice_ClearAll(hs)
       dv.AssociatedDevice_Add(hs, dvp.Ref(hs))
      
       dv.Relationship(hs) = Enums.eRelationship.Child
       dvp.Relationship(hs) = Enums.eRelationship.Parent_Root
      I think there's an example of this in one of the SDK samples.
      HS3Pro Running on a Raspberry Pi3
      64 Z-Wave Nodes, 168 Events, 280 Devices
      UPB modules via OMNI plugin/panel
      Plugins: Z-Wave, BLRF, OMNI, HSTouch, weatherXML, EasyTrigger
      HSTouch Clients: 3 Android, 1 Joggler

      Comment


      • #4
        Thanks for your answer. I searched around in my code for what you described. My code is based on the HSPI_SAMPLE example plugin.

        It apperantly does this save, but I had made another error.

        I did these settings in the root device:
        DT.Device_Type = (int)DeviceTypeInfo_m.DeviceTypeInfo.eDeviceType_Plugin.Root ;
        DT.Device_SubType = 0;

        And it should be just:
        DT.Device_Type = 69;

        When I did that change, it started working, I only get devices when I start the plugin if there are devices missing.

        Thanks again for your help!

        Comment

        Working...
        X