From 79d20b0edb101cc79e24097f3750179b03666eb1 Mon Sep 17 00:00:00 2001 From: Juan Pablo Risso Date: Thu, 22 Sep 2016 18:59:07 -0400 Subject: [PATCH] SSVD-2740 - Remove zipcode input (#1267) Limit to samsungtv channel --- .../smart-windows.src/smart-windows.groovy | 29 +++++++++++++------ .../ready-for-rain.src/ready-for-rain.groovy | 15 ++++++++-- .../severe-weather-alert.groovy | 25 +++++++++------- 3 files changed, 47 insertions(+), 22 deletions(-) diff --git a/smartapps/egid/smart-windows.src/smart-windows.groovy b/smartapps/egid/smart-windows.src/smart-windows.groovy index 89cdb04..924da87 100644 --- a/smartapps/egid/smart-windows.src/smart-windows.groovy +++ b/smartapps/egid/smart-windows.src/smart-windows.groovy @@ -1,7 +1,7 @@ /** * Smart Windows * Compares two temperatures – indoor vs outdoor, for example – then sends an alert if windows are open (or closed!). - * + * * Copyright 2014 Eric Gideon * * Based in part on the "When it's going to rain" SmartApp by the SmartThings team, @@ -21,13 +21,18 @@ definition( name: "Smart Windows", namespace: "egid", author: "Eric Gideon", - description: "Compares two temperatures – indoor vs outdoor, for example – then sends an alert if windows are open (or closed!). If you don't use an external temperature device, your zipcode will be used instead.", + description: "Compares two temperatures – indoor vs outdoor, for example – then sends an alert if windows are open (or closed!). If you don't use an external temperature device, your location will be used instead.", iconUrl: "https://s3.amazonaws.com/smartthings-device-icons/Home/home9-icn.png", iconX2Url: "https://s3.amazonaws.com/smartthings-device-icons/Home/home9-icn@2x.png" ) preferences { + + if (!(location.zipCode || ( location.latitude && location.longitude )) && location.channelName == 'samsungtv') { + section { paragraph title: "Note:", "Location is required for this SmartApp. Go to 'Location Name' settings to setup your correct location." } + } + section( "Set the temperature range for your comfort zone..." ) { input "minTemp", "number", title: "Minimum temperature" input "maxTemp", "number", title: "Maximum temperature" @@ -39,9 +44,11 @@ preferences { input "inTemp", "capability.temperatureMeasurement", title: "Indoor" input "outTemp", "capability.temperatureMeasurement", title: "Outdoor (optional)", required: false } - section( "Set your location" ) { - input "zipCode", "text", title: "Zip code" - } + + if (location.channelName != 'samsungtv') { + section( "Set your location" ) { input "zipCode", "text", title: "Zip code" } + } + section( "Notifications" ) { input "sendPushMessage", "enum", title: "Send a push notification?", metadata:[values:["Yes","No"]], required:false input "retryPeriod", "number", title: "Minutes between notifications:" @@ -72,7 +79,7 @@ def temperatureHandler(evt) { def currentInTemp = evt.doubleValue def openWindows = sensors.findAll { it?.latestValue("contact") == 'open' } - + log.trace "Temp event: $evt" log.info "In: $currentInTemp; Out: $currentOutTemp" @@ -98,7 +105,7 @@ def temperatureHandler(evt) { if ( currentOutTemp < maxTemp && !openWindows ) { send( "Open some windows to cool down the house! Currently ${currentInTemp}°F inside and ${currentOutTemp}°F outside." ) } else if ( currentOutTemp > maxTemp && openWindows ) { - send( "It's gotten warmer outside! You should close these windows: ${openWindows.join(', ')}. Currently ${currentInTemp}°F inside and ${currentOutTemp}°F outside." ) + send( "It's gotten warmer outside! You should close these windows: ${openWindows.join(', ')}. Currently ${currentInTemp}°F inside and ${currentOutTemp}°F outside." ) } else { log.debug "No notifications sent. Everything is in the right place." } @@ -125,7 +132,11 @@ def temperatureHandler(evt) { } def weatherCheck() { - def json = getWeatherFeature("conditions", zipCode) + def json + if (location.channelName != 'samsungtv') + json = getWeatherFeature("conditions", zipCode) + else + json = getWeatherFeature("conditions") def currentTemp = json?.current_observation?.temp_f if ( currentTemp ) { @@ -150,4 +161,4 @@ private send(msg) { } log.info msg -} \ No newline at end of file +} diff --git a/smartapps/imbrianj/ready-for-rain.src/ready-for-rain.groovy b/smartapps/imbrianj/ready-for-rain.src/ready-for-rain.groovy index c88b91f..c7ffb39 100644 --- a/smartapps/imbrianj/ready-for-rain.src/ready-for-rain.groovy +++ b/smartapps/imbrianj/ready-for-rain.src/ready-for-rain.groovy @@ -18,8 +18,13 @@ definition( ) preferences { - section("Zip code?") { - input "zipcode", "text", title: "Zipcode?" + + if (!(location.zipCode || ( location.latitude && location.longitude )) && location.channelName == 'samsungtv') { + section { paragraph title: "Note:", "Location is required for this SmartApp. Go to 'Location Name' settings to setup your correct location." } + } + + if (location.channelName != 'samsungtv') { + section( "Set your location" ) { input "zipCode", "text", title: "Zip code" } } section("Things to check?") { @@ -60,7 +65,11 @@ def scheduleCheck(evt) { // Only need to poll if we haven't checked in a while - and if something is left open. if((now() - (30 * 60 * 1000) > state.lastCheck["time"]) && open) { log.info("Something's open - let's check the weather.") - def response = getWeatherFeature("forecast", zipcode) + def response + if (location.channelName != 'samsungtv') + response = getWeatherFeature("forecast", zipCode) + else + response = getWeatherFeature("forecast") def weather = isStormy(response) if(weather) { diff --git a/smartapps/smartthings/severe-weather-alert.src/severe-weather-alert.groovy b/smartapps/smartthings/severe-weather-alert.src/severe-weather-alert.groovy index f27671c..eafa863 100644 --- a/smartapps/smartthings/severe-weather-alert.src/severe-weather-alert.groovy +++ b/smartapps/smartthings/severe-weather-alert.src/severe-weather-alert.groovy @@ -26,17 +26,22 @@ definition( ) preferences { - section ("In addition to push notifications, send text alerts to...") { - input("recipients", "contact", title: "Send notifications to") { - input "phone1", "phone", title: "Phone Number 1", required: false - input "phone2", "phone", title: "Phone Number 2", required: false - input "phone3", "phone", title: "Phone Number 3", required: false - } + + if (!(location.zipCode || ( location.latitude && location.longitude )) && location.channelName == 'samsungtv') { + section { paragraph title: "Note:", "Location is required for this SmartApp. Go to 'Location Name' settings to setup your correct location." } } - section ("Zip code (optional, defaults to location coordinates)...") { - input "zipcode", "text", title: "Zip Code", required: false - } + if (location.channelName != 'samsungtv') { + section( "Set your location" ) { input "zipCode", "text", title: "Zip code" } + } + + section ("In addition to push notifications, send text alerts to...") { + input("recipients", "contact", title: "Send notifications to") { + input "phone1", "phone", title: "Phone Number 1", required: false + input "phone2", "phone", title: "Phone Number 2", required: false + input "phone3", "phone", title: "Phone Number 3", required: false + } + } } def installed() { @@ -61,7 +66,7 @@ def checkForSevereWeather() { def alerts if(locationIsDefined()) { if(zipcodeIsValid()) { - alerts = getWeatherFeature("alerts", zipcode)?.alerts + alerts = getWeatherFeature("alerts", zipCode)?.alerts } else { log.warn "Severe Weather Alert: Invalid zipcode entered, defaulting to location's zipcode" alerts = getWeatherFeature("alerts")?.alerts