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 3.0.0.548: 1990 Devices 1172 Events
            Z-Wave 3.0.1.262: 126 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 3.0.0.548: 1990 Devices 1172 Events
                Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

                Comment

                Working...
                X