Nice catch. That might be the ticket.
Announcement
Collapse
No announcement yet.
Why doesn't this work?
Collapse
X
-
Are you running the script from HsTouch ? If so try first to run the script from the event with a parameter. When that works try again with HSTouch. I suspect that the parameter you are giving in HsTouch is not correct. You are possibly missing a property for the slider. AduioZoneSourceVolSlider.Value or something.
Comment
-
Guest
Note that there is a big difference when calling scripts with a parameter between HSTouch and directly from an event. In an HS event, the parameters are passed as one single string. From HSTouch, they are passed as an array of strings (even when there is only one parameter). So accomadating one side will cause a run time error when running from the other, unless you handle it properly. And this is why you normally see recomended that the procedure declare be: "Sub Main(parms As Object)" since an object can be a single string or an array of strings (or even other things). This makes things complicated when a script can be called from an event or HSTouch. You can use the following code to handle both sides though, assuming only one input string:Code:Sub Main(parms As Object) Dim parm As String If parms.GetType().ToString = "System.String" Then parm = parms.ToString() Else parm = parms(0).ToString() End If ' Now use parm as your input variable...
- Likes 1
Comment
-
Guest
-
Still not getting it....
Can you put that together with this so I see what you mean?
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
-
Guest
Try:
Code:Sub VolSlide(parms As Object) Dim parm As String If parms.GetType().ToString = "System.String" Then parm = parms.ToString() Else parm = parms(0).ToString() End If Dim pParms As Short = CInt(parm) 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
-
That's working!
Just one question on how it's working though.
It would work the "other" way but it would throw that error every time. Now, no error but for some reason it sets the level to 0 before every move.
Code:[TABLE="cellspacing: 0"] [TR] [TD="colspan: 1, align: left"][COLOR=#000000]Jul-02 5:40:05 PM[/COLOR][/TD] [TD="colspan: 1, align: left"][COLOR=#000000] [/COLOR][/TD] [TD="colspan: 3, align: left"][COLOR=#000000]Test[/COLOR][/TD] [TD="colspan: 8, align: left"][COLOR=#000000]This is the output: Zone= 358 level= 53[/COLOR][/TD] [/TR] [/TABLE] [TABLE="cellspacing: 0"] [TR] [TD="colspan: 1, align: left"][COLOR=#000000]Jul-02 5:40:05 PM[/COLOR][/TD] [TD="colspan: 1, align: left"][COLOR=#000000] [/COLOR][/TD] [TD="colspan: 3, align: left"][COLOR=#000000]Device Control[/COLOR][/TD] [TD="colspan: 8, align: left"][COLOR=#000000]Device: Virtual Virtual AudioZoneVolume to 53 (53) by/from: CAPI Control Handler[/COLOR][/TD] [/TR] [/TABLE] [TABLE="cellspacing: 0"] [TR] [TD="colspan: 1, align: left"][COLOR=#000000]Jul-02 5:40:05 PM[/COLOR][/TD] [TD="colspan: 1, align: left"][COLOR=#000000] [/COLOR][/TD] [TD="colspan: 3, align: left"][COLOR=#000000]Device Control[/COLOR][/TD] [TD="colspan: 8, align: left"][COLOR=#000000]Device: Virtual Virtual AudioZoneVolume to 0 (53) by/from: CAPI Control Handler[/COLOR][/TD] [/TR] [/TABLE] [TABLE="cellspacing: 0"] [TR] [TD="colspan: 1, align: left"][COLOR=#000000]Jul-02 5:40:05 PM[/COLOR][/TD] [TD="colspan: 1, align: left"][COLOR=#000000] [/COLOR][/TD] [TD="colspan: 3, align: left"][COLOR=#000000]Test[/COLOR][/TD] [TD="colspan: 8, align: left"][COLOR=#000000]This is the output: Zone= 358 level= 53[/COLOR][/TD] [/TR] [/TABLE] [TABLE="cellspacing: 0"] [TR] [TD="colspan: 1, align: left"][COLOR=#000000]Jul-02 5:40:04 PM[/COLOR][/TD] [TD="colspan: 1, align: left"][COLOR=#000000] [/COLOR][/TD] [TD="colspan: 3, align: left"][COLOR=#000000]Device Control[/COLOR][/TD] [TD="colspan: 8, align: left"][COLOR=#000000]Device: Virtual Virtual AudioZoneVolume to 53 (53) by/from: CAPI Control Handler[/COLOR][/TD] [/TR] [/TABLE] [TABLE="cellspacing: 0"] [TR] [TD="colspan: 1, align: left"][COLOR=#000000]Jul-02 5:40:04 PM[/COLOR][/TD] [TD="colspan: 1, align: left"][COLOR=#000000] [/COLOR][/TD] [TD="colspan: 3, align: left"][COLOR=#000000]Device Control[/COLOR][/TD] [TD="colspan: 8, align: left"][COLOR=#000000]Device: Virtual Virtual AudioZoneVolume to 0 (53) by/from: CAPI Control Handler[/COLOR][/TD] [/TR] [/TABLE] [TABLE="cellspacing: 0"] [TR] [TD="colspan: 1, align: left"][COLOR=#000000]Jul-02 5:40:04 PM[/COLOR][/TD] [TD="colspan: 1, align: left"][COLOR=#000000] [/COLOR][/TD] [TD="colspan: 3, align: left"][COLOR=#000000]Test[/COLOR][/TD] [TD="colspan: 8, align: left"][COLOR=#000000]This is the output: Zone= 358 level= 50[/COLOR][/TD] [/TR] [/TABLE] [TABLE="cellspacing: 0"] [TR] [TD="colspan: 1, align: left"][COLOR=#000000]Jul-02 5:40:04 PM[/COLOR][/TD] [TD="colspan: 1, align: left"][COLOR=#000000] [/COLOR][/TD] [TD="colspan: 3, align: left"][COLOR=#000000]Device Control[/COLOR][/TD] [TD="colspan: 8, align: left"][COLOR=#000000]Device: Virtual Virtual AudioZoneVolume to 50 (50) by/from: CAPI Control Handler[/COLOR][/TD] [/TR] [/TABLE] [TABLE="cellspacing: 0"] [TR] [TD="colspan: 1, align: left"][COLOR=#000000]Jul-02 5:40:04 PM[/COLOR][/TD] [TD="colspan: 1, align: left"][COLOR=#000000] [/COLOR][/TD] [TD="colspan: 3, align: left"][COLOR=#000000]Device Control[/COLOR][/TD] [TD="colspan: 8, align: left"][COLOR=#000000]Device: Virtual Virtual AudioZoneVolume to 0 (50) by/from: CAPI Control Handler[/COLOR][/TD] [/TR] [/TABLE]
Thanks for the help!!
Comment
-
Guest
Originally posted by Demusman View PostThat's working!
Just one question on how it's working though.
It would work the "other" way but it would throw that error every time. Now, no error but for some reason it sets the level to 0 before every move.
I haven't actually used this with live music yet so I don't know if the volume is actually going to 0 or not but is that the way the sliders work?
Thanks for the help!!
You are using the CAPI control stuff incorrectly as well. You actually need to find the control entry that has the desired value, and then set the virtual device to that.
This is the code I use to set a Virtual Switch to a particular value (I search for the desired control based on the label, but you can modify it to search on value instead):
Code:Private Function SetVirtual(ByVal sDevName As String, ByVal sLabel As String) As Integer Dim iRef As Integer = hs.GetDeviceRefByName(sDevName) Dim CS As ICAPIStatus = hs.CAPIGetStatus(iRef) For Each objCAPIControl As CAPIControl In hs.CAPIGetControl(iRef) If LCase(objCAPIControl.Label) = LCase(sLabel) Then hs.WriteLog("SetVirtual", sDevName + ": " + sLabel) hs.CAPIControlHandler(objCAPIControl) Return 0 End If Next hs.WriteLog("error", sDevName + ": " + sLabel) Return 1 End Function
Comment
-
I got the CAPI commands right from tenScriptaid. If it works, I think I'm ok with for now. Still too new to scripting to know any better.
How about this, Is there a way to track status from a script?
I have the volume sync'd but if I change the volume from another device, the volume label on clients doesn't update until I leave the screen and go back to it.
Comment
Comment