Sure thing. The Github repository I use for it is named inclement_weather_pws under the account jameslew.
If you just want the text of it:
/**
* Severe Weather Alert - PWS edition
*
* Author: Jim Lewallen
* Date: 2013-03-04
*/
preferences {
section ("Weather threshholds to alert at..."){
input "highwindspeed", "number", title: "Avg Wind Speed", required: false
input "hightempf", "number", title: "High Temperature", required: false
input "lowtempf", "number", title: "Low Temperature", required: false
input "highrainfall", "number", title: "Rainfall Threshhold", required: false
input "apikey", "string", title: "API Key", required: false
}
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
}
section("Which people should I watch for?") {
input "people", "capability.presenceSensor", title: "Presence sensor", description: "Which people(s)?", multiple: true, required: false
}
section ("Weather Underground Weather Station ID") {
input "stationid", "text", title: "Station ID", required: true
}
section ("Custom Weather Quotes") {
input "coldWeatherQuote", "text", title: "Custom Cold Comment", required: false
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
setDefaultWeather()
checkWeather()
schedule("0 0/15 * * * ?", "checkWeather") //Check at top and half-past of every hour
schedule("0 0 5 * * ?", "setDefaultWeather") //Reset in the morning
schedule("0 0 16 * * ?", "setDefaultWeather") //Reset in the afternoon
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
setDefaultWeather()
checkWeather()
schedule("0 0/15 * * * ?", "checkWeather") //Check at top and half-past of every hour
schedule("0 0 5 * * ?", "setDefaultWeather") //Reset in the morning
schedule("0 0 16 * * ?", "setDefaultWeather") //Reset in the afternoon
}
def checkWeather() {
log.debug "Checking Weather"
httpGet("http://api.wunderground.com/api/${apikey}/conditions/q/pws:${stationid}.json")
{ response ->
def windspeed = response.data.current_observation.wind_mph.floatValue()
def tempf = response.data.current_observation.temp_f.floatValue()
def hourlyprecip = Float.parseFloat(response.data.current_observation.precip_1hr_in)
log.debug "Actual: ${windspeed}, ${tempf}, ${hourlyprecip}"
log.debug "Threshholds: ${highwindspeed}, ${hightempf}, ${lowtempf}, ${hourlyprecip}"
log.debug "State: ${state.lastHighWindSpeed}, ${state.lasthightempf}, ${state.lastlowtempf}, ${state.lasthourlyprecip}"
if (windspeed > highwindspeed) {
if (windspeed >= state.lastHighWindSpeed + 3.0 ) {
state.lastHighWindSpeed = windspeed
notifyHousemates("High wind speed of ${windspeed}mph at the house")
} else {log.debug "not enough wind speed change"}
} else { state.lastHighWindSpeed = windspeed }
if (tempf > hightempf) {
if (tempf >= state.lasthightempf + 3.0 ) {
state.lasthightempf = tempf
notifyHousemates("It's damn hot at the house: ${tempf}F")
} else {log.debug "not enough high temp change"}
} else { state.lasthightempf = tempf }
if (tempf < lowtempf) {
if (tempf <= state.lastlowtempf - 3.0 ) {
state.lastlowtempf = tempf
notifyHousemates(coldWeatherQuote + ": ${tempf}")
} else { log.debug "not enough low temp change" }
} else { state.lastlowtempf = tempf }
if (hourlyprecip > highrainfall) {
if (hourlyprecip >= state.lasthourlyprecip + 1.0 ) {
state.lasthourlyprecip = hourlyprecip
notifyHousemates("It's raining buckets at the house: ${hourlyprecip} in.")
} else {log.debug "not enough precip change"}
} else { state.lasthourlyprecip = hourlyprecip }
}
}
def logTraceWithPush(message) {
sendPush message
log.debug message
}
def setDefaultWeather() {
logTraceWithPush("Resetting the weather state")
state.lastHighWindSpeed = 0.0
state.lasthightempf = 65.0
state.lastlowtempf = 40.0
state.lasthourlyprecip = 0.0
log.debug "state: ${state.lastHighWindSpeed}, ${state.lasthightempf}, ${state.lastlowtempf}, ${state.lasthourlyprecip}"
}
private notifyHousemates(message) {
def t0 = new Date(now() - (8 * 60 * 60 * 1000))
if (t0.getHours() >= 6 && t0.getHours() <= 22)
{
log.debug "We got one! ${message}"
send(message)
} else {
log.debug "Yikes, it's ${t0.getHours()}, discarding notification!"
send(message)
}
}