forked from iakoubtchik/Quirky-Connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Quirky-Porkfolio-Device.groovy
90 lines (83 loc) · 2.8 KB
/
Quirky-Porkfolio-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
/* Quirky Porkfolio
*
* Author: todd@wackford.net
* Date: 2014-02-22
*
*****************************************************************
* Setup Namespace, acpabilities, attributes and commands
*****************************************************************
* Namespace: "wackford"
*
* Capabilities: "acceleration"
* "battery"
* "polling"
* "refresh"
*
* Custom Attributes: "balance"
* "goal"
*
* Custom Commands: "none"
*
*****************************************************************
* Changes
*****************************************************************
*
* Change 1: 2014-03-10
* Documented Header
*
* Change 2: 2014-09-30
* Added child device uninstall call to parent
*
*****************************************************************
* Code
*****************************************************************
*/
metadata {
// Automatically generated. Make future change here.
definition (name: "Quirky Porkfolio", namespace: "wackford", author: "todd@wackford.net", oauth: true) {
capability "Battery"
capability "Refresh"
capability "Polling"
capability "Acceleration Sensor"
attribute "balance", "string"
attribute "goal", "string"
}
tiles {
standardTile("acceleration", "device.acceleration", width: 2, height: 2, canChangeIcon: true) {
state "inactive", label:'pig secure', icon:"st.quirky.porkfolio.quirky-porkfolio-side"//, backgroundColor:"#44b621"
state "active", label:'pig alarm', icon:"st.quirky.porkfolio.quirky-porkfolio-dead", backgroundColor:"#FF1919"
}
standardTile("balance", "device.balance", inactiveLabel: false, canChangeIcon: true) {
state "balance", label:'${currentValue}', unit:"", icon:"st.quirky.porkfolio.quirky-porkfolio-facing"
}
standardTile("goal", "device.goal", inactiveLabel: false, decoration: "flat", canChangeIcon: true) {
state "goal", label:'${currentValue} goal', unit:"", icon:"st.quirky.porkfolio.quirky-porkfolio-success"
}
standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat") {
state "default", action:"refresh.refresh", icon:"st.secondary.refresh"
}
}
main(["acceleration", "balance"])
details(["acceleration", "balance", "goal", "refresh" ])
}
// parse events into attributes
def parse(description) {
log.debug "parse() - $description"
def results = []
if (description?.name && description?.value)
{
results << sendEvent(name: "${description?.name}", value: "${description?.value}")
}
}
def uninstalled() {
log.debug "Executing 'uninstall' in child"
parent.uninstallChildDevice(this)
}
def poll() {
log.debug "Executing 'poll'"
parent.getPiggyBankUpdate(this)
}
def refresh() {
log.debug "Executing 'refresh'"
parent.getPiggyBankUpdate(this)
}