[OBSOLETE] Everyone's Presence

“Everyone’s Presence” is a SmartApp that sets a simulated presence sensor to “present” or “not present” based on a group of presence sensors. If no sensors are home, it sets to “not present”. If at least one sensor is home, it sets to “present”. To use this, you need to create a “Simulated Presence Sensor” in the IDE. I created this SmartApp to be used with IFTTT. I know this could have been done with a virtual switch, but I thought it might come in handy later for something else. I’m sure somebody will see another use for this.

/**
 *  Everyone's Presence
 *
 *  Copyright 2015 Eric Roberts
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 */
definition(
    name: "Everyone's Presence",
    namespace: "baldeagle072",
    author: "Eric Roberts",
    description: "Will set a simulated presence sensor based based on if anybody is home. If no people are home, it will set to 'not present'. If at least one person is home, it will set to 'present'.",
    category: "Fun & Social",
    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 Presence Sensor Group") {
		input "presenceSensors", "capability.presenceSensor", title: "Presence Sensors", multiple: true, required: true
        input "simulatedPresence", "device.simulatedPresenceSensor", title: "Simulated Presence Sensor", multiple: false, required: true
	}
}

def installed() {
	log.debug "Installed with settings: ${settings}"

	initialize()
}

def updated() {
	log.debug "Updated with settings: ${settings}"

	unsubscribe()
	initialize()
}

def initialize() {
	setPresence()
	subscribe(presenceSensors, "presence", "presenceHandler")
}

def presenceHandler(evt) {
	setPresence()
}

def setPresence(){
	def presentCounter = 0
    
    presenceSensors.each {
    	if (it.currentValue("presence") == "present") {
        	presentCounter++
        }
    }
    
    log.debug("presentCounter: ${presentCounter}, simulatedPresence: ${simulatedPresence.currentValue("presence")}")
    
    if (presentCounter > 0) {
    	if (simulatedPresence.currentValue("presence") != "present") {
    		simulatedPresence.arrived()
            log.debug("Arrived")
        }
    } else {
    	if (simulatedPresence.currentValue("presence") != "not present") {
    		simulatedPresence.departed()
            log.debug("Departed")
        }
    }
}
11 Likes

Thank you for the work and your help. I was looking to do something like this as well, in order to improve the way that ST works with Presence sensors. I wanted to incorporate a HA Lock, but did not want it firing randomly without verification of two devices arriving home at the same time.

Thanks, I’m hoping to use this to set my thermostat to ‘home’ and ‘away’ using IFTTT… Thanks!

Question, @baldeagle072, do you have this in Github?

NM, I found it: https://github.com/baldeagle072/SmartThingsOther/blob/master/smartapps/baldeagle072/everyones-presence.groovy

Likewise, this is awesome! It seems odd that IFTTT doesn’t allow Modes to be used as a trigger. If it did then this wouldn’t be necessary because you could just say “whenever my Hub is in Away Mode [which would be based on “everyone’s presence”], then…”. Anyways, this definitely bridges the gap. Thanks!

Updated link:

I like this (setting a single simulated presence) better than using something that is tied to specific modes or routines, like Nobody’s Home. Thanks!

Oops… I can accidentally change the simulated sensor. I better not put it in my SmartTiles.

My thanks to baldeagle072 for Everyone’s Presence. I’m using it to pass joint presence status to HomeKit via Homebridge. Easy to install and is working great!

Howdy,
Is there any possibility a version of this could be written so Everyone’s presence could trigger an event?

I’d like to have ST recognize that every member of the family is home, and once the last member arrives, turn off the outside lights (after a set interval).

where should I post the code? after I created de SPS I didn’t see this option

Follow the instructions on adding a custom SmartApp: https://thingsthataresmart.wiki/index.php?title=Using_Custom_Code

I am completly null on coding can you help me please?

I had to set up a new phone after the new app was just released, June 2021. I can not find where to add the Everyone’s Presence smart app and tie it to a phone and a simulated presence sensor in the new app. Looks like it is missing.

With the new app I can not seem to add the custom smart app. The do not show under smart app now.

Any ideas?

To assign that SmartApp to a specific device:

  1. Open the ST mobile app.
  2. Go to the Dashboard, then click on the Marketplace icon (the multicolored asterisk in the lower right).
  3. Choose SmartApps
  4. Scroll down to the My Apps section all the way at the bottom and choose it.
  5. Scroll down to find the custom smartapp you want, then install it.
  6. Follow the set up wizard instructions for that smartapp.
1 Like

See this thread: Did we lose the ability to add custom smartapps after the app update of June 2021?

1 Like