Hi,
I've found this great script from MyHappy back in 2014 that I'd like to use slightly differently to fix devices being orphaned devices when Zwave is restarted.
Basically all of my child devices are 6 consecutive numbers after the parent, so parent = 88 and the 6 child devices will be 89,90,91,92,93,94. What I'd like is to have the RootDV in the script below as an array of all my parent devices (RootDV) (88, 100, 110, 120 etc) and then the script to cycle through each Child device not using the array as in the script but simply as RootDV +1, +2, + 3, +4, +5, +6 and then continue to add them as per the script to the parent.
My coding skills are limited so hoping someone can just let me know what can be easily changed to serve this purpose........please...
Thanks in advance
I've found this great script from MyHappy back in 2014 that I'd like to use slightly differently to fix devices being orphaned devices when Zwave is restarted.
Basically all of my child devices are 6 consecutive numbers after the parent, so parent = 88 and the 6 child devices will be 89,90,91,92,93,94. What I'd like is to have the RootDV in the script below as an array of all my parent devices (RootDV) (88, 100, 110, 120 etc) and then the script to cycle through each Child device not using the array as in the script but simply as RootDV +1, +2, + 3, +4, +5, +6 and then continue to add them as per the script to the parent.
My coding skills are limited so hoping someone can just let me know what can be easily changed to serve this purpose........please...
Thanks in advance
Code:
Dim RootDV As Integer = 88 Dim ChildDV() As Integer = {89,90,91,92,93,94} Dim rDV As Scheduler.Classes.DeviceClass Dim cDV As Scheduler.Classes.DeviceClass Sub Main(ByVal Parm As Object) For i As Byte = 0 To ChildDV.GetUpperBound(0) + 1 If i = 0 Then If hs.deviceexistsref(RootDV) Then rDV = hs.GetDeviceByRef(RootDV) hs.writelog("Root Device", "Root Device Name: " & rDV.Name(hs)) hs.writelog("Root Device", "Current Root Relationship: " & rDV.Relationship(hs)) If rDV.Relationship(hs) = 0 Then rdv.Relationship(hs) = Enums.eRelationship.Parent_Root hs.writelog("Root Device", "New Root Relationship: " & rDV.Relationship(hs)) End If Else hs.writelog("Error", "Device Reference " & RootDV & " does not exist") End If Else If hs.deviceexistsref(ChildDV(i - 1)) Then If rdv IsNot Nothing Then rdv.AssociatedDevice_Add(hs, ChildDV(i - 1)) cDV = hs.GetDeviceByRef(ChildDV(i - 1)) hs.writelog("Child Device", "Child Device Name: " & cDV.Name(hs)) hs.writelog("Child Device", "Current Child Relationship: " & cDV.Relationship(hs)) If cDV.Relationship(hs) = 0 Then cdv.Relationship(hs) = Enums.eRelationship.Child hs.writelog("Child Device", "New Child Relationship: " & cDV.Relationship(hs)) End If cdv.AssociatedDevice_Add(hs, RootDV) Else hs.writelog("Error", "Device Reference " & ChildDV(i - 1) & " does not exist") End If End If Next End Sub
Comment