Hello
So I am making a script which is for tts, as opposed to the proper linkgroup method, which is due to response times and that I don't use linking.
What I am trying to achieve: I would like to call an event action.
The simple way is creating several events like the attached, then put the hs.TriggerEvent line in - but I don't want to do this, as I would like it all within this vb script.
There is no device in the devices that allow me to pair, so I can't use CAPI ( at least I don't think I can).
Is there a way I can put the green THEN SONOS ACTION into my script?
Thank you
Chris
Code:
So I am making a script which is for tts, as opposed to the proper linkgroup method, which is due to response times and that I don't use linking.
What I am trying to achieve: I would like to call an event action.
The simple way is creating several events like the attached, then put the hs.TriggerEvent line in - but I don't want to do this, as I would like it all within this vb script.
There is no device in the devices that allow me to pair, so I can't use CAPI ( at least I don't think I can).
Is there a way I can put the green THEN SONOS ACTION into my script?
Thank you
Chris
Code:
Code:
'---------------------------------- ' SONOS Script by Chris Coles ' Note this does not UNLINK/LINK Groups, LINKGROUPS should be used for this '---------------------------------- '--------------------------------------------------------------------------- ' Public Variables '--------------------------------------------------------------------------- '--------------------------------------------------------------------------- ' Main Method '--------------------------------------------------------------------------- Sub Main(parm As Object) End Sub '--------------------------------------------------------------------------- ' Speak Method '--------------------------------------------------------------------------- Public Sub speakSomething(ByVal Parms As Object) Dim parmArray() As String = Parms.ToString.Split("|") Dim setSpeakerName As String = parmArray(0) Dim setVolume As Integer = parmArray(1) Dim setTTS As String = parmArray(2) Dim speakerNameID As Integer Dim speakerVolumeID As Integer Dim getOriginalVolume As Integer Select Case setSpeakerName Case "upstairs" speakerNameID = -1 speakerVolumeID = -1 Case "bathroom" speakerNameID = 11 speakerVolumeID = 77 Case "ensuite" speakerNameID = 1369 speakerVolumeID = 1379 Case "masterbedroom" speakerNameID = 8 speakerVolumeID = 22 Case "guestbedroom" speakerNameID = -1 speakerVolumeID = -1 Case "office" speakerNameID = -1 speakerVolumeID = -1 Case "livingroom" speakerNameID = 10 speakerVolumeID = 59 Case "frontroom" speakerNameID = 292 speakerVolumeID = 321 Case "downstairs" speakerNameID = 293 speakerVolumeID = 339 Case "frontdoor" speakerNameID = 12 speakerVolumeID = 95 Case "frontdoor" speakerNameID = 12 speakerVolumeID = 95 Case "kitchen" speakerNameID = -1 speakerVolumeID = -1 Case else hs.WriteLogEx("SONOS TTS", "Destination Speaker Incorrect", "#ff0000") End Select If speakerNameID >-1 Then ' Get Original Volume getOriginalVolume = hs.DeviceValueEx(speakerVolumeID) hs.WriteLog("SONOS TTS", "Speaker Number: " & speakerNameID & " has an original volume of: " & getOriginalVolume) ' Set Pause on Speaker hs.CAPIControlHandler(hs.CAPIGetSingleControl(speakerNameID,True,"Pause",False,False)) ' Set Speaker to New Volume Dim cc as HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(speakerNameID, True, "Volume (value)%", False, False) cc.ControlValue = setVolume Dim cr as HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc) ' Set Speaker to Line-In of Master Bedroom Connect Amp ' ????????????????????????????????????????????????????????????????????? ' ????????????????????????????????????????????????????????????????????? ' Set Resume on Speaker hs.CAPIControlHandler(hs.CAPIGetSingleControl(speakerNameID,True,"Play",False,False)) ' Speak TTS through 3.5mm Jack to Connect AMP LineIn Input hs.Speak(setTTS, True, "EAGLE54:DEFAULT") ' Set Speaker to Original Volume Dim cc as HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(speakerNameID, True, "Volume (value)%", False, False) cc.ControlValue = getOriginalVolume Dim cr as HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc) ' Set speakerNameNumber to stop hs.CAPIControlHandler(hs.CAPIGetSingleControl(speakerNameID,True,"Stop",False,False)) End If End Sub
Comment