-
Notifications
You must be signed in to change notification settings - Fork 0
/
Energy Tile
49 lines (38 loc) · 947 Bytes
/
Energy Tile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
Virtual Device with `energy` value to pass details to Actiontiles object.
*/
metadata {
definition(name: "Energy Tile", namespace: "s.tavener", author: "Stavener" ) {
capability "Energy Meter"
capability "Sensor"
capability "Actuator"
command "setenergy"
command "getenergy"
attribute "energy", "number"
}
tiles {
valueTile("energy", "device.energy", width: 3, height: 1) {
state "default", label:'${currentValue} number}'
}
}
}
def initialize() {
state.energy = 0.0
log.debug("init")
}
def installed() {
log.debug "Installed"
initialize()
}
def updated() {
log.debug "Updated"
initialize()
}
def setenergy(new_value) {
log.debug "setenergy called energy=$new_value"
sendEvent(name:"energy", value: new_value, unit:"p/Kw")
}
private getenergy() {
value = device.currentState("energy")
return value
}