Announcement

Collapse
No announcement yet.

Why doesn't this work?

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

  • Why doesn't this work?

    Code:
    Sub SetVol (ByVal Parms() As String)
        Dim theDevice As Double
            theDevice = hs.DeviceValueEx(463)
                Dim cc as HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(theDevice, True, "(value)", False, False)
                cc.ControlValue = 0
                Dim cr as HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)
    End Sub
    '----------------
    Error from Log
    Code:
     
    Running script C:\Program Files (x86)\HomeSeer HS3\scripts\Audio Zones.vb :Object of type 'System.String' cannot be converted to type 'System.String[]'.->Does entry point SetVol exist in script? at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast) at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr) at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig) at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Scheduler.clsRunVBNetScript.ExecuteScript()

    edited for more info.... This is supposed to run from a slider.
    I set it to run from a button and it ran fine.
    What's the difference?

  • #2
    Here is the event.
    Click image for larger version

Name:	setvol.PNG
Views:	146
Size:	45.1 KB
ID:	1313656

    Comment


    • #3
      I think you are defining your sub wrong
      Code:
      Sub SetVol (ByVal Parms() As String)
      it should be
      Code:
      Sub SetVol (ByVal Parms As String)

      Comment


      • #4
        Tried that. No difference.

        Comment


        • #5
          Then I usually comment out all lines but the first line and try to run the script. If it works gradually add one and one line just to see where the error is.

          Comment


          • #6
            Well, here's the crazy thing. It actually is working.
            Click image for larger version

Name:	volume.PNG
Views:	121
Size:	39.3 KB
ID:	1313745
            But it still throws the error.

            Comment


            • #7
              Where is VolSlide? That is the thing that is making an error.
              Edit: Is there more in the script that you are not showing?

              Comment


              • #8
                Just to update, I have been changing the script.
                This is what it is now:

                Code:
                Sub VolSlide (ByVal Parms() As Object)
                    Dim pParms As Short = CInt(Parms(0))
                    Dim theDevice As Double
                        theDevice = hs.DeviceValueEx(463)
                            Dim cc as HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(theDevice, True, "(value)", False, False)
                            cc.ControlValue = pParms
                            Dim cr as HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)
                            hs.writelog("Test", "This is the output: Zone= " & theDevice & " level= " & pParms)
                End Sub
                '----------------

                Comment


                • #9
                  What are the params sendt into the sub from the event? Blank?
                  If you are sending a value maybe you should change from ByVal Parms() As Object
                  to
                  ByVal param as string
                  and just do a
                  Dim pParms As Short = CInt(param)

                  Comment


                  • #10
                    It's coming from a slider. I read on here that it has to be object.
                    Is that not true?

                    Click image for larger version

Name:	slider.PNG
Views:	118
Size:	158.5 KB
ID:	1313751

                    Comment


                    • #11
                      The error says that it cannot convert a string value to an array of objects. So the slider passes its value as a string to your script. But your script want to convert that string.
                      You might as well try my suggestion.

                      Code:
                      Sub VolSlide (ByVal Param As String)
                      Dim pParms As Short = CInt(Param)
                      Dim theDevice As Double
                      theDevice = hs.DeviceValueEx(463)
                      Dim cc as HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(theDevice, True, "(value)", False, False)
                      cc.ControlValue = pParms
                      Dim cr as HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)
                      hs.writelog("Test", "This is the output: Zone= " & theDevice & " level= " & pParms)
                      End Sub
                      '----------------

                      Comment


                      • #12
                        I already tried it. Didn't run at all.

                        Comment


                        • #13
                          No error message at all?
                          Edit: And it was exactly as it is show?
                          Code:
                          Sub VolSlide (ByVal Param As String)
                          and not
                          Code:
                            
                           Sub VolSlide (ByVal Param() As String)
                          The key might be the parenthesis after Param

                          Comment


                          • #14
                            It threw the same error but did not continue running. Didn't write to the log in other words.
                            I'll try the above now.

                            Just noticed you didn't change anything in the last post so, yeah, doesn't work like that either.

                            Comment


                            • #15
                              There should not be a space after "Volslide". You're showing it as:
                              Code:
                               
                               Sub VolSlide (ByVal Param As String)
                              It should be:
                              Code:
                               
                               Sub VolSlide(ByVal Param As String)
                              Fred

                              HomeSeer Pro 3.0.0.478, HS3Touch, Zwave 3.0.1.252, Envisalink DSC 3.0.0.40, WeatherXML, Z-stick, HS phone, Way2Call

                              Comment

                              Working...
                              X