mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-08 05:31:56 +00:00
Merge pull request #342 from Yaima/master
Display issue with Wattvision integration
This commit is contained in:
@@ -33,14 +33,14 @@ metadata {
|
||||
state "power", label: '${currentValue} W'
|
||||
}
|
||||
|
||||
tile(name: "powerChart", attribute: "powerContent", type: "HTML", url: '${currentValue}', width: 3, height: 2) { }
|
||||
htmlTile(name: "powerContent", attribute: "powerContent", type: "HTML", whitelist: "www.wattvision.com" , url: '${currentValue}', width: 3, height: 2)
|
||||
|
||||
standardTile("refresh", "device.power", inactiveLabel: false, decoration: "flat") {
|
||||
state "default", label: '', action: "refresh.refresh", icon: "st.secondary.refresh"
|
||||
}
|
||||
|
||||
main "power"
|
||||
details(["powerChart", "power", "refresh"])
|
||||
details(["powerContent", "power", "refresh"])
|
||||
|
||||
}
|
||||
}
|
||||
@@ -74,10 +74,10 @@ public addWattvisionData(json) {
|
||||
|
||||
log.trace "Adding data from Wattvision"
|
||||
|
||||
def data = json.data
|
||||
def data = parseJson(json.data.toString())
|
||||
def units = json.units ?: "watts"
|
||||
|
||||
if (data) {
|
||||
if (data.size() > 0) {
|
||||
def latestData = data[-1]
|
||||
data.each {
|
||||
sendPowerEvent(it.t, it.v, units, (latestData == it))
|
||||
@@ -103,3 +103,7 @@ private sendPowerEvent(time, value, units, isLatest = false) {
|
||||
sendEvent(eventData)
|
||||
|
||||
}
|
||||
|
||||
def parseJson(String s) {
|
||||
new groovy.json.JsonSlurper().parseText(s)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user