Announcement

Collapse
No announcement yet.

How to control Z-Wave Dimmer

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

    How to control Z-Wave Dimmer

    I have simple single script test event that is supposed to dim a Z-Wave switch.

    Running the event gives this in the log -

    Aug-10 14:11:39 Event Event Admin Z-Wave Node 15 Dim by Name triggered by the event page 'Run' button.
    Aug-10 14:11:39 Event Event Trigger "Admin Z-Wave Node 15 Dim by Name"
    Aug-10 14:11:39 Event Running script statement immediately: &hs.SetDeviceValueByName("First Hall Node 15",0)

    But the Z-Wave switch does not go on.
    The device screen line for this device shows -
    Off First Hall Node 15 014D0697-015
    Z-Wave Switch Multilevel
    Today 14:11:39

    So the device noticed the change (times) but the actual device did not go on.
    If I use the buttons/sliders on the devices page it goes on/off/dims fine.

    How do I control a Z-Wave device from a script?

    The device was just imported from the Aeon Labs stick and as I say works fine from the slider/buttons.

    Thank you for any help.

    #2
    Search for CAPIControl, you'll find several examples on how to send control commands.
    The HS3 help page also has info.
    http://homeseer.com/support/homeseer...lp/default.htm

    Z

    Comment


      #3
      May well be true

      Hi vasrc, nice to hear from you.

      OK, I freely admit I >can< use the more complex 'bits' inside HomeSeer*.

      But how is just a regular 'non programmer' supposed to make a script that would control a Z-Wave device?

      Using CAPIControl is well beyond most people who aren't developers but is something they might want to do outside of a set of event statements by dropping into a script.

      Heck, I am a developer and if I can stay away from it then I will !


      (*Just posted an abstract device [HSPI_ScriptDevice] that drops into a script to do the real driving of the device - check out the reasons for it and you'll see why it is useful.)

      Comment


        #4
        Originally posted by JamesWestoby View Post
        Hi vasrc, nice to hear from you.

        OK, I freely admit I >can< use the more complex 'bits' inside HomeSeer*.

        But how is just a regular 'non programmer' supposed to make a script that would control a Z-Wave device?

        Using CAPIControl is well beyond most people who aren't developers but is something they might want to do outside of a set of event statements by dropping into a script.

        Heck, I am a developer and if I can stay away from it then I will !


        (*Just posted an abstract device [HSPI_ScriptDevice] that drops into a script to do the real driving of the device - check out the reasons for it and you'll see why it is useful.)
        You are not alone...have a good read of this thread: http://board.homeseer.com/showthread.php?t=167405
        Jon

        Comment


          #5
          It's just a couple of lines of code (well more if you sub it). I've saw a Linq version posted that was only one line?
          Everyone that's scripting HS3 has felt the CAPI "pain", but it goes away quickly. Once you get your head around what they are trying to do, it's not all that more difficult than the other HS calls.
          Once someone walks into the scripting world from Events, they're going to have some level of learning curve depending on their background. Took me two six packs of Black Hook before I finally grokked it

          Z
          Last edited by vasrc; August 11, 2014, 12:25 AM.

          Comment


            #6
            No kidding... just about the time you think you have wrapped your head around it, the booze hits.
            Don

            Comment


              #7
              Hi James,

              This is the one-liner I use to set the dim level on Leviton z-wave dimmers.

              Code:
              hs.CAPIControlHandler(hs.CAPIGetSingleControl(targetDev,false,targetDim,false,true))
              targetDim is a string with the value you want to set.

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

              Comment


                #8
                Yowser!

                Guys - first thank you for all the replies, much appreciated.

                Second, thank for nor taking my reply the wrong way - it did rather sound like I was 'dissing', which I wasn't

                I would have thought that HS might have made things easier with a stupid little routine like -

                PushDaButton("Device Name", "Button String")

                (Think I'll copyright the name....)

                Internally the events are doing just this when you select the 'set device value', so way not make it easy for people (Me!).

                Huge thanks and massively impressed with the forum (as always) - ALWAYS get some good ideas.

                Finally vasrc, yes it worked (stop looking so smug ).

                Comment


                  #9
                  Originally posted by vasrc View Post
                  . . . Everyone that's scripting HS3 has felt the CAPI "pain", but it goes away quickly . . .
                  'Must disagree. I still feel the pain.

                  Comment


                    #10
                    Probably not enough alcohol then

                    Z

                    Comment


                      #11
                      This seems to be exactly what I want...

                      Just scribbled this down and it seems too simple, but works perfectly!

                      This is a simple routine that seems to do things right (on/Off/Open/close etc.)

                      The parameter is just <device>=<operation>
                      (Operation is the label value.)

                      So something like -
                      Hall Lights=On
                      or
                      Hall Lights=Dim 25%

                      Odd thing is that HS seems to make one of these for EVERY value in a range, so there is a Dim 1%, Dim 2%, Dim 3%, etc. for a range!

                      Tell me what I've got wrong (if anything).

                      Public Function DeviceString(ByRef Line As String) As String
                      'Line is <Device>{=<Value>}

                      'return the value quickly if asked for
                      Dim l() As String = Split(Line,"="c)
                      If (l.Length() = 1) Then Return hs.DeviceStringByName(Line.Trim())

                      'dealing with control change from here
                      Dim d As Integer = hs.GetDeviceRefByName(trim(l(0)))
                      If (d <= 0) Then Return ""

                      Dim q As Object = hs.GetDeviceByRef(d)
                      'If (q Is Nothing) Then Return ""

                      Dim v As String = trim(l(1))
                      'If (v = "[VR]") Then v = hs.LastVoiceCommand

                      Dim u as string = UCase(v)
                      Dim cl() As CAPIControl = hs.CAPIGetControl(d)
                      For Each c As CAPIControl In cl
                      if (UCase(c.Label) = u) Then
                      'reset the string too (may have previous error), don't trigger
                      'hs.SetDeviceString(d, v, False)
                      'hs.SetDeviceValueByRef(d, c.ControValue, True) 'can now though
                      hs.CAPIControlHandler(c) 'press/move it!
                      Return hs.DeviceString(d)
                      End If
                      Next

                      Return hs.DeviceString(d)
                      End Function


                      (Sorry for the cross post as I put this in the thread mentioned by jon00. Just thought it was too good to ignore.)

                      Comment


                        #12
                        so if im reading this right, what used to be a simple 1 line script now needs a complex 20+ line script to do the same thing?
                        detail of setup in profile. Link to videos of my projects there as well. Over 300 scripts running every min and counting

                        Comment


                          #13
                          Read Post#7
                          James is trying to do more than just controlling a device (hence the extra code)

                          Z

                          Comment


                            #14
                            Originally posted by sparkman View Post
                            Hi James,

                            This is the one-liner I use to set the dim level on Leviton z-wave dimmers.

                            Code:
                            hs.CAPIControlHandler(hs.CAPIGetSingleControl(targetDev,false,targetDim,false,true))
                            targetDim is a string with the value you want to set.

                            Cheers
                            Al
                            I am adding this note on this four year old posting to inform newcomers like myself that this one-liner solves the problem. I had spent several hours studying, fussing with, and trying to decode CAPIcontrols before trying the forum, so I am pleased to inform others that Sparkman's solution works perfectly ... first time, every time. on my Fibaro dimmers, which is good news given my rate of progress with GetControlEx, etc.

                            It might be worth adding that "targetDim" is in fact the label string, e.g., "Dim 14%".

                            Comment

                            Working...
                            X