Announcement

Collapse
No announcement yet.

Setting a z-wave device parameter via script

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

    Setting a z-wave device parameter via script

    Lately I've been playing with script work around getting z-wave parameters via script, though I was setting them using an event action. Due to things, I've decided to set the parameters via script rather than event action. Based on some help from sparkman here:

    https://forums.homeseer.com/forum/li...-z-wave-device

    I got the configuration_get working initially, and where I went back to to try to get configuration_set working. However I cannot get configuration_set to change the parameter on the switch. It claims it worked, no error, I get a successful result code, but when I query the parameter after the set, the parameter has not changed. If I set the same parameter on the same device using an event action, the parameter sets successfully.

    Any ideas what I might be missing? To go back to basics, i've gone back to the script sparkman gave me:

    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 = "0000000"
        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
    I get a successful result, but the parameter did not change on the device.

    Any ideas what I might be missing?

    regards,

    Paul

    #2
    I assume that your are setting your "HomeID" variable to your actual zwave ID, rather than all zeroes like you have shown.

    Comment


      #3
      Yup. Home ID is appropriately set. And similar scripting that uses configuration_get to query the parameter is working perfectly. I just can't get configuration_set to work. Though, like I said, it claims it's successfully setting the parameter. (If I don't have the correct home ID it does actually throw an error to let me know the ID doesn't exist).....

      Comment


        #4
        Next suggestion: Try setting a parameter on something else that you know will work, such as the LED color on a WS200 or WD200 switch. If that works, then you know the code is good and the issue is with the device itself.

        Comment


          #5
          Yup, already done that. I can set the parameter successfully using the Event Action for setting a Z-Wave parameter. That's initially how I was doing it, using the Event Actions to set the parameters and using scripting to query them and do things based on them. Due to issues around complex event logic, parallelism vs. serialism, etc, I've decided I'd like to have my scripts do the setting of the parameter as well querying. The parameter I'm trying to set, I know is good - it sets just fine doing an Event Action to set the Z-Wave parameter. But done using the script, the script claims success, but the parameter has not been changed.

          Comment


            #6
            I’ll try to replicate tomorrow. It may be worthwhile creating a ticket with HS as well, although if it’s a bug, I would suspect it’s unlikely to be resolved in the HS3 plugin. rjh Rich, can you confirm that the syntax in the script is correct?
            HS 4.2.8.0: 2134 Devices 1252 Events
            Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

            Comment


              #7
              Originally posted by sparkman View Post
              I’ll try to replicate tomorrow. It may be worthwhile creating a ticket with HS as well, although if it’s a bug, I would suspect it’s unlikely to be resolved in the HS3 plugin. rjh Rich, can you confirm that the syntax in the script is correct?
              So I figured it out. It was a dummy bit on my side. I went to create an event action to set the property so that I could recreate the issue for a bug ticket, and as I was setting up the action, I realized that one of the options to set in the action is the byte size - the byte size defaults to 1, but for my particular property it needs to be 4. So I went back to the script:

              Code:
              ConfigResult = hs.PluginFunction("Z-Wave", "", "Configuration_Set", New Object(){HomeID, Convert.ToByte(NodeID), Convert.ToByte(ParamNumber), Convert.ToByte(1), Convert.ToInt32(ParamValue)})
              And realized that, on a guess, the 'Convert.ToByte(1)' is probably the byte size setting for the parameter set. Changed it to 4, and *boom*, it worked.

              All is now working, via script....

              Thanks folks!

              Paul

              Comment


                #8
                Originally posted by paul View Post

                So I figured it out. It was a dummy bit on my side. I went to create an event action to set the property so that I could recreate the issue for a bug ticket, and as I was setting up the action, I realized that one of the options to set in the action is the byte size - the byte size defaults to 1, but for my particular property it needs to be 4.
                Thanks for letting us know. Good point on that, as in hindsight it shouldn't have been hard-coded. I'll update the script in my posting to make it a variable.

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

                Comment


                  #9
                  I am trying to set the parameters for a Z-Wave Chime to control the sound the chime makes when triggered by different devices. This code fails for me because my node ID is 626.

                  LOG RESULTS:
                  Error: Value was either too large or too small for an unsigned byte.
                  11/18/2022 4:28:53 PM Script Z-Wave Param NodeID: 626 Parameter Number: 5 Value: 1

                  ​When I change to a different chime that has a nodeID of 8, the script just runs forever.

                  CODE:

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

                  The parameter should be 5 with a value of 1, size of value = 1 byte

                  Documentation is here: https://products.z-wavealliance.org/...s/2484/configs




                  Comment


                    #10
                    626 isn't a valid nodeid. Valid range for that is 1 to 232, which fits in a single byte.

                    Perhaps 626 is the HomeSeer device ID? That's an entirely different thing.

                    Comment


                      #11
                      Anyone update this script to do a batch of... multiple devices and/or multiple parameters?

                      I have 50 newly installed Zooz ZEN30 dimmers and need to set 8 or 9 parameters on each. TIA

                      Comment


                        #12
                        Originally posted by zwolfpack View Post
                        626 isn't a valid nodeid. Valid range for that is 1 to 232, which fits in a single byte.

                        Perhaps 626 is the HomeSeer device ID? That's an entirely different thing.
                        Yes, that is the HS deviceID. Where is the nodeID located? Thank you.

                        Comment


                          #13
                          Originally posted by cmdrcrank View Post

                          Yes, that is the HS deviceID. Where is the nodeID located? Thank you.
                          All Z-Wave Device Addresses are made of the HomeID plus the Node ID. 003D3409-149 for one of my devices is HomeID 003D3409 and Node 149. In HS3 or HS4 you can select that Addresses are shown on the Device Manager. Look under Setup>Custom.

                          Click image for larger version

Name:	capture.png
Views:	83
Size:	55.3 KB
ID:	1576443
                          HS4 Pro, Windows 10 pro

                          Comment


                            #14
                            I found it. Thank you.

                            Comment


                              #15
                              Originally posted by Ltek View Post
                              Anyone update this script to do a batch of... multiple devices and/or multiple parameters?

                              I have 50 newly installed Zooz ZEN30 dimmers and need to set 8 or 9 parameters on each. TIA
                              Cross post. See the reply in your other thread.

                              https://forums.homeseer.com/forum/hs...ave-parameters

                              Comment

                              Working...
                              X