|
11 | 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 | 12 | * for the specific language governing permissions and limitations under the License.
|
13 | 13 | *
|
| 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 |
14 | 17 | * Apr 05, 2019 Arn Burkhoff; ST V2.03 modify launchAppPackage allowing dynamic package name, if no parameter use
|
15 | 18 | * use input setting appPackage, otherwise log an error message
|
16 | 19 | * Apr 01, 2019 Arn Burkhoff; ST V2.02 Added cabability Audio Notification, coded playTrack for testing
|
@@ -63,7 +66,19 @@ metadata {
|
63 | 66 | command "alarm"
|
64 | 67 | command "playSound",["String"]
|
65 | 68 | 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 | + } |
67 | 82 | }
|
68 | 83 | preferences {
|
69 | 84 | input(name:"serverIP",type:"string",title:"Server IP Address",defaultValue:"",required:true)
|
@@ -162,6 +177,10 @@ metadata {
|
162 | 177 | {
|
163 | 178 | state "default", label:'Stop Sound', action:'stopSound'
|
164 | 179 | }
|
| 180 | + standardTile("stopTTS", "device.tone", inactiveLabel: false, decoration: "flat") |
| 181 | + { |
| 182 | + state "default", label:'Stop TTS', action:'stopTTS' |
| 183 | + } |
165 | 184 | standardTile("refresh", "device.tone", inactiveLabel: false, decoration: "flat")
|
166 | 185 | {
|
167 | 186 | state "default", label:'Screen Refresh', action:"refresh"
|
@@ -309,11 +328,25 @@ def loadStartURL() {
|
309 | 328 | logger(logprefix,"trace")
|
310 | 329 | sendCommandPost("cmd=loadStartURL")
|
311 | 330 | }
|
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 | + { |
313 | 334 | 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 | + |
317 | 350 | def setVolume(volumeLevel) {
|
318 | 351 | def logprefix = "[setVolume] "
|
319 | 352 | logger(logprefix+"volumeLevel:${volumeLevel}")
|
@@ -401,6 +434,26 @@ def stopSound()
|
401 | 434 | sendCommandPost("cmd=stopSound")
|
402 | 435 | }
|
403 | 436 |
|
| 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 | + |
404 | 457 | // *** [ Platform Determination Methods ] *************************************
|
405 | 458 | private isSmartThings()
|
406 | 459 | {
|
|
0 commit comments