forked from sidjohn1/smartthings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ThermostatAutoHome.groovy
52 lines (46 loc) · 1.4 KB
/
ThermostatAutoHome.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
/**
* Thermostat Auto Home
*
* Author: [email protected]
* Date: 2013-07-23
*/
// Automatically generated. Make future change here.
definition(
name: "Thermostat Auto Home",
namespace: "sidjohn1",
author: "[email protected]",
description: "Simply marks any thermostat home after someone arrives. Great for Nest",
category: "Green Living",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png",
oauth: false
)
preferences {
section("When one of these people arrive at home") {
input "presence1", "capability.presenceSensor", title: "Who?", multiple: true, required: true
}
section("Set this thermostat staus to home") {
input "thermostat1", "capability.thermostat", title: "Which?", multiple: true, required: true
}
}
def installed()
{
subscribe(presence1, "presence", presenceHandler)
}
def updated()
{
unsubscribe()
subscribe(presence1, "presence", presenceHandler)
}
def presenceHandler(evt)
{
log.debug "presenceHandler $evt.name: $evt.value"
def current = presence1.currentValue("presence")
log.debug current
def presenceValue = presence1.find{it.currentPresence == "present"}
log.debug presenceValue
if(presenceValue){
thermostat1?.present()
log.debug "SmartThings changed your thermostat to home because someone arrived home"
}
}