-
Notifications
You must be signed in to change notification settings - Fork 3
/
web-presence-manager.sa.groovy
69 lines (57 loc) · 1.48 KB
/
web-presence-manager.sa.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
/**
* Web Presence Manager
*
* Author: Brian Steere
* Date: 2014-04-18
*/
// Automatically generated. Make future change here.
definition(
name: "Web Presence Manager",
namespace: "dianoga",
author: "Brian Steere",
description: "REST API for Web Presence device",
category: "Family",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png",
oauth: [displayName: "Web Presence Manager", displayLink: ""]
)
preferences {
section("Web Presence") {
//input "devices", "device.webPresence", title: "Which Devices"
input "devices", "capability.presenceSensor", title: "Which Devices", multiple: true
}
}
mappings {
path("/devices") {
action: [ GET: "listDevices" ]
}
path("/devices/:id/:command") {
action: [ GET: "update" ]
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
initialize()
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
initialize()
}
def initialize() {
// TODO: subscribe to attributes, devices, locations, etc.
}
def listDevices() {
log.debug "Listing Devices"
devices.collect()
}
def update() {
log.debug "update, request: params: ${params}, devices: $devices.id"
def device = devices.find { it.id == params.id }
log.debug "Device: $device";
if(params.command == 'away') {
device.away()
} else if (params.command == 'present') {
device.present()
}
}