mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-08 05:31:56 +00:00
@@ -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:"
|
||||
@@ -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 ) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -26,6 +26,15 @@ definition(
|
||||
)
|
||||
|
||||
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." }
|
||||
}
|
||||
|
||||
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
|
||||
@@ -33,10 +42,6 @@ preferences {
|
||||
input "phone3", "phone", title: "Phone Number 3", required: false
|
||||
}
|
||||
}
|
||||
|
||||
section ("Zip code (optional, defaults to location coordinates)...") {
|
||||
input "zipcode", "text", title: "Zip Code", 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
|
||||
|
||||
Reference in New Issue
Block a user