Code by Scott שאול בן ישוע
Unverified Commit 20c62288 authored by Brian Lowrance's avatar Brian Lowrance Committed by GitHub
Browse files

P2.0.2

* Corrected major issues with time based events
* Each child event now calls sendTalk() instead of direct calling parent.Talk() for further analysis
* Added error detection to processPhraseTokens() to help detect invalid user input (logged in parent logs, error announced verbally)..  ie: if someone actually uses %weathercurrent(00000)% instead of using a proper zipcode in place of 00000.
* Corrected an issue when calling %description% from Talk Now.
* Corrected an issue with non-zip code locations in weather phrase tokens/variables.
** ie: %weathercurrent(France/Paris)% was saying this phrase instead of translating it. The issue was phrase casing.
parent 8b7b85cb
......@@ -5,9 +5,9 @@ definition(
description: "Let's talk about mode changes, switches, motions, and so on.",
category: "Fun & Social",
singleInstance: true,
iconUrl: "http://lowrance.cc/ST/icons/BigTalker-2.0.1.png",
iconX2Url: "http://lowrance.cc/ST/icons/BigTalker@2x-2.0.1.png",
iconX3Url: "http://lowrance.cc/ST/icons/BigTalker@2x-2.0.1.png")
iconUrl: "http://lowrance.cc/ST/icons/BigTalker-BetaVersion.png",
iconX2Url: "http://lowrance.cc/ST/icons/BigTalker@2x-BetaVersion.png",
iconX3Url: "http://lowrance.cc/ST/icons/BigTalker@2x-BetaVersion.png")
preferences {
page(name: "pageStart")
......@@ -1821,7 +1821,7 @@ def pageTalkNow(){
myTalkNowResume = (myTalkNowResume == "") ? settings.resumeAudio : true //use global setting if TalkNow is not set
if (settings?.talkNowResume == null) {mytalkNowResume = true} //default to true if not set.
}
def customevent = [displayName: 'BigTalker:TalkNow', name: 'TalkNow', value: 'TalkNow']
def customevent = [displayName: 'BigTalker:TalkNow', name: 'TalkNow', value: 'TalkNow', descriptionText: "Talk Now"]
def myVolume = getDesiredVolume(settings?.talkNowVolume)
def myVoice = getMyVoice(settings.talkNowVoice)
//def myVoice = (!(talkNowVoice == null || talkNowVoice == "")) ? talkNowVoice : (settings?.speechVoice ? settings.speechVoice : "Sallie(en-us)")
......@@ -2012,6 +2012,7 @@ def initialize() {
}
def processPhraseVariables(appname, phrase, evt){
try {
def zipCode = location.zipCode
def mp3Url = ""
if (phrase.toLowerCase().contains("%mp3(")) {
......@@ -2077,7 +2078,7 @@ def processPhraseVariables(appname, phrase, evt){
def phraseZipEnd = (phrase.toLowerCase().indexOf(")%"))
zipCode = phrase.substring(phraseZipStart, phraseZipEnd)
LOGDEBUG("Custom zipCode: ${zipCode}")
phrase = phrase.toLowerCase().replace("%weathercurrent(${zipCode})%", getWeather("current", zipCode))
phrase = phrase.toLowerCase().replace("%weathercurrent(${zipCode.toLowerCase()})%", getWeather("current", zipCode.toLowerCase()))
phrase = adjustWeatherPhrase(phrase.toLowerCase())
} else {
phrase = "Custom Zip Code format error in request for current weather"
......@@ -2089,7 +2090,7 @@ def processPhraseVariables(appname, phrase, evt){
def phraseZipEnd = (phrase.toLowerCase().indexOf(")%"))
zipCode = phrase.substring(phraseZipStart, phraseZipEnd)
LOGDEBUG("Custom zipCode: ${zipCode}")
phrase = phrase.toLowerCase().replace("%weathertoday(${zipCode})%", getWeather("today", zipCode))
phrase = phrase.toLowerCase().replace("%weathertoday(${zipCode.toLowerCase()})%", getWeather("today", zipCode.toLowerCase()))
phrase = adjustWeatherPhrase(phrase.toLowerCase())
} else {
phrase = "Custom Zip Code format error in request for today's weather"
......@@ -2101,7 +2102,7 @@ def processPhraseVariables(appname, phrase, evt){
def phraseZipEnd = (phrase.toLowerCase().indexOf(")%"))
zipCode = phrase.substring(phraseZipStart, phraseZipEnd)
LOGDEBUG("Custom zipCode: ${zipCode}")
phrase = phrase.toLowerCase().replace("%weathertonight(${zipCode})%", getWeather("tonight", zipCode))
phrase = phrase.toLowerCase().replace("%weathertonight(${zipCode.toLowerCase()})%", getWeather("tonight", zipCode.toLowerCase()))
phrase = adjustWeatherPhrase(phrase)
} else {
phrase = "Custom Zip Code format error in request for tonight's weather"
......@@ -2113,7 +2114,7 @@ def processPhraseVariables(appname, phrase, evt){
def phraseZipEnd = (phrase.toLowerCase().indexOf(")%"))
zipCode = phrase.substring(phraseZipStart, phraseZipEnd)
LOGDEBUG("Custom zipCode: ${zipCode}")
phrase = phrase.toLowerCase().replace("%weathertomorrow(${zipCode})%", getWeather("tomorrow", zipCode))
phrase = phrase.toLowerCase().replace("%weathertomorrow(${zipCode.toLowerCase()})%", getWeather("tomorrow", zipCode.toLowerCase()))
phrase = adjustWeatherPhrase(phrase)
} else {
phrase = "Custom ZipCode format error in request for tomorrow's weather"
......@@ -2156,10 +2157,15 @@ def processPhraseVariables(appname, phrase, evt){
phrase=phrase.replace("%date%",(new Date().format( 'MMMM dd' )))
}
if (phrase.contains("%day%")) {
phrase=phrase.replace("%day%",(new Date().format( 'EEEE' )))
phrase=phrase.replace("%day%",(new Date().format('EEEE',location.timeZone)))
}
if (phrase.contains("%")) { phrase = phrase.replace("%"," percent ") }
return phrase
} catch(ex) {
LOGTRACE("There was a problem processing your desired phrase: ${phrase}. ${ex}")
phrase = "Sorry, there was a problem processing your desired BigTalker phrase token."
return phrase
}
}
def addPersonalityToPhrase(phrase, evt){
......@@ -2275,6 +2281,7 @@ def adjustWeatherPhrase(phraseIn){
phraseOut = phraseOut.replace(" WSW ", " West Southwest ")
phraseOut = phraseOut.replace(" MPH", " Miles Per Hour")
phraseOut = phraseOut.replace(" MM)", " Milimeters ")
LOGDEBUG ("Adjust Weather: In=${phraseIn} Out=${phraseOut}")
return phraseOut
}
......@@ -2295,7 +2302,7 @@ def Talk(appname, phrase, customSpeechDevice, volume, resume, personality, voice
def smartAppSpeechDevice = false
def playAudioFile = false
def spoke = false
LOGDEBUG ("TALK(app=${appname},customdevice=${customSpeechDevice},volume=${volume},resume=${resume},personality=${personality},myDelay=${myDelay}, voice=${myVoice},evt=${evt},phrase=${phrase})")
LOGDEBUG ("TALK(app=${appname},customdevice=${customSpeechDevice},volume=${volume},resume=${resume},personality=${personality},myDelay=${myDelay},voice=${myVoice},evt=${evt},phrase=${phrase})")
if ((phrase?.toLowerCase())?.contains("%askalexa%")) {smartAppSpeechDevice = true}
if (!(phrase == null) && !(phrase == "")) {
phrase = processPhraseVariables(appname, phrase, evt)
......@@ -2531,7 +2538,7 @@ def Talk(appname, phrase, customSpeechDevice, volume, resume, personality, voice
}// if (state.speechDeviceType=="capability.musicPlayer")
if ((state.speechDeviceType == "capability.speechSynthesis") && (!( phrase==null ) && !(phrase==""))){
//capability.speechSynthesis is in use
if (!(settings.speechDeviceDefault == null) || !(customSpeechDevice == null)) {
if (!(settings?.speechDeviceDefault == null) || !(customSpeechDevice == null)) {
LOGTRACE("TALK(${appname}.${evt.name}) |sS| >> ${phrase}")
if (!(customSpeechDevice == null)) {
currentSpeechDevices = customSpeechDevice
......@@ -2570,6 +2577,7 @@ def Talk(appname, phrase, customSpeechDevice, volume, resume, personality, voice
LOGTRACE("TALK(${appname}.${evt.name}) |sA| Sent to another smartApp.")
}
}
phrase = ""
}//Talk()
def timeAllowed(devicetype,index){
......@@ -3544,5 +3552,5 @@ def LOGERROR(txt){
}
def setAppVersion(){
state.appversion = "P2.0.1"
state.appversion = "P2.0.2"
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment