Announcement

Collapse
No announcement yet.

OK Capi!!! Help

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

    #16
    Thanks Guy's for all your help, I think I am getting there; slowly.

    Now have an error, which I used to get in the old HS2 days
    Jan-02 18:07:20 Error 1 Running script C:\Program Files\HomeSeer HS3\scripts\Desk Lamp.vb :Exception has been thrown by the target of an invocation.Index was outside the bounds of the array.
    Jan-02 18:07:20 Event Running script in background: C:/Program Files/HomeSeer HS3/scripts/Desk Lamp.vb Jan-02 18:07:20 Event Event Trigger "Lighting Study Desk Lamp"
    Hmmm
    sigpic
    A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

    Comment


      #17
      Can you post your complete script and a screen shot of the event that you're using to call it?

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

      Comment


        #18
        The Script is:[quote}Sub Main(ByVal Parms as String)
        Dim ParmArray() as String
        ParmArray = Parms.tostring.split(",")
        dim targetDev1 as Integer = CInt(ParmArray(7)) 'reference ID of the virtual device to use for value
        dim targetDev2 as Integer = CInt(ParmArray(6)) '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[/quote]

        Screen shot:
        sigpic
        A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

        Comment


          #19
          Screen shot did not work, will try again.
          sigpic
          A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

          Comment


            #20
            Hi Gordon,

            Call the script as per my original post:

            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.
            Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	28.8 KB
ID:	1175825

            Also change the script back to using the "0" and the "1". That way it will use the parameters from the event that you are using and you can reuse the same script for multiple events (& devices). The first 4 lines in the script are used to read the parameters passed from the event and should not be modified.

            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
            Last edited by sparkman; January 2, 2015, 03:16 PM.
            HS 4.2.8.0: 2134 Devices 1252 Events
            Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

            Comment


              #21
              Screen Shot:
              Attached Files
              sigpic
              A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

              Comment


                #22
                Hi Gordon,

                See the post above your last one on how to fix.

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

                Comment


                  #23
                  Originally posted by sparkman View Post
                  Hi Gordon,

                  See the post above your last one on how to fix.

                  Cheers
                  Al
                  Thanks, it is working perfectly.

                  Really appreciate the time you all have taken to guide me through this.
                  sigpic
                  A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

                  Comment


                    #24
                    Originally posted by Gogs View Post
                    Thanks, it is working perfectly.

                    Really appreciate the time you all have taken to guide me through this.
                    No worries, glad to help.

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

                    Comment


                      #25
                      Originally posted by sparkman View Post
                      No worries, glad to help.

                      Cheers
                      Al
                      Not sure if this is script problem or what, however when the device that is being monitored goes to off, value "0" the script is putting the lamps to 10%!
                      sigpic
                      A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

                      Comment


                        #26
                        See if this works for you.

                        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)
                        
                        	Select Case dev1Value
                        		Case 100
                        		' Device ON
                        		hs.CAPIControlHandler(hs.CAPIGetSingleControl(targetDev2,true ,"on",false,true))
                        		Case 0
                        		' Device OFF
                        		hs.CAPIControlHandler(hs.CAPIGetSingleControl(targetDev2,true ,"off",false,true))
                        		Case Else
                        		' Device Dim
                        		hs.CAPIControlHandler(hs.CAPIGetSingleControl(targetDev2, false, CStr(dev1Value), false, true))
                        	End Select
                        
                        End Sub
                        Last edited by sparkman; January 2, 2015, 04:23 PM.
                        HS 4.2.8.0: 2134 Devices 1252 Events
                        Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

                        Comment


                          #27
                          Originally posted by sparkman
                          Hi Gordon,

                          Try changing the last true to false:

                          Code:
                          hs.CAPIControlHandler(hs.CAPIGetSingleControl(targetDev2, false, CStr(dev1Value), false, false))
                          Based on your original message I had interpreted it like the virtual device would only contain dim values. If it can contain an On or Off as well, then I can adjust the script to account for those possibilities. What is the value shown for a On? 99, 100 or 255?

                          Cheers
                          Al
                          The On value is 100 the off is 0
                          sigpic
                          A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

                          Comment


                            #28
                            Originally posted by sparkman
                            ok, the script in my previous post has been updated to account for an on value of 100. Let me know if it works for you.

                            Cheers
                            Al
                            OK I have changed the last true/false back to true an changed the value from 99 to 100, guess what, it works perfectly.

                            Thank you Sir, I now have a true interface between HS2 and HS3 courtesy of your script and Jon00's connect programme.

                            Although HS2 is still the Master, through time HS3 may become the Master.

                            Many thanks for your time. If you do not mind I will post a link into Jon00's connect script to this thread as to how to get it working. Perhaps you would like to delete the trial scripts.

                            Once again, Thank You.
                            sigpic
                            A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

                            Comment


                              #29
                              Originally posted by Gogs View Post
                              OK I have changed the last true/false back to true an changed the value from 99 to 100, guess what, it works perfectly.

                              Thank you Sir, I now have a true interface between HS2 and HS3 courtesy of your script and Jon00's connect programme.

                              Although HS2 is still the Master, through time HS3 may become the Master.

                              Many thanks for your time. If you do not mind I will post a link into Jon00's connect script to this thread as to how to get it working. Perhaps you would like to delete the trial scripts.

                              Once again, Thank You.
                              Great to hear and you're very welcome. I don't mind the link and will see what posts I can delete.

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

                              Comment


                                #30
                                Originally posted by sparkman View Post
                                Great to hear and you're very welcome. I don't mind the link and will see what posts I can delete.

                                Cheers
                                Al
                                Thanks Mate, and thanks again for your time.
                                sigpic
                                A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

                                Comment

                                Working...
                                X