Last active
December 17, 2015 00:29
-
-
Save bflorian/5520946 to your computer and use it in GitHub Desktop.
Weather Alert Monitor -- SmartApp that listens to alert events from the SmartWeather Station Tile device, and sends alerts as push or SMS notifications.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Weather Alert Monitor | |
* | |
* Author: bob | |
* | |
* EXAMPLE NOT CURRENTLY PUBLISHED | |
* | |
* Date: 2013-04-30 | |
*/ | |
preferences { | |
section("Weather service..") { | |
input "weather", "device.SmartweatherStationTile" | |
} | |
section ("In addition to push notifications, send text alerts 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() { | |
initialize() | |
} | |
def updated() { | |
unsubscribe() | |
initialize() | |
} | |
def initialize() { | |
subscribe(weather, "alert", alertHandler) | |
} | |
def alertHandler(evt) { | |
if (evt.value != "no current weather alerts") { | |
def msg = "Weather Alert! $evt.descriptionText" | |
log.debug msg | |
sendPush msg | |
if (settings.phone1) { | |
sendSms phone1, msg | |
} | |
if (settings.phone2) { | |
sendSms phone2, msg | |
} | |
if (settings.phone3) { | |
sendSms phone3, msg | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment