From 1578c48440ca5de8d2a8b3594a1245b04b76eabc Mon Sep 17 00:00:00 2001 From: tslagle13 Date: Sun, 13 Mar 2016 17:04:15 -0700 Subject: [PATCH] Fix text-to-speech feature Refactor case statement so custom message works. Remove comment from input selection. --- .../speaker-notify-with-sound.groovy | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/smartapps/smartthings/speaker-notify-with-sound.src/speaker-notify-with-sound.groovy b/smartapps/smartthings/speaker-notify-with-sound.src/speaker-notify-with-sound.groovy index 30a6521..bb72b8a 100644 --- a/smartapps/smartthings/speaker-notify-with-sound.src/speaker-notify-with-sound.groovy +++ b/smartapps/smartthings/speaker-notify-with-sound.src/speaker-notify-with-sound.groovy @@ -76,7 +76,7 @@ def mainPage() { } section{ input "actionType", "enum", title: "Action?", required: true, defaultValue: "Bell 1", options: [ - //"Custom Message", + "Custom Message", "Bell 1", "Bell 2", "Dogs Barking", @@ -89,7 +89,7 @@ def mainPage() { "Someone is arriving", "Piano", "Lightsaber"] - //input "message","text",title:"Play this message", required:false, multiple: false + input "message","text",title:"Play this message", required:false, multiple: false } section { input "sonos", "capability.musicPlayer", title: "On this Speaker player", required: true @@ -408,13 +408,15 @@ private loadText() { case "Lightsaber": state.sound = [uri: "http://s3.amazonaws.com/smartapp-media/sonos/lightsaber.mp3", duration: "10"] break; - default: - /*if (message) { + case "Custom Message": + if (message) { state.sound = textToSpeech(message instanceof List ? message[0] : message) // not sure why this is (sometimes) needed) } else { state.sound = textToSpeech("You selected the custom message option but did not enter a message in the $app.label Smart App") - }*/ + } + break; + default: state.sound = [uri: "http://s3.amazonaws.com/smartapp-media/sonos/bell1.mp3", duration: "10"] break; }