Announcement

Collapse
No announcement yet.

Z-Wave Device Parameters & Scripting

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

  • Z-Wave Device Parameters & Scripting

    Is it possible via scripting to read/write Z-Wave device parameters? I'd like to create a script that will pole a devices parameters given a single parameter number or range. I haven't been able to find any scripting commands specific to the Z-Wave plugin.

    Thanks.

  • #2
    Here you go for writing parameters:

    Code:
    Imports System.Text
    
    'call Main with NodeID|ParameterNum|Value
    'Based on http://board.homeseer.com/showpost.php?p=1176987&postcount=11
    
    Sub Main(parms As String)
    Dim logName As String = "Z-Wave Param" 'set log name for HS log
    Dim debug As Boolean = True
    
    Dim param as String() = parms.Split("|")
    Dim HomeID as String = "xxxxxxxx"
    Dim NodeID as String = param(0)
    Dim ParamNumber as String = param(1)
    Dim Value as String = param(2)
    Dim ConfigResult As Integer = 0
    Dim ConfigResultVal() As String = {" is Unknown"," is Successful"," has been Queued"," has Failed"}
    
    Try
    ConfigResult = hs.PluginFunction("Z-Wave", "", "Configuration_Set", New Object(){HomeID, Convert.ToByte(NodeID), Convert.ToByte(ParamNumber), Convert.ToByte(1), Convert.ToInt32(Value)})
                    If Debug Then hs.WriteLog(logName, "Result of Parameter " & ParamNumber & " change to " & Value & " on Node " & NodeID & ConfigResultVal(ConfigResult))
    Catch ex As Exception
    hs.writelog(logName, "Error:  " & ex.Message.ToString)
    End Try
    
    End Sub
    It is based on the script posted here: Based on http://board.homeseer.com/showpost.p...7&postcount=11. I don't know of a way to read the parameters. The scripting functions for the zwave plugin are not documented anywhere that I know of.

    Cheers
    Al
    Last edited by sparkman; September 4th, 2016, 04:49 PM.
    HS 3.0.0.548: 1976 Devices 1156 Events
    Z-Wave 3.0.1.262: 123 Nodes on one Z-Net

    Comment


    • #3
      Just messing about a bit but it does appear that there is a Configuration_Get command but unfortunately what it returns does not appear to be data that you would expect (possibly the same enum as the set? I only seem to get 1/0 back). You can try and mess around if you wish however...

      Code:
      Sub Main(ByVal Parms As Object)
      
      Dim Reply As String = ""
      Dim HomeID As String = "E4F5DD8A"
      Dim NodeNumber As Byte = 3
      Dim ParameterNumber As Byte = 12
      
      Reply = hs.PluginFunction("Z-Wave", "", "Configuration_Get", {HomeID, NodeNumber, ParameterNumber})
      
      hs.writelog("", Reply)
      
      End Sub
      My Plugins:

      Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
      Yeelight 3P | Nanoleaf 3P

      Comment


      • #4
        Thanks for insight guys. Here's what I come up with so far. It works on my devices that have a direct route mostly reliably. Without knowing the specifics of how the plugin deals with parameters that don't exist in the device, it's hard to tell what the return really means.

        Code:
        Sub Main(Parms As Object)
        
        Dim Parm() as string = Parms.Split(",")
        hs.WriteLog("Z-Wave", "Node No:  " & Parm(0))
        hs.WriteLog("Z-Wave", "Start Parameter:  " & Parm(1))
        hs.WriteLog("Z-Wave", "End Parameter:  " & Parm(2))
        
        Dim Reply As String = ""
        Dim HomeID As String = "XXXXXXXX"
        Dim NodeNum As Byte = Parm(0)
        Dim ParamNum As Byte = 0
        For ParamNum = Parm(1) To Parm(2)
        Reply = ""
        Reply = hs.PluginFunction("Z-Wave", "", "Configuration_Get", {HomeID, NodeNum, ParamNum})
        hs.writelog("Z-Wave", "Node " & NodeNum & ", Parameter " & ParamNum & " is set to " & Reply)
        hs.WaitSecs(2)
        Next
        End Sub

        Comment


        • #5
          I'm trying out this set command in a script but it's failing... should this Configuration_set command still work?

          hs.PluginFunction("Z-Wave", "", "Configuration_Set", {homeid, nodeID, Parameter, ParamSize, Convert.ToInt32(value)})

          Comment


          • #6
            Originally posted by Toby View Post
            I'm trying out this set command in a script but it's failing... should this Configuration_set command still work?

            hs.PluginFunction("Z-Wave", "", "Configuration_Set", {homeid, nodeID, Parameter, ParamSize, Convert.ToInt32(value)})
            Yes, what's the error message you get in the logs and are you running this on linux? If linux, use this instead (will work on Windows as well):

            Code:
            ConfigResult = hs.PluginFunction("Z-Wave", "", "Configuration_Set", New Object(){HomeID, Convert.ToByte(NodeID), Convert.ToByte(ParamNumber), Convert.ToByte(1), Convert.ToInt32(Value)})

            HS 3.0.0.548: 1976 Devices 1156 Events
            Z-Wave 3.0.1.262: 123 Nodes on one Z-Net

            Comment


            • #7
              Originally posted by sparkman View Post
              Yes, what's the error message you get in the logs and are you running this on linux? If linux, use this instead (will work on Windows as well):
              Code:
              ConfigResult = hs.PluginFunction("Z-Wave", "", "Configuration_Set", New Object(){HomeID, Convert.ToByte(NodeID), Convert.ToByte(ParamNumber), Convert.ToByte(1), Convert.ToInt32(Value)})
              I get this error:
              Exception deserializing message: Unable to find assembly 'HSPI_ZWave, Version=3.0.1.252, Culture=neutral, PublicKeyToken=null'. in the console window right away and it stalls for some time and then I get an exception thrown "ConfigDevicePost: Object reference not set to an instance of an object. in the Homeseer log.

              The Configuration_Get part works fine, but not the _Set...

              I'm running windows10

              Edit: I found out that the parameter is actually set, but it still stalls for 20s and then throws an exception..
              when i read it out later with
              Code:
               newValue = Convert.ToInt16(hs.PluginFunction("Z-Wave", "", "Configuration_Get", New Object() {homeid, nodeID, Parameter}))
              it reads out the new value quite fast.

              how to set a value without delay and errors?

              Comment


              • #8
                is there a delay also when you guys are testing this function?

                Comment


                • #9
                  Originally posted by Toby View Post
                  is there a delay also when you guys are testing this function?
                  I don't get any errors when using the function and it is generally completed very fast. As an example I set a number of parameters on my Dome siren/chime in quick succession using the script here: https://forums.homeseer.com/forum/de...e-siren-script. Maybe post your whole script. What kind of device are you trying to set the parameter on?
                  HS 3.0.0.548: 1976 Devices 1156 Events
                  Z-Wave 3.0.1.262: 123 Nodes on one Z-Net

                  Comment


                  • #10
                    i'm trying to configure a dimmer.
                    i have the following code
                    Code:
                        Public Function SetSingleParameter(ByVal homeid As String, ByVal nodeID As Byte, ByVal Parameter As Byte, ByVal ParamSize As Byte, ByVal value As Int32) As Integer
                    
                            Dim ConfigResult As Integer = 0
                            Dim ConfigResultVal(3) As String
                    
                            ConfigResultVal(0) = "Unknown"
                            ConfigResultVal(1) = "Success"
                            ConfigResultVal(2) = "Queued"
                            ConfigResultVal(3) = "Failed"
                    
                            ConfigResult = Convert.ToInt16(hs.PluginFunction("Z-Wave", "", "Configuration_Set", New Object() {homeid, nodeID, Parameter, ParamSize, value}))
                    
                            Log(("ZWave Node " & nodeID & " on Network " & homeid & ": Parameter Set " & Parameter & " Value: " & value & " -  Result " & ConfigResultVal(ConfigResult)), LogType.Debug)
                            Return ConfigResult
                        End Function

                    Comment


                    • #11
                      Can someone break this down for me to a very simple level. Specifically, I'd like to have an event with an immediate script which sets parameter 10 of device reference 284 to the value 5 for home ID "ABABABAB". I found the following general form for the set command:

                      hs.PluginFunction("Z-Wave", "", "Configuration_Set", New Object(){HomeID, Convert.ToByte(NodeID), Convert.ToByte(ParamNumber), Convert.ToByte(1), Convert.ToInt32(Value)})

                      And applying it to the example, came up with the script:

                      &hs.PluginFunction("Z-Wave", "", "Configuration_Set", New Object(){"ABABABAB", Convert.ToByte(284), Convert.ToByte(10), Convert.ToByte(1), Convert.ToInt32(5)})


                      But when this executes, I get an Init Error, Expected End of Statement.
                      Anybody know what I'm doing wrong?

                      Any working example of an immediate script setting a parameter value would be appreciated!

                      Thanks.

                      Comment


                      • #12
                        Originally posted by jvm View Post
                        Can someone break this down for me to a very simple level. Specifically, I'd like to have an event with an immediate script which sets parameter 10 of device reference 284 to the value 5 for home ID "ABABABAB". I found the following general form for the set command:

                        hs.PluginFunction("Z-Wave", "", "Configuration_Set", New Object(){HomeID, Convert.ToByte(NodeID), Convert.ToByte(ParamNumber), Convert.ToByte(1), Convert.ToInt32(Value)})

                        And applying it to the example, came up with the script:

                        &hs.PluginFunction("Z-Wave", "", "Configuration_Set", New Object(){"ABABABAB", Convert.ToByte(284), Convert.ToByte(10), Convert.ToByte(1), Convert.ToInt32(5)})


                        But when this executes, I get an Init Error, Expected End of Statement.
                        Anybody know what I'm doing wrong?

                        Any working example of an immediate script setting a parameter value would be appreciated!

                        Thanks.
                        Are you doing this as an immediate script command, or a full script? If the former, then use &nhs rather than &hs as you are using VB.NET syntax. &hs expects VBScript syntax.
                        HS 3.0.0.548: 1976 Devices 1156 Events
                        Z-Wave 3.0.1.262: 123 Nodes on one Z-Net

                        Comment


                        • #13
                          Originally posted by sparkman View Post

                          Are you doing this as an immediate script command, or a full script? If the former, then use &nhs rather than &hs as you are using VB.NET syntax. &hs expects VBScript syntax.
                          Thanks. I was trying for "immediate". Your &nhs suggestion gave me some progress (well, at least a something different!). I now get a different error: "Running script C:\Program Files (x86)\HomeSeer HS3\Temp\K1.vb :Exception has been thrown by the target of an invocation.Value was either too large or too small for an unsigned byte."

                          I'm guess it may be in the conversion of the NodeID by the function Convert.ToByte(284) for the node id #284. I've also tried Convert.ToInt16 and Convert.ToInt32 which then give a different error ("cannot be converted to type 'System.Byte'").

                          Any further thoughts or working "immediate" script examples appreciated.

                          Comment


                          • #14
                            Check the documentation for the parameter that you are trying to set. I believe the "Convert.ToByte(1)" should be changed to the the number of bytes the parameter is. If it's 2 bytes, then change to "Convert.ToByte(2)", if it's 4 bytes, change to "Convert.ToByte(4)", etc. I don't have access to my system right now to confirm, so I'm doing an educated guess on that, based on the error that you are getting.
                            HS 3.0.0.548: 1976 Devices 1156 Events
                            Z-Wave 3.0.1.262: 123 Nodes on one Z-Net

                            Comment


                            • #15
                              I have ran into the same problem and have narrowed it down to the nodeID(447) to convert to a byte. Of course, 447 is larger than a byte have have tried the same as you have, .toInt and received the same results.

                              Have you had any luck? Where is the 'Pluginfunction("zwave"....' documented at? I have search the help file and the web and haven't found anything yet.


                              Thanks

                              Comment

                              Working...
                              X