Turn On Switch When Only One Particular Presence is Detected and No one Else is Home

I am hoping that someone can once again point me in the right direction. I am looking for an app that will activate switches based on if only one particular presence is detected. I have a set of Lorex cameras that donā€™t integrated with SmartThings nor much else really. I have set those cameras up with a smart switch outlet to come on when no one is present. Works great as I donā€™t have to keep them on all the time and will not receive Lorex motion and image notifications when the house is occupied. However, as an extra security/monitoring measure I would like those switches to be active if a particular person is present. My first thought was to do it with modes but I already have a complex set of modes and I donā€™t want to complicate it further. If there is an Smart App out that can do this can someone please tell which one. I have searched and have not had much success. Thanks!

If you donā€™t have it already add the ā€œLights and Switchesā€ Dashboard and then add that switch to the dashboard and one of the actions for it will be ā€œTurn on when people arriveā€ then pick the person and that should work for what you want I think.

Thanks. I will give that a try. I was under the impression that it would turn on the switches even if that particular person was home and other people were as well. So for example, Person A is the one particular person I want to monitor only when no other presence is detected. If Person A arrives with Person B will the switches turn on? I would guess yes but I might be wrong. In my scenario, I donā€™t want the switches on when Person A, B and C are presence. Only when Person A is presence and Person B and Person C are not present. That might be a better way to explain it.

Youā€™re right about Lights & Switches, and how it works. You will need a small SmartApp to do what you want. The way it could work is with a virtual switch. Have ST turn on that switch when Person A arrives. The virtual switch fires the app, which examines the presence of Person B and C, and turns on the light if they are not present, but not otherwise.

Here is a small app that turns on a light when only one person arrives, who must be there alone. It does not use a virtual switch, just the presence sensors.

/**
 *  One Person Light
 *
 */
definition(
    name: "One Person Light",
    namespace: "public",
    author: "B Ravenel",
    description: "Turn on a light when only one person is home",
    category: "My Apps",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
    iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")


preferences {
    section("Select the switch to turn on") {
    	input "switches", "capability.switch", title: "Which switch(es)?", required: true, multiple: true
    }
    section("Select the single presence for On"){
    	input "person", "capability.presenceSensor", title: "Which presence?", required: true
    }
    section("Select the other presences") {
    	input "others", "capability.presenceSensor", title: "Which presences?", required: true, multiple: true
    }
}

def installed() {
	initialize()
}

def updated() {
	unsubscribe()
	initialize()
}

def initialize() {
	subscribe(person, "presence", personHandler)
}

def personHandler(evt) {
	if(evt.value == "present") {
    	    def alone = true
            others.each {alone = alone && it.currentPresence == "not present"}
            if(alone) switches.on()
        }
}
1 Like

Thanks, I will give this a try!

Sounds like someone has a teenager. Just a guess though :smile:
Been thereā€¦

Yup. Person B and C = Mom and Dad and Person A = Teenage Son. He is a great kid and we have a lot of trust in him. We are blessed to be so lucky. But I know how I was as a teenagerā€¦ :open_mouth:

I found a simpler way of doing for the not so coding inclined type like myself. :sunglasses:

I had to create two rules.

The first rules is to activate the switches when Person A or Person B leave while Person C is Present:
if any of these happen:
Person A Leaves
Person B Leaves

while ALL of these things are true:
Person A Is Not Present
Person B Is Not Present
Person C Is Present

then do these:
turn on x
turn on y
turn on z

Second rule is toe deactivate the switches on arrival of either Person A or Person B:
if any of these happen:
Person A arrives
Person B arrives

while ALL of these things are true:
blank

then do these:
turn off x
turn off y
turn off z

Pretty neat. Tested this afternoon with success!

I was looking for similar thing. However, I am super new to the ST and the forum. I still canā€™t figure out what to do with this code? How do you enter this app/code into ST?

Steps:

Login to IDE at https://graph.api.smartthings.com
Click on My SmartApps
Click on New SmartApp, then From Code tab
Copy and paste the code from above, then click on Create
Click on Publish / For Me

At that point the app will be available on your mobile device. Go to the far right lower icon, then click on SmartApps. Scroll to the bottom to My Apps, then scroll to the app. Then you can install it, selecting the presences and switches.

2 Likes

In the SmartRules iOS app use the rules I created above. If you have not installed SmartRules I think there are instructions to connect with ST.

This might help:

1 Like