Announcement

Collapse
No announcement yet.

Script to find Z-wave node

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

    Script to find Z-wave node

    Can't seem to find this in the docs... what is the correct way to enumerate thru devices to find the node number of a Z-Wave device?
    Don

    #2
    Bump
    Don

    Comment


      #3
      Originally posted by donstephens View Post
      Bump
      Hi Don,

      What are you trying to accomplish with it? What info do you have that you want to pass to the script and then have it return the node number?

      Cheers
      Al
      HS 4.2.8.0: 2134 Devices 1252 Events
      Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

      Comment


        #4
        Hi Al;

        I'm trying to get the node numbers from all the Z-Wave devices. I have had failed comm problems from nodes from time to time and I'd like to have a script that goes through all the Z-Wave devices and reports the node #.

        Don
        Don

        Comment


          #5
          The best place to get that is the Node Information page in the Z-Wave plugin. If you still want a script, here's a quick one that will report the nodes to a .txt file:

          Code:
          Public Sub Main(ByVal parm As Object)
                  Dim dev As Scheduler.Classes.DeviceClass
                  Dim sw As System.IO.StreamWriter
                  Dim pdata As clsPlugExtraData = Nothing
                  Dim pk() As String
                  Dim s As Object
                  Dim x As Integer
          
                  Try
                      sw = New System.IO.StreamWriter("DumpZWaveDevices.txt", False)
          
                      Dim EN As Scheduler.Classes.clsDeviceEnumeration
                      EN = hs.GetDeviceEnumerator
                      If EN Is Nothing Then Throw New Exception("failed to get a device enumerator from HomeSeer.")
          
                      Do
                          dev = EN.GetNext
                          If dev Is Nothing Then Continue Do
                          pdata = dev.PlugExtraData_Get(hs)
                          If (pdata IsNot Nothing) Then
                              pk = pdata.GetNamedKeys()
                              If (pk IsNot Nothing) Then
                                  For x = 0 To pk.Length() - 1
                                      s = pdata.GetNamed(pk(x))
                                      If (pk(x) = "node_id") Then
                                          sw.WriteLine("ref=(" & dev.ref(hs) & ") - " & dev.Location(hs) & " - " & dev.Location2(hs) & " - " & dev.Name(hs) & ":  " & pk(x).ToString() & " = " & s.ToString())
                                      End If
                                  Next
                              End If
                          End If
                      Loop Until EN.Finished
          
                  Catch ex As Exception
                      hs.WriteLog("DumpZWaveDevices", ex.Message)
                  Finally
                      If (Not sw Is Nothing) Then sw.Close()
                  End Try
              End Sub
          Last edited by rmasonjr; March 13, 2018, 02:43 PM. Reason: changed code
          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


            #6
            Cool, Thanks Rob!
            Don

            Comment


              #7
              Originally posted by rmasonjr View Post
              The best place to get that is the Node Information page in the Z-Wave plugin. If you still want a script, here's a quick one that will report the nodes to a .txt file:

              Code:
              Public Sub Main(ByVal parm As Object)
                      Dim dev As Scheduler.Classes.DeviceClass
                      Dim sw As System.IO.StreamWriter
                      Dim pdata As clsPlugExtraData = Nothing
                      Dim pk() As String
                      Dim s As Object
                      Dim x As Integer
              
                      Try
                          sw = New System.IO.StreamWriter("DumpZWaveDevices.txt", False)
              
                          Dim EN As Scheduler.Classes.clsDeviceEnumeration
                          EN = hs.GetDeviceEnumerator
                          If EN Is Nothing Then Throw New Exception("failed to get a device enumerator from HomeSeer.")
              
                          Do
                              dev = EN.GetNext
                              If dev Is Nothing Then Continue Do
                              pdata = dev.PlugExtraData_Get(hs)
                              If (pdata IsNot Nothing) Then
                                  pk = pdata.GetNamedKeys()
                                  If (pk IsNot Nothing) Then
                                      For x = 0 To pk.Length() - 1
                                          s = pdata.GetNamed(pk(x))
                                          If (pk(x) = "node_id") Then
                                              sw.WriteLine(dev.Location(hs) & " - " & dev.Location2(hs) & " - " & dev.Name(hs) & ":  " & pk(x).ToString() & " = " & s.ToString())
                                          End If
                                      Next
                                  End If
                              End If
                          Loop Until EN.Finished
              
                      Catch ex As Exception
                          hs.WriteLog("DumpZWaveDevices", ex.Message)
                      Finally
                          If (Not sw Is Nothing) Then sw.Close()
                      End Try
                  End Sub
              Awesome this worked great on my Linux HS3 box. Issue is that with hundreds of nodes, in some places such a Z-Wave logs, HS refers to devices by node number, and you can't easily see the node number in your device list, you'd have to open up each device to get that info. With your script I was quickly able to search the TXT file for the node number I was getting errors on and get its name so that I could then go to it in the device list.

              Comment


                #8
                By the way, is there a way to modify the script to show list of device numbers instead, or even better both node and device numbers? I get errors like this in the log but have no idea which device is #580...

                Mar-11 10:51:00 PM Z-Wave Error Device 580 is being set to an invalid value: 0


                Comment


                  #9
                  Originally posted by numgis View Post
                  By the way, is there a way to modify the script to show list of device numbers instead, or even better both node and device numbers? I get errors like this in the log but have no idea which device is #580...

                  Mar-11 10:51:00 PM Z-Wave Error Device 580 is being set to an invalid value: 0


                  I changed the code in my post above to add the device reference.
                  Try that and see if that works for you...
                  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


                    #10
                    Originally posted by rmasonjr View Post
                    I changed the code in my post above to add the device reference.
                    Try that and see if that works for you...
                    Awesome works great, thanks!!

                    Comment


                      #11
                      Originally posted by rmasonjr View Post
                      The best place to get that is the Node Information page in the Z-Wave plugin. If you still want a script, here's a quick one that will report the nodes to a .txt file:

                      Code:
                      Public Sub Main(ByVal parm As Object)
                      Dim dev As Scheduler.Classes.DeviceClass
                      Dim sw As System.IO.StreamWriter
                      Dim pdata As clsPlugExtraData = Nothing
                      Dim pk() As String
                      Dim s As Object
                      Dim x As Integer
                      
                      Try
                      sw = New System.IO.StreamWriter("DumpZWaveDevices.txt", False)
                      
                      Dim EN As Scheduler.Classes.clsDeviceEnumeration
                      EN = hs.GetDeviceEnumerator
                      If EN Is Nothing Then Throw New Exception("failed to get a device enumerator from HomeSeer.")
                      
                      Do
                      dev = EN.GetNext
                      If dev Is Nothing Then Continue Do
                      pdata = dev.PlugExtraData_Get(hs)
                      If (pdata IsNot Nothing) Then
                      pk = pdata.GetNamedKeys()
                      If (pk IsNot Nothing) Then
                      For x = 0 To pk.Length() - 1
                      s = pdata.GetNamed(pk(x))
                      If (pk(x) = "node_id") Then
                      sw.WriteLine("ref=(" & dev.ref(hs) & ") - " & dev.Location(hs) & " - " & dev.Location2(hs) & " - " & dev.Name(hs) & ": " & pk(x).ToString() & " = " & s.ToString())
                      End If
                      Next
                      End If
                      End If
                      Loop Until EN.Finished
                      
                      Catch ex As Exception
                      hs.WriteLog("DumpZWaveDevices", ex.Message)
                      Finally
                      If (Not sw Is Nothing) Then sw.Close()
                      End Try
                      End Sub
                      Thanks for this awesome code, use it all the time. I have two Z-Net interfaces now, is there a way to modify the script to also display the Address / HomeID so that I know which Z-Net my node is on? On the Advanced tab of a device I see a Technology Address which seems to combine the HomeID and Node value, would be great if the script could pull this value. I can modify the script myself, just don't know the name for the value.. dev.Address(hs) perhaps?

                      Comment


                        #12
                        I dont have a HS3 instance to test, but try: dev.Address(hs) or dev.Code(hs)
                        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