Skip to content

Commit 05d9c90

Browse files
committed
Add settings commands
1 parent fe7ffce commit 05d9c90

File tree

1 file changed

+58
-5
lines changed

1 file changed

+58
-5
lines changed

devicetypes/gvncampbell/fully-kiosk-browser-controller.src/fully-kiosk-browser-controller.groovy

+58-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
1212
* for the specific language governing permissions and limitations under the License.
1313
*
14+
* Mar 03, 2020 Arn Burkhoff; ST V2.05 Port commands Added setBooleanSetting, setStringSetting from HE
15+
* Feb 19, 2020 Arn Burkhoff; ST V2.04 add support for new sendTextToSpeech queue parameter
16+
* Feb 15, 2020 Arn Burkhoff; ST V2.04 add support for SSML adjustments, new Fully stopTextToSpeach command
1417
* Apr 05, 2019 Arn Burkhoff; ST V2.03 modify launchAppPackage allowing dynamic package name, if no parameter use
1518
* use input setting appPackage, otherwise log an error message
1619
* Apr 01, 2019 Arn Burkhoff; ST V2.02 Added cabability Audio Notification, coded playTrack for testing
@@ -63,7 +66,19 @@ metadata {
6366
command "alarm"
6467
command "playSound",["String"]
6568
command "stopSound"
66-
69+
command "stopTTS"
70+
if (isSmartThings())
71+
{
72+
command "setBooleanSetting",["String","String"]
73+
command "setStringSetting",["String","String"]
74+
}
75+
else
76+
{
77+
command "setBooleanSetting",[[name:"Key*",type:"STRING",description:"The key value associated with the setting to be updated."],
78+
[name:"Value*:",type:"ENUM",constraints:["true","false"],desciption:"The setting to be applied."]]
79+
command "setStringSetting",[[name:"Key*",type:"STRING",description:"The key value associated with the setting to be updated."],
80+
[name:"Value*:",type:"STRING",desciption:"The setting to be applied."]]
81+
}
6782
}
6883
preferences {
6984
input(name:"serverIP",type:"string",title:"Server IP Address",defaultValue:"",required:true)
@@ -162,6 +177,10 @@ metadata {
162177
{
163178
state "default", label:'Stop Sound', action:'stopSound'
164179
}
180+
standardTile("stopTTS", "device.tone", inactiveLabel: false, decoration: "flat")
181+
{
182+
state "default", label:'Stop TTS', action:'stopTTS'
183+
}
165184
standardTile("refresh", "device.tone", inactiveLabel: false, decoration: "flat")
166185
{
167186
state "default", label:'Screen Refresh', action:"refresh"
@@ -309,11 +328,25 @@ def loadStartURL() {
309328
logger(logprefix,"trace")
310329
sendCommandPost("cmd=loadStartURL")
311330
}
312-
def speak(text="Fully Kiosk TTS Device Handler") {
331+
332+
def speak(text='!{speak}Fully Kiosk {break time="2000ms"/} TTS Device Handler{/speak}')
333+
{
313334
def logprefix = "[speak] "
314-
logger(logprefix+"text:${text}","trace")
315-
sendCommandPost("cmd=textToSpeech&text=${java.net.URLEncoder.encode(text, "UTF-8")}")
316-
}
335+
logger(logprefix+"text:${text}","info")
336+
def wktext=text.replaceAll('[{]','<')
337+
wktext=wktext.replaceAll('[}]','>')
338+
if (wktext.startsWith("!"))
339+
{
340+
sendCommandPost("cmd=textToSpeech&queue=0&text=${java.net.URLEncoder.encode(wktext.substring(1), "UTF-8")}")
341+
}
342+
else
343+
{
344+
sendCommandPost("cmd=textToSpeech&text=${java.net.URLEncoder.encode(wktext, "UTF-8")}")
345+
}
346+
// def sound = textToSpeech(wktext) //currently used in Hubitat version cannot make it work with embedded SSML in ST
347+
// playSound(sound.uri)
348+
}
349+
317350
def setVolume(volumeLevel) {
318351
def logprefix = "[setVolume] "
319352
logger(logprefix+"volumeLevel:${volumeLevel}")
@@ -401,6 +434,26 @@ def stopSound()
401434
sendCommandPost("cmd=stopSound")
402435
}
403436

437+
def stopTTS()
438+
{
439+
// Terminates currently speaking TTS message, and purges the message queue
440+
def logprefix = "[stopTTS] "
441+
logger(logprefix,"trace")
442+
sendCommandPost("cmd=stopTextToSpeech")
443+
}
444+
445+
def setBooleanSetting(key,value) {
446+
def logprefix = "[setBooleanSetting] "
447+
logger(logprefix+"key,value: ${key},${value}","trace")
448+
sendCommandPost("cmd=setBooleanSetting&key=${key}&value=${value}")
449+
}
450+
def setStringSetting(key,value) {
451+
def logprefix = "[setBooleanSetting] "
452+
logger(logprefix+"key,value: ${key},${value}","trace")
453+
sendCommandPost("cmd=setBooleanSetting&key=${key}&value=${java.net.URLEncoder.encode(value,"UTF-8")}")
454+
}
455+
456+
404457
// *** [ Platform Determination Methods ] *************************************
405458
private isSmartThings()
406459
{

0 commit comments

Comments
 (0)