Here’s what I ended up with. Using a combination of OpenWeatherMap’s free API and the temperature sensor template in ST. Works great!
/**
*/
metadata {
definition (name: “Temperature Sensor Weather”, namespace: “burninmoney”, author: “burninmoney”) {
capability “Temperature Measurement”
capability “Relative Humidity Measurement”
capability “Sensor”
}
// UI tile definitions
tiles {
valueTile("temperature", "device.temperature", width: 2, height: 2) {
state("temperature", label:'${currentValue}°',
backgroundColors:[
[value: 31, color: "#153591"],
[value: 44, color: "#1e9cbb"],
[value: 59, color: "#90d2a7"],
[value: 74, color: "#44b621"],
[value: 84, color: "#f1d801"],
[value: 95, color: "#d04e00"],
[value: 96, color: "#bc2323"]
]
)
}
valueTile("humidity", "device.humidity") {
state "humidity", label:'${currentValue}%', unit:""
}
main(["temperature", "humidity"])
details(["temperature", "humidity"])
}
}
def installed() {
runEvery1Minute(makeJSONWeatherRequest)
}
def makeJSONWeatherRequest() {
def params = [
uri: ‘http://api.openweathermap.org/data/2.5/weather?zip=YOURFIVEDIGITZIPCODE,us&APPID=YOURAPIKEY&units=imperial’,
contentType: ‘application/json’,
]
try {
httpGet(params) {resp ->
log.debug “resp data: {resp.data}"
log.debug "humidity: {resp.data.main.humidity}”
log.debug “temp: ${resp.data.main.temp}”
sendEvent(name: “temperature”, value: resp.data.main.temp)
sendEvent(name: “humidity”, value: resp.data.main.humidity)
}
} catch (e) {
log.error “error: e"
log.error "{params}”
}
}