Announcement

Collapse
No announcement yet.

OK Capi!!! Help

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

    OK Capi!!! Help

    I am trying to create a script in HS3 which would have been a one liner in HS2 and cannot figure out how to do it.

    I have a event that fires a script, non working at this point, when the value of a virtual device changes. I would like the script to then trigger a z-wave device to the level of the value in the virtual device.

    Sounds like a simple thing to do, but how?

    Any help appreciated.
    sigpic
    A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

    #2
    HST's recommendation is you should use an event whenever possible. Can you use an event instead?

    Sent from my SCH-R970X using Tapatalk
    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


      #3
      Originally posted by rmasonjr View Post
      HST's recommendation is you should use an event whenever possible. Can you use an event instead?

      Sent from my SCH-R970X using Tapatalk
      Nope, because HS3 does not support simple commands like HS.Exec and so on.
      sigpic
      A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

      Comment


        #4
        Originally posted by Gogs View Post
        Nope, because HS3 does not support simple commands like HS.Exec and so on.
        Sure you can. Set up the event to turn on the device. Many one liners can be done via the action in HS3. You use "control a device".
        💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

        Comment


          #5
          Originally posted by Gogs View Post
          I am trying to create a script in HS3 which would have been a one liner in HS2 and cannot figure out how to do it.

          I have a event that fires a script, non working at this point, when the value of a virtual device changes. I would like the script to then trigger a z-wave device to the level of the value in the virtual device.

          Sounds like a simple thing to do, but how?

          Any help appreciated.
          Hi Gogs,

          Here's an example. You pass two parameters to it separated by a comma. The first the device ID of your virtual device, and the second is the device ID of your z-wave device.

          Cheers
          Al

          Code:
          Sub Main(ByVal Parms as String)
          
          	Dim ParmArray() as String
          	ParmArray = Parms.tostring.split(",")
          	dim targetDev1 as Integer = CInt(ParmArray(0))		'reference ID of the virtual device to use for value
          	dim targetDev2 as Integer = CInt(ParmArray(1))		'reference ID of the device of the z-wave device
          
          	Dim dev1Value As Double
          	dev1Value = hs.DeviceValue(targetDev1)
          
          	hs.CAPIControlHandler(hs.CAPIGetSingleControl(targetDev2, false, CStr(dev1Value), false, true))
          
          End Sub
          HS 4.2.8.0: 2134 Devices 1252 Events
          Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

          Comment


            #6
            Originally posted by Rupp View Post
            Sure you can. Set up the event to turn on the device. Many one liners can be done via the action in HS3. You use "control a device".
            Yes appreciate that Rupp, but I cannot, at least I think I cannot tell a device to dim to the value of another virtual device with one liners.

            Could be wrong of course.
            sigpic
            A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

            Comment


              #7
              Originally posted by sparkman View Post
              Hi Gogs,

              Here's an example. You pass two parameters to it separated by a comma. The first the device ID of your virtual device, and the second is the device ID of your z-wave device.

              Cheers
              Al

              Code:
              Sub Main(ByVal Parms as String)
              
                  Dim ParmArray() as String
                  ParmArray = Parms.tostring.split(",")
                  dim targetDev1 as Integer = CInt(ParmArray(0))        'reference ID of the virtual device to use for value
                  dim targetDev2 as Integer = CInt(ParmArray(1))        'reference ID of the device of the z-wave device
              
                  Dim dev1Value As Double
                  dev1Value = hs.DeviceValue(targetDev1)
              
                  hs.CAPIControlHandler(hs.CAPIGetSingleControl(targetDev2, false, CStr(dev1Value), false, true))
              
              End Sub
              Al, thanks for that bit of code, I will play with it tomorrow.

              Much appreciated.
              sigpic
              A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

              Comment


                #8
                Originally posted by Gogs View Post
                Al, thanks for that bit of code, I will play with it tomorrow.

                Much appreciated.
                You're welcome.

                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
                  Originally posted by Gogs View Post
                  Yes appreciate that Rupp, but I cannot, at least I think I cannot tell a device to dim to the value of another virtual device with one liners.

                  Could be wrong of course.
                  You can use the following one-liner to set the dim level of one device to the value of another. In this example device 72 is being set to the dim level of device 6. However, it will probably only work for dim levels (1 to 98) not "On", "Off", or "On Last Level". That is probably doable as a one liner, but it would be so complex and repetitive that a script would be a much better idea.

                  PHP Code:
                   &hs.CAPIControlHandler(hs.CAPIGetSingleControl(72FalseCStr(hs.DeviceValue(6)), FalseTrue)) 
                  This is the same as Sparkman's code, but consolidated into a single line.

                  Comment


                    #10
                    Hi Sparkman,

                    trying your script but receiving this error
                    Jan-02 16:57:37 Error Running script, script run or compile error in file: C:/Program Files/HomeSeer HS3/scripts/Desk Lamp.txt1006:Expected ')' in line 1 More info: Expected ')'
                    This is the modifications I made to the script.
                    Sub Main(ByVal Parms as String)
                    Dim ParmArray() as String
                    ParmArray = Parms.tostring.split(",")
                    dim targetDev1 as Integer = CInt(ParmArray(Q42)) 'reference ID of the virtual device to use for value
                    dim targetDev2 as Integer = CInt(ParmArray(R1)) 'reference ID of the device of the z-wave device
                    Dim dev1Value As Double
                    dev1Value = hs.DeviceValue(targetDev1)
                    hs.CAPIControlHandler(hs.CAPIGetSingleControl(targetDev2, false, CStr(dev1Value), false, true))
                    End Sub
                    I know I am being stupid, but once I get the first script working I can move on from there.
                    sigpic
                    A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

                    Comment


                      #11
                      Gogs,
                      This is a .net script and as such needs to be saved with a .vb extension rather than a .txt which is for vbscript scripts.
                      💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                      Comment


                        #12
                        Originally posted by Rupp View Post
                        Gogs,
                        This is a .net script and as such needs to be saved with a .vb extension rather than a .txt which is for vbscript scripts.
                        Ahh, thanks Rupp, now that was me being stupid.
                        sigpic
                        A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

                        Comment


                          #13
                          OK script running but now getting this error.
                          Jan-02 17:23:25 Error Compiling script C:\Program Files\HomeSeer HS3\scripts\Desk Lamp.vb: 'R1' is not declared. It may be inaccessible due to its protection level.
                          Jan-02 17:23:25 Error Compiling script C:\Program Files\HomeSeer HS3\scripts\Desk Lamp.vb: 'Q42' is not declared. It may be inaccessible due to its protection level.
                          Jan-02 17:23:24 Event Running script in background: C:/Program Files/HomeSeer HS3/scripts/Desk Lamp.vb
                          I take it the reference ID is not the house/unit code, then where do you find it?
                          sigpic
                          A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

                          Comment


                            #14
                            Originally posted by Gogs View Post
                            OK script running but now getting this error.I take it the reference ID is not the house/unit code, then where do you find it?
                            Hi Gordon,

                            Correct. If you go the device management page and then click on the advanced tab you will see it.

                            Cheers
                            Al

                            PS There are commands that'll work with the house/unit code so if you'd prefer to use those, I can adjust the script.
                            HS 4.2.8.0: 2134 Devices 1252 Events
                            Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

                            Comment


                              #15
                              Gogs,

                              You get the reference from clicking on the respective name link in the device management page.

                              You can also substitute the code as follows:

                              dim targetDev1 as Integer = CInt(ParmArray(hs.DeviceExistsAddressFull("Q42", False)))
                              dim targetDev2 as Integer = CInt(ParmArray(hs.DeviceExistsAddressFull("R1", False)))
                              Jon

                              Comment

                              Working...
                              X