Can someone help figure out why the attributes in this custom DTH aren’t refreshing every 15 minutes?
metadata {
definition (name: "TWC Weather Device", namespace: "lnjustin", author: "Justin Leonard") {
capability "Configuration"
capability "Refresh"
attribute "dayOfWeek","string"
attribute "dayOrNight","string"
attribute "precip1Hour","number"
attribute "precip6Hour","number"
attribute "precip24Hour","number"
attribute "relativeHumidity","number"
attribute "temperature","number"
attribute "temperatureMax24Hour","number"
attribute "temperatureMin24Hour","number"
attribute "validTimeLocal","string"
attribute "validTimeUtc","number"
attribute "windSpeed","string"
attribute "qpfToday","number"
attribute "qpfTomorrow","number"
attribute "temperatureMaxToday","number"
attribute "temperatureMaxTomorrow","number"
attribute "temperatureMinToday","number"
attribute "temperatureMinTomorrow","number"
attribute "precipChanceTodayDay","number"
attribute "precipChanceTodayNight","number"
attribute "precipChanceTomorrowDay","number"
attribute "precipChanceTomorrowNight","number"
attribute "relativeHumidityTodayDay","number"
attribute "relativeHumidityTodayNight","number"
attribute "relativeHumidityTomorrowDay","number"
attribute "relativeHumidityTomorrowNight","number"
attribute "windSpeedTodayDay","number"
attribute "windSpeedTodayNight","number"
attribute "windSpeedTomorrowDay","number"
attribute "windSpeedTomorrowNight","number"
command "sync"
}
}
def parse(String description) {
log.trace "parse($description)"
refresh()
}
def installed()
{
LOG("TWC In installed")
// clear existing state info
state.clear()
// update system info
updated()
}
def refresh()
{
LOG("TWC refresh")
def twcConditions = [:]
try {
twcConditions = getTwcConditions()
} catch (e) {
LOG("Error getting TWC Conditions: ${e}",1,null,'error')
return null
}
if (twcConditions) {
sendEvent(name: "dayOfWeek", value: twcConditions.dayOfWeek)
sendEvent(name: "dayOrNight", value: twcConditions.dayOrNight)
sendEvent(name: "precip1Hour", value: twcConditions.precip1Hour)
sendEvent(name: "precip6Hour", value: twcConditions.precip6Hour)
sendEvent(name: "precip24Hour", value: twcConditions.precip24Hour)
sendEvent(name: "relativeHumidity", value: twcConditions.relativeHumidity)
sendEvent(name: "temperature", value: twcConditions.temperature)
sendEvent(name: "temperatureMax24Hour", value: twcConditions.temperatureMax24Hour)
sendEvent(name: "temperatureMin24Hour", value: twcConditions.temperatureMin24Hour)
sendEvent(name: "validTimeLocal", value: twcConditions.validTimeLocal)
sendEvent(name: "validTimeUtc", value: twcConditions.validTimeUtc)
sendEvent(name: "windSpeed", value: twcConditions.windSpeed)
}
def twcForecast = [:]
try {
twcForecast = getTwcForecast()
} catch (e) {
LOG("Error getting TWC Forecast: ${e}",1,null,'error')
return null
}
if (twcForecast) {
sendEvent(name: "qpfToday", value: twcForecast.qpf[0])
sendEvent(name: "qpfTomorrow", value: twcForecast.qpf[1])
sendEvent(name: "temperatureMaxToday", value: twcForecast.temperatureMax[0])
sendEvent(name: "temperatureMaxTomorrow", value: twcForecast.temperatureMax[1])
sendEvent(name: "temperatureMinToday", value: twcForecast.temperatureMin[0])
sendEvent(name: "temperatureMinTomorrow", value: twcForecast.temperatureMin[1])
sendEvent(name: "precipChanceTodayDay", value: twcForecast.daypart[0].precipChance[0])
sendEvent(name: "precipChanceTodayNight", value: twcForecast.daypart[0].precipChance[1])
sendEvent(name: "precipChanceTomorrowDay", value: twcForecast.daypart[0].precipChance[2])
sendEvent(name: "precipChanceTomorrowNight", value: twcForecast.daypart[0].precipChance[3])
sendEvent(name: "relativeHumidityTodayDay", value: twcForecast.daypart[0].relativeHumidity[0])
sendEvent(name: "relativeHumidityTodayNight", value: twcForecast.daypart[0].relativeHumidity[1])
sendEvent(name: "relativeHumidityTomorrowDay", value: twcForecast.daypart[0].relativeHumidity[2])
sendEvent(name: "relativeHumidityTomorrowNight", value: twcForecast.daypart[0].relativeHumidity[3])
sendEvent(name: "windSpeedTodayDay", value: twcForecast.daypart[0].windSpeed[0])
sendEvent(name: "windSpeedTodayNight", value: twcForecast.daypart[0].windSpeed[1])
sendEvent(name: "windSpeedTomorrowDay", value: twcForecast.daypart[0].windSpeed[2])
sendEvent(name: "windSpeedTomorrowNight", value: twcForecast.daypart[0].windSpeed[3])
}
parent.sendDeviceEvent(device.deviceNetworkId, "refresh")
}
def updated()
{
LOG("TWC updated")
unschedule()
runEvery15Minutes(refresh)
runIn(2, refresh)
}
/*
sync
*/
def sync()
{
// The server will respond with updated status and details
parent.syncDevice(device.deviceNetworkId, "omnipurpose")
sendEvent([name: "version", value: "v${driverVersion.major}.${driverVersion.minor}.${driverVersion.build}"])
}
def getDriverVersion() {[platform: "Hubitat", major: 1, minor: 0, build: 0]}