/
web-presence.dt.groovy
55 lines (46 loc) · 1.07 KB
/
web-presence.dt.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
/**
* Clever Presence
*
* Author: Brian Steere
* Date: 2014-04-18
*/
// for the UI
metadata {
definition (name: "webPresence", namespace: "dianoga", author: "Brian Steere") {
capability "Presence Sensor"
command "away"
command "present"
}
simulator {
// TODO: define status and reply messages here
}
tiles {
standardTile("presence", "device.presence", width: 2, height: 2, canChangeBackground: true) {
state "present", labelIcon:"st.presence.tile.present", backgroundColor:"#53a7c0"
state "not present", labelIcon:"st.presence.tile.not-present", backgroundColor:"#ffffff"
}
main "presence"
details(["presence"])
}
}
mappings {
path("/present") {
action: [ GET: "present" ]
}
path("/away") {
action: [ GET: "away" ]
}
}
// parse events into attributes
def parse(String description) {
log.debug "Parsing '${description}'"
}
// handle commands
def away() {
log.debug "Executing 'away'"
sendEvent(name: 'presence', value: 'not present')
}
def present() {
log.debug "Executing 'present'"
sendEvent(name: 'presence', value: 'present')
}