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

Initial BigTalker2 Parent-App Release (2.0.0)

parent 6b0a3bd0
definition(
name: "BigTalker2",
namespace: "rayzurbock",
author: "rayzur@rayzurbock.com",
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.0.png",
iconX2Url: "http://lowrance.cc/ST/icons/BigTalker@2x-2.0.0.png",
iconX3Url: "http://lowrance.cc/ST/icons/BigTalker@2x-2.0.0.png")
preferences {
page(name: "pageStart")
page(name: "pageStatus")
page(name: "pageTalkNow")
page(name: "pageConfigureSpeechDeviceType")
page(name: "pageConfigureDefaults")
page(name: "pageHelpPhraseTokens")
//End preferences
}
def pageStart(){
state.childAppName = "BigTalker2-Child"
state.parentAppName = "BigTalker2"
state.namespace = "rayzurbock"
setAppVersion()
state.supportedVoices = ["Ivy(en-us)","Joanna(en-us)","Joey(en-us)","Justin(en-us)","Kendra(en-us)","Kimberly(en-us)","Salli(en-us)","Amy(en-gb)","Brian(en-gb)","Emma(en-gb)","Miguel(es-us)","Penelope(es-us)"]
if (checkConfig()) {
// Do nothing here, but run checkConfig()
}
dynamicPage(name: "pageStart", title: "Big Talker", install: false, uninstall: (app.getInstallationState() == "COMPLETE")){
section(){
LOGDEBUG("install state=${app.getInstallationState()}.")
def mydebug_pollnow = ""
if (!(state.configOK)) {
href "pageConfigureSpeechDeviceType", title:"Configure", description:"Tap to configure"
} else {
//V1Method href "pageConfigureEvents", title: "Configure Events", description: "Tap to configure events"
href "pageStatus", title:"Status", description:"Tap to view status"
href "pageConfigureDefaults", title: "Configure Defaults", description: "Tap to configure defaults"
href "pageTalkNow", title:"Talk Now", description:"Tap to setup talk now"
}
}
section("Event Groups") {}
section(){
def apps = getChildApps()?.sort{ it.label }
if (state.configOK) {
if (apps?.size() == 0) {
paragraph "You have not configured any event groups yet."
app(name: "BTEvt-", appName: state.childAppName, namespace: state.namespace, title: "Add Event Group", description: "Tap to configure event triggers", multiple: true, uninstall: false)
} else {
app(name: "BTEvt-", appName: state.childAppName, namespace: state.namespace, title: "Add Event Group", description: "Tap to configure event triggers", multiple: true, uninstall: false)
}
}
}
section(){
if ((settings?.debugmode == true) && (state.speechDeviceType == "capability.musicPlayer") && (settings?.resumePlay == true)) {
input name: "debug_pollnow", type: "bool", title: "DEBUG: Poll Now (simply toggle)", multiple: false, required: false, submitOnChange: true, defaultValue: false
if (!(settings.debug_pollnow == mydebug_pollnow)) { poll() }
}
}
section("About"){
def AboutApp = ""
AboutApp += 'Big Talker is a SmartApp that can make your house talk depending on various triggered events.\n\n'
AboutApp += 'Pair with a SmartThings compatible audio device such as Sonos, Ubi, LANnouncer, VLC Thing (running on your computer or Raspberry Pi), a DLNA device using the "Generic MediaRenderer" SmartApp/Device and/or AskAlexa SmartApp\n\n'
AboutApp += 'You can contribute to the development of this SmartApp by making a PayPal donation to rayzur@rayzurbock.com or visit http://rayzurbock.com/store\n\n'
if (!(state.appversion == null)){
AboutApp += "Big Talker ${state.appversion}\nhttp://www.github.com/rayzurbock\n"
} else {
AboutApp += 'Big Talker \nhttp://www.github.com/rayzurbock\n'
}
paragraph(AboutApp)
}
}
}
def pageStatus(){
//dynamicPage(name: "pageStatus", title: "Big Talker is configured as follows:", nextPage: "pageConfigure"){
dynamicPage(name: "pageStatus", title: "Big Talker is configured as follows:", install: false, uninstall: false){
String enabledDevices = ""
//BEGIN STATUS DEFAULTS
enabledDevices = "Speech Device Mode:\n"
enabledDevices += " "
if (state.speechDeviceType == "capability.musicPlayer") {
enabledDevices += "musicPlayer (Sonos, VLCThing, Generic DLNA)"
}
if (state.speechDeviceType == "capability.speechSynthesis") {
enabledDevices += "speechSynthesis (Ubi, LANnouncer)"
}
enabledDevices += "\n\n"
enabledDevices += "Default Speech Devices:\n"
enabledDevices += " "
settings.speechDeviceDefault?.each(){
enabledDevices += "${it.displayName},"
}
enabledDevices += "\n\n"
if (settings.speechVolume && state.speechDeviceType == "capability.musicPlayer") {
enabledDevices += "Adjust Volume To: ${settings.speechVolume}%"
enabledDevices += "\n\n"
}
if (state.speechDeviceType == "capability.musicPlayer") {
enabledDevices += "Default Resume Audio: ${settings?.resumePlay}"
enabledDevices += "\n\n"
}
enabledDevices += "Default Modes:\n"
enabledDevices += " "
settings.speechModesDefault.each(){
enabledDevices += "${it},"
}
if (settings.defaultStartTime) {
enabledDevices += "\n\n"
def defStartTime = getTimeFromDateString(settings.defaultStartTime, true)
def defEndTime = getTimeFromDateString(settings.defaultEndTime, true)
enabledDevices += "Default Allowed Talk Time:\n ${defStartTime} - ${defEndTime}"
}
enabledDevices += "\n\n"
enabledDevices += "Hub ZipCode* for Weather: ${location.zipCode}\n"
enabledDevices += "*SmartThings uses GPS to ZipCode conversion; May not be exact"
section ("Defaults:"){
//NEEDS DEVELOPMENT
paragraph enabledDevices
//paragraph "Nothing else is viewable at this time. I'm working on the best method to expose this data from the child apps in one location, if possible."
}
enabledDevices = ""
//END STATUS DEFAULTS
//BEGIN STATUS TIME SCHEDULED EVENTS GROUP 1
if (settings.timeSlotTime1){
enabledDevices += "AT: ${getTimeFromDateString(settings.timeSlotTime1, true)} \n"
enabledDevices += "ON: \n"
enabledDevices += " "
def i = 0
timeSlotDays1.each() {
enabledDevices += "${it},"
i += 1
if (i == 3) { enabledDevices += "\n " }
}
enabledDevices += "\n"
enabledDevices += "SAY: \n"
enabledDevices += " ${timeSlotOnTime1}\n"
if (settings.timeSlotSpeechDevice1) {
enabledDevices += "Custom Speech Device(s):\n"
enabledDevices += " "
settings.timeSlotSpeechDevice1.each() {
enabledDevices += "${it.displayName},"
enabledDevices += "\n\n"
}
}
if (state.speechDeviceType == "capability.musicPlayer") {
enabledDevices += "Resume Audio: ${(!(settings.timeSlotResumePlay1 == null)) ? settings.timeSlotResumePlay1 : settings.resumePlay}"
enabledDevices += "\n\n"
}
if (settings.timeSlotModes1) {
enabledDevices += "Custom mode(s):\n"
enabledDevices += " "
settings.timeSlotModes1.each() {
enabledDevices += "${it},"
}
}
if (!(enabledDevices == "")) {
section ("Time Schedule 1:"){
paragraph enabledDevices
}
}
enabledDevices = ""
}
//END STATUS TIME SCHEDULED EVENTS GROUP 1
//BEGIN STATUS TIME SCHEDULED EVENTS GROUP 2
if (settings.timeSlotTime2){
enabledDevices += "AT: ${getTimeFromDateString(settings.timeSlotTime2, true)} \n"
enabledDevices += "ON: \n"
enabledDevices += " "
def i = 0
timeSlotDays2.each() {
enabledDevices += "${it},"
i += 1
if (i == 3) { enabledDevices += "\n " }
}
enabledDevices += "\n"
enabledDevices += "SAY: \n"
enabledDevices += " ${timeSlotOnTime2}\n"
if (settings.timeSlotSpeechDevice2) {
enabledDevices += "Custom Speech Device(s):\n"
enabledDevices += " "
settings.timeSlotSpeechDevice2.each() {
enabledDevices += "${it.displayName},"
enabledDevices += "\n\n"
}
}
if (state.speechDeviceType == "capability.musicPlayer") {
enabledDevices += "Resume Audio: ${(!(settings.timeSlotResumePlay2 == null)) ? settings.timeSlotResumePlay2 : settings.resumePlay}"
enabledDevices += "\n\n"
}
if (settings.timeSlotModes2) {
enabledDevices += "Custom mode(s):\n"
enabledDevices += " "
settings.timeSlotModes2.each() {
enabledDevices += "${it},"
}
}
if (!(enabledDevices == "")) {
section ("Time Schedule 2:"){
paragraph enabledDevices
}
}
enabledDevices = ""
}
//END STATUS TIME SCHEDULED EVENTS GROUP 2
//BEGIN STATUS TIME SCHEDULED EVENTS GROUP 3
if (settings.timeSlotTime3){
enabledDevices += "AT: ${getTimeFromDateString(settings.timeSlotTime3, true)} \n"
enabledDevices += "ON: \n"
enabledDevices += " "
def i = 0
timeSlotDays3.each() {
enabledDevices += "${it},"
i += 1
if (i == 3) { enabledDevices += "\n " }
}
enabledDevices += "\n"
enabledDevices += "SAY: \n"
enabledDevices += " ${timeSlotOnTime3}\n"
if (settings.timeSlotSpeechDevice3) {
enabledDevices += "Custom Speech Device(s):\n"
enabledDevices += " "
settings.timeSlotSpeechDevice3.each() {
enabledDevices += "${it.displayName},"
enabledDevices += "\n\n"
}
}
if (state.speechDeviceType == "capability.musicPlayer") {
enabledDevices += "Resume Audio: ${(!(settings.timeSlotResumePlay3 == null)) ? settings.timeSlotResumePlay3 : settings.resumePlay}"
enabledDevices += "\n\n"
}
if (settings.timeSlotModes3) {
enabledDevices += "Custom mode(s):\n"
enabledDevices += " "
settings.timeSlotModes3.each() {
enabledDevices += "${it},"
}
}
if (!(enabledDevices == "")) {
section ("Time Schedule 3:"){
paragraph enabledDevices
}
}
enabledDevices = ""
}
//END STATUS TIME SCHEDULED EVENTS GROUP 3
//BEGIN STATUS CONFIG MOTION GROUP 1
if (settings.motionDeviceGroup1) {
enabledDevices += "Devices: \n"
enabledDevices += " "
settings.motionDeviceGroup1.each() {
enabledDevices += "${it.displayName},"
}
enabledDevices += "\n"
if (settings.motionTalkActive1) {
enabledDevices += "Say on active:\n ${settings.motionTalkActive1}\n\n"
}
if (settings.motionTalkInactive1) {
enabledDevices += "Say on inactive:\n ${settings.motionTalkInactive1}\n\n"
}
if (settings.motionSpeechDevice1) {
enabledDevices += "Custom Speech Device(s):\n"
enabledDevices += " "
settings.motionSpeechDevice1.each() {
enabledDevices += "${it.displayName},"
}
enabledDevices += "\n\n"
}
if (state.speechDeviceType == "capability.musicPlayer") {
enabledDevices += "Resume Audio: ${(!(settings.motionResumePlay1 == null)) ? settings.motionResumePlay1 : settings.resumePlay}"
enabledDevices += "\n\n"
}
if (settings.motionModes1) {
enabledDevices += "Custom mode(s):\n"
enabledDevices += " "
settings.motionModes1.each() {
enabledDevices += "${it},"
}
enabledDevices += "\n\n"
}
if (settings.motionStartTime1) {
def customStartTime = getTimeFromDateString(settings.motionStartTime1, true)
def customEndTime = getTimeFromDateString(settings.motionEndTime1, true)
enabledDevices += "Custom Allowed Talk Time:\n ${customStartTime} - ${customEndTime}"
customStartTime = ""
customEndTime = ""
}
if (!(enabledDevices == "")) {
section ("Motion Sensor Group 1:"){
paragraph enabledDevices
}
}
enabledDevices = ""
}
//END STATUS CONFIG MOTION GROUP 1
//BEGIN STATUS CONFIG MOTION GROUP 2
if (settings.motionDeviceGroup2) {
enabledDevices += "Devices: \n"
enabledDevices += " "
settings.motionDeviceGroup2.each() {
enabledDevices += "${it.displayName},"
}
enabledDevices += "\n"
if (settings.motionTalkActive2) {
enabledDevices += "Say on active:\n ${settings.motionTalkActive2}\n\n"
}
if (settings.motionTalkInactive2) {
enabledDevices += "Say on inactive:\n ${settings.motionTalkInactive2}\n\n"
}
if (settings.motionSpeechDevice2) {
enabledDevices += "Custom Speech Device(s):\n"
enabledDevices += " "
settings.motionSpeechDevice2.each() {
enabledDevices += "${it.displayName},"
}
enabledDevices += "\n\n"
}
if (state.speechDeviceType == "capability.musicPlayer") {
enabledDevices += "Resume Audio: ${(!(settings.motionResumePlay2 == null)) ? settings.motionResumePlay2 : settings.resumePlay}"
enabledDevices += "\n\n"
}
if (settings.motionModes2) {
enabledDevices += "Custom mode(s):\n"
enabledDevices += " "
settings.motionModes2.each() {
enabledDevices += "${it},"
}
enabledDevices += "\n\n"
}
if (settings.motionStartTime2) {
def customStartTime = getTimeFromDateString(settings.motionStartTime2, true)
def customEndTime = getTimeFromDateString(settings.motionEndTime2, true)
enabledDevices += "Custom Allowed Talk Time:\n ${customStartTime} - ${customEndTime}"
customStartTime = ""
customEndTime = ""
}
if (!(enabledDevices == "")) {
section ("Motion Sensor Group 2:"){
paragraph enabledDevices
}
}
enabledDevices = ""
}
//END STATUS CONFIG MOTION GROUP 2
//BEGIN STATUS CONFIG MOTION GROUP 3
if (settings.motionDeviceGroup3) {
enabledDevices += "Devices: \n"
enabledDevices += " "
settings.motionDeviceGroup3.each() {
enabledDevices += "${it.displayName},"
}
enabledDevices += "\n"
if (settings.motionTalkActive3) {
enabledDevices += "Say on active:\n ${settings.motionTalkActive3}\n\n"
}
if (settings.motionTalkInactive3) {
enabledDevices += "Say on inactive:\n ${settings.motionTalkInactive3}\n\n"
}
if (settings.motionSpeechDevice3) {
enabledDevices += "Custom Speech Device(s):\n"
enabledDevices += " "
settings.motionSpeechDevice3.each() {
enabledDevices += "${it.displayName},"
}
enabledDevices += "\n\n"
}
if (state.speechDeviceType == "capability.musicPlayer") {
enabledDevices += "Resume Audio: ${(!(settings.motionResumePlay3 == null)) ? settings.motionResumePlay3 : settings.resumePlay}"
enabledDevices += "\n\n"
}
if (settings.motionModes3) {
enabledDevices += "Custom mode(s):\n"
enabledDevices += " "
settings.motionModes3.each() {
enabledDevices += "${it},"
}
enabledDevices += "\n\n"
}
if (settings.motionStartTime3) {
def customStartTime = getTimeFromDateString(settings.motionStartTime3, true)
def customEndTime = getTimeFromDateString(settings.motionEndTime3, true)
enabledDevices += "Custom Allowed Talk Time:\n ${customStartTime} - ${customEndTime}"
customStartTime = ""
customEndTime = ""
}
if (!(enabledDevices == "")) {
section ("Motion Sensor Group 3:"){
paragraph enabledDevices
}
}
enabledDevices = ""
}
//END STATUS CONFIG MOTION GROUP 3
//BEGIN STATUS CONFIG SWITCH GROUP 1
if (settings.switchDeviceGroup1) {
enabledDevices += "Devices: \n"
enabledDevices += " "
settings.switchDeviceGroup1.each() {
enabledDevices += "${it.displayName},"
}
enabledDevices += "\n\n"
if (settings.switchTalkOn1) {
enabledDevices += "Say when switched ON:\n ${settings.switchTalkOn1}\n\n"
}
if (settings.switchTalkOff1) {
enabledDevices += "Say when switched OFF:\n ${settings.switchTalkOff1}\n\n"
}
if (settings.switchSpeechDevice1) {
enabledDevices += "Custom Speech Device(s):\n"
enabledDevices += " "
settings.switchSpeechDevice1.each() {
enabledDevices += "${it.displayName},"
}
enabledDevices += "\n\n"
}
if (state.speechDeviceType == "capability.musicPlayer") {
enabledDevices += "Resume Audio: ${(!(settings.switchResumePlay1 == null)) ? settings.switchResumePlay1 : settings.resumePlay}"
enabledDevices += "\n\n"
}
if (settings.switchModes1) {
enabledDevices += "Custom mode(s):\n"
enabledDevices += " "
settings.switchModes1.each() {
enabledDevices += "${it},"
}
enabledDevices += "\n\n"
}
if (settings.switchStartTime1) {
def customStartTime = getTimeFromDateString(settings.switchStartTime1, true)
def customEndTime = getTimeFromDateString(settings.switchEndTime1, true)
enabledDevices += "Custom Allowed Talk Time:\n ${customStartTime} - ${customEndTime}"
customStartTime = ""
customEndTime = ""
}
if (!(enabledDevices == "")) {
section ("Switch Group 1:"){
paragraph enabledDevices
}
}
enabledDevices = ""
}
//END STATUS CONFIG SWITCH GROUP 1
//BEGIN STATUS CONFIG SWITCH GROUP 2
if (settings.switchDeviceGroup2) {
enabledDevices += "Devices: \n"
enabledDevices += " "
settings.switchDeviceGroup2.each() {
enabledDevices += "${it.displayName},"
}
enabledDevices += "\n\n"
if (settings.switchTalkOn2) {
enabledDevices += "Say when switched ON:\n ${settings.switchTalkOn2}\n\n"
}
if (settings.switchTalkOff1) {
enabledDevices += "Say when switched OFF:\n ${settings.switchTalkOff2}\n\n"
}
if (settings.switchSpeechDevice2) {
enabledDevices += "Custom Speech Device(s):\n"
enabledDevices += " "
settings.switchSpeechDevice2.each() {
enabledDevices += "${it.displayName},"
}
enabledDevices += "\n\n"
}
if (state.speechDeviceType == "capability.musicPlayer") {
enabledDevices += "Resume Audio: ${(!(settings.switchResumePlay2 == null)) ? settings.switchResumePlay2 : settings.resumePlay}"
enabledDevices += "\n\n"
}
if (settings.switchModes2) {
enabledDevices += "Custom mode(s):\n"
enabledDevices += " "
settings.switchModes2.each() {
enabledDevices += "${it},"
}
enabledDevices += "\n\n"
}
if (settings.switchStartTime2) {
def customStartTime = getTimeFromDateString(settings.switchStartTime2, true)
def customEndTime = getTimeFromDateString(settings.switchEndTime2, true)
enabledDevices += "Custom Allowed Talk Time:\n ${customStartTime} - ${customEndTime}"
customStartTime = ""
customEndTime = ""
}
if (!(enabledDevices == "")) {
section ("Switch Group 2:"){
paragraph enabledDevices
}
}
enabledDevices = ""
}
//END STATUS CONFIG SWITCH GROUP 2
//BEGIN STATUS CONFIG SWITCH GROUP 3
if (settings.switchDeviceGroup3) {
enabledDevices += "Devices: \n"
enabledDevices += " "
settings.switchDeviceGroup3.each() {
enabledDevices += "${it.displayName},"
}
enabledDevices += "\n\n"
if (settings.switchTalkOn3) {
enabledDevices += "Say when switched ON:\n ${settings.switchTalkOn3}\n\n"
}
if (settings.switchTalkOff3) {
enabledDevices += "Say when switched OFF:\n ${settings.switchTalkOff3}\n\n"
}
if (settings.switchSpeechDevice3) {
enabledDevices += "Custom Speech Device(s):\n"
enabledDevices += " "
settings.switchSpeechDevice3.each() {
enabledDevices += "${it.displayName},"
}
enabledDevices += "\n\n"
}
if (state.speechDeviceType == "capability.musicPlayer") {
enabledDevices += "Resume Audio: ${(!(settings.switchResumePlay3 == null)) ? settings.switchResumePlay3 : settings.resumePlay}"
enabledDevices += "\n\n"
}
if (settings.switchModes3) {
enabledDevices += "Custom mode(s):\n"
enabledDevices += " "
settings.switchModes3.each() {
enabledDevices += "${it},"
}
enabledDevices += "\n\n"
}
if (settings.switchStartTime3) {
def customStartTime = getTimeFromDateString(settings.switchStartTime3, true)
def customEndTime = getTimeFromDateString(settings.switchEndTime3, true)
enabledDevices += "Custom Allowed Talk Time:\n ${customStartTime} - ${customEndTime}"
customStartTime = ""
customEndTime = ""
}
if (!(enabledDevices == "")) {
section ("Switch Group 3:"){
paragraph enabledDevices
}
}
enabledDevices = ""
}
//END STATUS CONFIG SWITCH GROUP 3
//BEGIN STATUS CONFIG PRESENCE GROUP 1
if (settings.presDeviceGroup1) {
enabledDevices += "Devices: \n"
enabledDevices += " "
settings.presDeviceGroup1.each() {
enabledDevices += "${it.displayName},"
}
enabledDevices += "\n\n"
if (settings.presTalkOnArrive1) {
enabledDevices += "Say on arrive:\n ${settings.presTalkOnArrive1}\n\n"
}
if (settings.presTalkOnLeave1) {
enabledDevices += "Say on leave:\n ${settings.presTalkOnLeave1}\n\n"
}
if (settings.presSpeechDevice1) {
enabledDevices += "Custom Speech Device(s):\n"
enabledDevices += " "
settings.presSpeechDevice1.each() {
enabledDevices += "${it.displayName},"
}
enabledDevices += "\n\n"
}
if (state.speechDeviceType == "capability.musicPlayer") {
enabledDevices += "Resume Audio: ${(!(settings.presResumePlay1 == null)) ? settings.presResumePlay1 : settings.resumePlay}"
enabledDevices += "\n\n"
}
if (settings.presModes1) {
enabledDevices += "Custom mode(s):\n"
enabledDevices += " "
settings.presModes1.each() {
enabledDevices += "${it},"
}
enabledDevices += "\n\n"
}
if (settings.presStartTime1) {
def customStartTime = getTimeFromDateString(settings.presStartTime1, true)
def customEndTime = getTimeFromDateString(settings.presEndTime1, true)
enabledDevices += "Custom Allowed Talk Time:\n ${customStartTime} - ${customEndTime}"
customStartTime = ""
customEndTime = ""
}
if (!(enabledDevices == "")) {
section ("Presence Group 1:"){
paragraph enabledDevices