4 * Author: sidjohn1@gmail.com
8 // Automatically generated. Make future change here.
10 name: "Smart turn it on",
11 namespace: "sidjohn1",
12 author: "sidjohn1@gmail.com",
13 description: "Turns on selected device(s) at a set time on selected days of the week only if a selected person is present and turns off selected device(s) after a set time.",
14 category: "Convenience",
15 iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
16 iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png"
20 section("Turn on which device?"){
21 input "switchOne", "capability.switch",title:"Select Light", required: true, multiple: true
23 section("For Whom?") {
24 input "presenceOne", "capability.presenceSensor", title: "Select Person", required: true, multiple: true
26 section("On which Days?") {
27 input "dayOne", "enum", title:"Select Days", required: true, multiple:true, metadata: [values: ['Mon','Tue','Wed','Thu','Fri','Sat','Sun']]
29 section("At what time?") {
30 input name: "timeOne", title: "Select Time", type: "time", required: true
32 section("For how long?") {
33 input name: "timeTwo", title: "Number of minutes", type: "number", required: true
40 log.debug "scheduling 'Smart turn it on' to run at $timeOne"
41 schedule(timeOne, "turnOn")
50 log.debug "scheduling 'Smart turn it on' to run at $timeOne"
51 schedule(timeOne, "turnOn")
57 def dayCheck = dayOne.contains(new Date().format("EEE"))
58 def dayTwo = new Date().format("EEE");
60 def presenceTwo = presenceOne.latestValue("presence").contains("present")
63 def delay = timeTwo * 60
64 runIn(delay, "turnOff")