Announcement

Collapse
No announcement yet.

hs.DeleteDevice question

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

    hs.DeleteDevice question

    If I delete a root device in the HS web interface, it removes all of the associated child devices.

    If i execute hs.DeleteDevice(dvRef) it only removes the root and leave the orphaned child devices.

    Bug or intentional?
    Author of Highpeak Plugins | SMS-Gateway Plugin | Blue Iris Plugin | Paradox (Beta) Plugin | Modbus Plugin | Yamaha Plugin

    #2
    Interesting one - imagine the function has been passed on from HS2 which didn't have the relationships arrangement so a sort of bug or missed feature, guess that you'll have to write a little function that examines whether or not the device to delete is a parent device and then delete the children?

    Comment


      #3
      Yup, did just that, but it is a little inconsistent in behavior.
      Author of Highpeak Plugins | SMS-Gateway Plugin | Blue Iris Plugin | Paradox (Beta) Plugin | Modbus Plugin | Yamaha Plugin

      Comment


        #4
        Here's a snippet to remove the root node and any children associated with that root node:

        Code:
        If (ref > 0) Then
                    dv = hs.GetDeviceByRef(ref)
                    assocDevices = dv.AssociatedDevices(hs)
                    For y = 0 To dv.AssociatedDevices_Count(hs) - 1
                        hs.DeleteDevice(assocDevices(y))
                    Next
                    hs.DeleteDevice(ref)
                    hs.SaveEventsDevices()
                End If
        HS4Pro on a Raspberry Pi4
        54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
        Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

        HSTouch Clients: 1 Android

        Comment

        Working...
        X