/* groovylint-disable CompileStatic, MethodCount, MethodSize, UnnecessaryGetter */
/**
* Echo Speaks - Zones (Hubitat)
*
* Copyright 2018, 2019, 2020, 2021, 2022, 2023, 2024 Anthony Santilli
* Code Contributions by @nh.schottfam
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
*/
//file:noinspection GroovyUnusedAssignment
//file:noinspection unused
//file:noinspection GroovySillyAssignment
//file:noinspection GrMethodMayBeStatic
import groovy.json.JsonOutput
import groovy.transform.Field
import java.text.SimpleDateFormat
import java.util.concurrent.Semaphore
//************************************************
//* STATIC VARIABLES *
//************************************************
@Field static final String appVersionFLD = '4.2.4.0'
@Field static final String appModifiedFLD = '2024-03-07'
@Field static final String sNULL = (String)null
@Field static final String sBLANK = ''
@Field static final String sSPACE = ' '
@Field static final String sBULLET = '\u2022'
//@Field static final String sBULLETINV = '\u25E6'
//@Field static final String sSQUARE = '\u29C8'
//@Field static final String sPLUS = '\u002B'
//@Field static final String sRIGHTARR = '\u02C3'
@Field static final String okSymFLD = "\u2713"
@Field static final String notOkSymFLD = "\u2715"
@Field static final String sPAUSESymFLD = "\u275A\u275A"
@Field static final String sLINEBR = ' '
@Field static final String sFALSE = 'false'
@Field static final String sTRUE = 'true'
@Field static final String sBOOL = 'bool'
@Field static final String sENUM = 'enum'
@Field static final String sNUMBER = 'number'
@Field static final String sTEXT = 'text'
@Field static final String sTIME = 'time'
@Field static final String sMODE = 'mode'
//@Field static final String sCOMPLT = 'complete'
@Field static final String sMEDIUM = 'medium'
@Field static final String sSMALL = 'small'
@Field static final String sCLR4D9 = '#2784D9'
@Field static final String sCLRRED = 'red'
@Field static final String sCLRRED2 = '#cc2d3b'
@Field static final String sCLRGRY = 'gray'
//@Field static final String sCLRGRN = 'green'
@Field static final String sCLRGRN2 = '#43d843'
@Field static final String sCLRORG = 'orange'
@Field static final String sTTM = 'Tap to modify...'
@Field static final String sTTC = 'Tap to configure...'
//@Field static final String sTTCR = 'Tap to configure (Required)'
//@Field static final String sTTP = 'Tap to proceed...'
//@Field static final String sTTS = 'Tap to select...'
@Field static final String sSETTINGS = 'settings'
@Field static final String sRESET = 'reset'
@Field static final String sEXTNRL = 'external'
@Field static final String sDEBUG = 'debug'
@Field static final String sSWITCH = 'switch'
@Field static final String sCHKBOX = 'checkbox'
@Field static final String sCOMMAND = 'command'
@Field static final String zoneHistFLD = 'zoneHistory'
@Field static final List lSUNRISESET = ["sunrise", "sunset"]
//************************************************
//* IN-MEMORY ONLY VARIABLES *
//* (Cleared only on HUB REBOOT or CODE UPDATES) *
//************************************************
@Field volatile static Map historyMapFLD = [:]
// @Field volatile static String gitBranchFLD = null
static String appVersion() { return appVersionFLD }
static String appVersionDt() { return appModifiedFLD }
definition(
name : "Echo Speaks - Zones",
namespace : "tonesto7",
author : "Anthony Santilli",
description : "DO NOT INSTALL FROM MARKETPLACE\n\nAllows you to create virtual broadcast zones based on your echo devices using device/location events to active the zone.",
category : "My Apps",
parent : "tonesto7:Echo Speaks",
iconUrl : "https://raw.githubusercontent.com/tonesto7/echo-speaks/master/resources/icons/es_groups.png",
iconX2Url : "https://raw.githubusercontent.com/tonesto7/echo-speaks/master/resources/icons/es_groups.png",
iconX3Url : "https://raw.githubusercontent.com/tonesto7/echo-speaks/master/resources/icons/es_groups.png",
importUrl : "https://raw.githubusercontent.com/tonesto7/echo-speaks/master/apps/echo-speaks-zones.groovy",
documentationLink : documentationUrl(),
videoLink : videoUrl()
)
preferences {
page(name: "startPage")
page(name: "uhOhPage")
page(name: "codeUpdatePage")
page(name: "mainPage")
page(name: "prefsPage")
page(name: "conditionsPage")
page(name: "condTimePage")
page(name: "zoneNotifPage")
page(name: "zoneNotifTimePage")
page(name: "zoneHistoryPage")
page(name: "uninstallPage")
page(name: "namePage")
}
def startPage() {
if(parent != null) {
if(!(Boolean)state.isInstalled && !(Boolean)parent?.childInstallOk()) { return uhOhPage() }
else {
updDeviceInputs()
return (minVersionFailed()) ? codeUpdatePage() : mainPage()
}
} else { return uhOhPage() }
}
def codeUpdatePage () {
return dynamicPage(name: "codeUpdatePage", title: "Update is Required", install: false, uninstall: false) {
section() { paragraph spanSmBld("Looks like your Zone App needs an update
Please make sure all app and device code is updated to the most current version
Once updated your zones will resume normal operation.", sCLRRED) }
}
}
def uhOhPage () {
return dynamicPage(name: "uhOhPage", title: "This install Method is Not Allowed", install: false, uninstall: true) {
section() {
paragraph spanBld("HOUSTON WE HAVE A PROBLEM!
Echo Speaks - Zones can't be directly installed from the Marketplace.