forked from iakoubtchik/Quirky-Connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Quirky-Pivot-Power-Genius-Device.groovy
100 lines (85 loc) · 2.49 KB
/
Quirky-Pivot-Power-Genius-Device.groovy
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* Quirky Pivot Power Genius
*
* Author: [email protected]
* Date: 2014-01-28
*
*****************************************************************
* Setup Namespace, acpabilities, attributes and commands
*****************************************************************
* Namespace: "wackford"
*
* Capabilities: "switch"
* "polling"
* "refresh"
*
* Custom Attributes: "none"
*
* Custom Commands: "none"
*
*****************************************************************
* Changes
*****************************************************************
*
* Change 1: 2014-03-10
* Documented Header
*
*****************************************************************
* Code
*****************************************************************
*/
// for the UI
metadata {
// Automatically generated. Make future change here.
definition (name: "Quirky Pivot Power Genius", namespace: "wackford", author: "[email protected]", oauth: true) {
capability "Refresh"
capability "Polling"
capability "Switch"
}
simulator {
// TODO: define status and reply messages here
}
tiles {
standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) {
state "off", label: '${name}', action: "switch.on", icon: "st.quirky.pivot-genius.quirky-pivot-off", backgroundColor: "#ffffff"
state "on", label: '${name}', action: "switch.off", icon: "st.quirky.pivot-genius.quirky-pivot-on", backgroundColor: "#79b821"
}
standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat") {
state "default", action:"refresh.refresh", icon:"st.secondary.refresh"
}
}
main(["switch"])
details(["switch", "refresh" ])
}
// parse events into attributes
def parse(description) {
log.debug "parse() - $description"
def results = []
if ( description == "updated" ) on initial install we are returned just a string
return
if (description?.name && description?.value)
{
results << sendEvent(name: "${description?.name}", value: "${description?.value}")
}
}
// handle commands
def on() {
log.debug "Executing 'on'"
log.debug this
parent.on(this)
}
def off() {
log.debug "Executing 'off'"
parent.off(this)
}
def uninstalled() {
log.debug "Executing 'uninstall' in child"
parent.uninstallChildDevice(this)
}
def poll() {
log.debug "Executing 'poll'"
parent.pollOutlet(this)
}
def refresh() {
log.debug "Executing 'refresh'"
parent.pollOutlet(this)
}