I got a question about my newly created DTH. The new app does not show the current temperature in it’s tile. This is my first DTH so I am already really happy it’s able to pull it’s data from that api… But a working tile would be great. Hope someone has any insight?
In the new app the tile is not updating, it’s checking status.
When I open the tile everything is fine, values for humidity and temp are all there just like refresh and history.
In the old app I can see two tiles and in the devices list I can see the current themperature.
How can I make the old app ‘tile’ work and display the current temperature? Any suggestions?
metadata {
definition (name: "Quby Temperature and Humidity Sensor", namespace: "co.bbo/testing", author: "Bastiaan de Boer", mnmn: "smartthings", vid: "generic-humidity", ocfDeviceType: "oic.d.thermostat") {
capability "Temperature Measurement"
capability "Relative Humidity Measurement"
capability "Sensor"
capability "Polling"
capability "Refresh"
capability "Health Check"
}
simulator {
// TODO: define status and reply messages here
}
// UI tile definitions
tiles {
valueTile("temperature", "device.temperature", width: 2, height: 2) {
state("temperature", label:'${currentValue}', unit:"C",
backgroundColors:[
[value: 12, color: "#153591"],
[value: 15, color: "#1e9cbb"],
[value: 18, color: "#90d2a7"],
[value: 20, color: "#44b621"],
[value: 22, color: "#f1d801"],
[value: 25, color: "#d04e00"],
[value: 30, color: "#bc2323"]
]
)
}
valueTile("humidity", "device.humidity", width: 2, height: 2) {
state "humidity", label:'${currentValue}%', unit:"%", icon:"https://raw.githubusercontent.com/bspranger/Xiaomi/master/images/XiaomiHumidity.png",
backgroundColors:[
[value: 0, color: "#FFFCDF"],
[value: 4, color: "#FDF789"],
[value: 20, color: "#A5CF63"],
[value: 23, color: "#6FBD7F"],
[value: 56, color: "#4CA98C"],
[value: 59, color: "#0072BB"],
[value: 76, color: "#085396"]
]
}
main("temperature")
details(["temperature", "humidity", "refresh"])
}
}
def parse(String description) {
def pair = description.split(":")
createEvent(name: pair[0].trim(), value: pair[1].trim(), unit:"C")
}
def refresh() {
log.debug "Quby.Display: Refresh"
poll()
}
def ping() {
log.debug "Quby.Display: Ping"
poll()
}
def poll() {
sendEvent(name: "healthStatus", value: "online")
log.debug "Quby.Display: Poll"
setTemperature(getTemperature())
}
def installed() {
initialize()
}
def updated() {
initialize()
}
def initialize() {
log.debug "Quby.Display: Init"
sendEvent(name: "healthStatus", value: "online")
if (!device.currentState("temperature")) {
setTemperature(getTemperature())
}
sendEvent(name: "DeviceWatch-Enroll", value: [protocol: "cloud", scheme:"untracked"].encodeAsJson(), displayed: false)
}
def setTemperature(value_temp, value_hum) {
sendEvent(name:"temperature", value: value_temp)
sendEvent(name:"humidity", value: value_hum)
}
private getTemperature() {
def headers = [:]
headers.put("Content-Type", "application/json")
headers.put("Accpet", "application/json")
headers.put("Cache-Control", "no-cache")
headers.put("X-CommonName", "qb-xxx")
headers.put("X-Agreement-ID", "xxx")
headers.put("Host", "api.toon.eu")
headers.put("Authorization", "Bearer xxx")
def params = [
uri: "https://api.toon.eu",
path: "/toon/v3/xxx/thermostat",
headers: headers
]
try {
httpGet(params) { resp ->
def ts_temp = (resp.data.currentDisplayTemp/100) as Integer
def ts_hum = (resp.data.currentHumidity) as Integer
log.debug "Response: $resp.data"
log.debug "Quby.thermostat.currentDisplayTemp: $ts_temp"
log.debug "Quby.thermostat.currentHumidity: $ts_hum"
state.temp = ts_temp
state.hum = ts_hum
}
} catch (e) {
log.error "something went wrong: $e"
}
Integer value_temp = state.temp
Integer value_hum = state.hum
log.debug "Value_temp: $value_temp"
log.debug "Value_hum: $value_hum"
return [value_temp, value_hum]
}