I think you are mixing state and values.
I use both in my DTH (https://github.com/philippeportesppo/Honeywell_HPA250B_SmartThings/blob/master/honeywell-hpa250b.groovy) but I update them differently depending I want to update a state or a value.
For value, I have this tile definition:
standardTile("timer", "device.timer", width: 2, height: 2, canChangeIcon: false, canChangeBackground: false, decoration: "flat") {
state ("default", label: 'Timer: ${currentValue}h', backgroundColor:"#ffffff")
}
Then in my parse:
def parse(description) {
def events = []
def descMap = parseDescriptionAsMap(description)
log.debug descMap
def body = new String(descMap["body"].decodeBase64())
log.debug body
def slurper = new JsonSlurper()
def result = slurper.parseText(body)
....
events << createEvent(name: "timer", value: "${result.hpa250b.timer}", isStateChanged:true)
return events
}
If you really want to manage states, here is one:
standardTile("light", "device.light", width: 2, height: 2, canChangeIcon: false, canChangeBackground: false,decoration: "flat",) {
state ("light_off", label:'Off', action:"light_on", icon:"st.Lighting.light13", backgroundColor:"#ffffff" )
state ("light_medium", label:'Medium', action:"light_off", icon:"st.Lighting.light11", backgroundColor:"#00a0dc")
state ("light_on", label:'On', action:"light_medium", icon:"st.Lighting.light11", backgroundColor:"#00a0dc")
state ("light_updating", label:'Sending...')
state ("off", label:'')
}
Would be updated this way in Parse:
events << createEvent(name: "light", value: "light_${result.hpa250b.light}", isStateChanged:true)
where is “on” or “off” or “medium”
So basically, either you send a value, either you send a state. That’s how I use it.