Use a virtual switch to determine presence?

Looking to find a way to make a virtual switches status determine presence of a individual. If the switch is on then Home & Family shows the user “is present” and it the switch is off then the user “is not present”.

I’ve been able to create the Virtual switch and have it controlled by a IFTTT recipe for when I’m connected/ disconnected to my home WiFi. Geo fencing doesn’t really work for condo living.

I’ve search through the forum and haven’t been able to find a solution for this. I’ve looked at some rule engines but none have done what I desire to happen. Anyone have any thoughts or working solutions?

I want something like this too, just habving to press a button to let know my home im here :smile:

@baldeagle072 has previously posted some code for this, but I’m having double vision right now (happens) and can’t search for it. Hopefully he’ll add to the discussion.

Switch on/off has been automated as your phone connects and discounts from the WiFi. It would just be a better indicator that I’m home rather than across the street at the clubhouse. Least thing I want is events to be triggered for “present” when I’m not.

Here is the post. For virtual presence and switch. I use this on my action-dashboard Little help: Magic Home meets IFTTT?

Beat me to it. :smile:

1 Like

OK, looked at the other post and seems like it will work. Having problems creating the virtual presence thought. Any device I create is not seen when configuring the Virtual Presence. My switch is seen but nothing under the Virtual Presence setting. What am I missing here?

Do you see the simulated switch and simulated presence you created in Ide under devices? Don’t forget to publish it. Maybe you need to log out of you phone and back in. Here’s another link on creating virtual switch FAQ: Creating a virtual Device

Thank you for creating all the useful little apps!

If you are on Android, you can use Tasker to control your presence - either automated via WiFi connection as you indicated or manual by tapping a widget on your home screen.

For most users, I would recommend using a multi-faceted location solution that uses GPS and WiFi such as AutoLocation, but I can see how using WiFi alone might be better in your case.

@baldeagle072 code is working. Been using Tasker which is working but trying to get the ITFFF recipe to work (since its already installed) with my Nexus 5. It will report properly when I connect to WiFi, but not when I disconnect from the WiFi… separate issue though. Thank you all for you thoughts and direction.

I just thought i woud share something that took me awhile to figure out. The best solution for this problem is to make a new device type that is both a presence sensor AND a switch. This way, you can expose the presence sensor directly to other applications like IFTT to allow them to toggle your presence on and off. You can then make use of any facility you want for presence

  • IFTT Geofence

  • IFTT Based on Wifi Association

  • Other

    * Copyright 2015 SmartThings
    * 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:
    * 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.
    metadata {
    definition (name: “Presence Switch”, namespace: “smartthings”, author: “SmartThings”) {
    capability "Presence Sensor"
    capability "Sensor"
    capability “Switch”

      simulator {
      	status "present": "presence: 1"
      	status "not present": "presence: 0"
      tiles {
      	standardTile("presence", "device.presence", width: 2, height: 2, canChangeBackground: true) {
      		state("present", labelIcon:"", backgroundColor:"#53a7c0")
      		state("not present", labelIcon:"", backgroundColor:"#ffffff")
          standardTile("button", "device.switch", width: 2, height: 2, canChangeIcon: false) {
      		state "off", label: 'Off', action: "switch.on", icon: "st.Kids.kid10", backgroundColor: "#ffffff", nextState: "on"
      		state "on", label: 'On', action: "", icon: "st.Kids.kid10", backgroundColor: "#79b821", nextState: "off"
      	main "presence"
      def parse(String description) {
      def name = parseName(description)
      def value = parseValue(description)
      def linkText = getLinkText(device)
      def descriptionText = parseDescriptionText(linkText, value, description)
      def handlerName = getState(value)
      def isStateChange = isStateChange(device, name, value)
      def results = [
      	name: name,
      	value: value,
      	unit: null,
      	linkText: linkText,
      	descriptionText: descriptionText,
      	handlerName: handlerName,
      	isStateChange: isStateChange,
      	displayed: displayed(description, isStateChange)
      log.debug "Parse returned $results.descriptionText"
      return results


    def on() {
    sendEvent(displayed: true, isStateChange: true, name: “presence”, value: “present”, descriptionText: “$device.displayName is $v”)

    def off() {
    sendEvent(displayed: true, isStateChange: true, name: “presence”, value: “not present”, descriptionText: “$device.displayName is $v”)

    private String parseName(String description) {
    if (description?.startsWith("presence: ")) {
    return “presence”

    private String parseValue(String description) {
    switch(description) {
    case “presence: 1”: return "present"
    case “presence: 0”: return "not present"
    default: return description

    private parseDescriptionText(String linkText, String value, String description) {
    switch(value) {
    case “present”: return "$linkText has arrived"
    case “not present”: return "$linkText has left"
    default: return value

    private getState(String value) {
    switch(value) {
    case “present”: return "arrived"
    case “not present”: return "left"
    default: return value

1 Like