Presence (again) via the app

this topic crosses many categories, so not sure if I posted in the right channel? :man_shrugging:

(Rather than resurrect an old thread, as I’ve posted on this before and then resolved it, I’m posting a new one)

I use the current ST Android app on my and my wife’s phones to use our location and trigger our presence for automations like “Goodbye” and “Good Return/Welcome Back” which does things like lights and switches. I’ve been struggling to get it to work properly again. I have my wife’s working perfectly it seems. Mine was working and now doesn’t. The thing that’s frustrating: as far as I can tell, my automations match my wife’s exactly, so I cannot figure out what’s the deal. I have set it up in this format:

IF DEREK is home AND virtualDerekHOMESwitch is OFF, turn virtualDerekHOMESwitch is ON.

So I have a virtual switch on or off for my wife and I, each one has our own switch, and automations run based on this switch being on or off. For example, if they are both off (we are both gone, just left), Goodbye will run.

Again, it now apparently works perfectly for my wife, but not mine. I do the virtual switches to be able to analyze problems like this, though I understand there are other ways to do it. For instance, if we are both at home, and I turn my wife’s presence virtual switch off, it instantly turns back on due to the automations. Mine will stay off though, and won’t turn back on. It’s as if somehow my presence isn’t being detected at all. Yet I have the location functions turned on in my phone’s app.

What’s changed on my end: got a new Android phone: it has Android 12. I have the latest app. But on my Samsung account I have my new and my old device. I have my new device selected for the automations, but now that I’m troubleshooting, I just removed my old device from the ST app, though I think it might be in the account somewhere online still. (I had thought to keep my old device as a ST interface, but maybe it won’t work out well on the same account.)

I’m just babbling here, giving all the info I can think of, in hopes someone might see a tidbit and realize this is my problem area and to focus my attention on that. If you see anything or have any ideas, I appreciate your help!

(PS: this always comes up, yes I know you can use dedicated presence devices, but I don’t want one of these.)

You didn’t say what your phone manufacture is ? If its a modern Samsung there is an alternate way worth a try but you need to use a Bixby routine which detects wifi connection


It is a Samsung S20 FE, but I hate to use Bixby… it is disabled currently. My wife’s phone, also with Bixby disabled, is a Samsung S9.

@JDRoberts I saw you moved this to an appropriate category, but is this really an Android specific issue?

Presence breaks in many different ways for many different reasons. :disappointed_relieved:

In your case, you said that what was new was that you had gotten a new Android phone and that your wife’s older Android phone did not develop the same problem at the same time. So that likely eliminates the typical ST routine setup issues but puts a spotlight on something possibly Android-specific.

As you noted, it’s potentially a problem that overlaps a number of categories, so if you’d rather put it somewhere else, go ahead. Your choice. But if it is something to do with a specific Android build, or the way that you disabled Bixby, you’re more likely to get an answer here, I think.

For example, I have read that on a Galaxy 9 you can’t really disable Bixby, just mute it, but you can fully disable it on the newest phones. You wouldn’t think that would break something in SmartThings, but I wouldn’t bet against it. :thinking:

1 Like

I don’t use Bixby either, just the routines it offers, Bixby is Samsungs voice control but it also encompasses automations you don’t need to speak to it or interact with it apart from creating the routine

It is worth looking at the options Bixby routines offer and using them, you have options

( if )arriving and leaving your defined area or wifi strength, wifi connection

(Then) trigger an ST device or scene


Found a little secret. Dunno if this is unique to my wife’s phone, but… her Samsung phone wakes up when pinged. It might take a couple seconds, but it does. (My iPhone does no such thing.)

I’ve already created Webcore pistons that run based on events sent by EventGhost. The Ping event registers in EventtGhost. There are plugins and scripts that can check for the existence of data in a file.

So the concept is to have a Scheduled Event that pings the Samsung phone. Twice. Once to wake it up if it’s there, the next to capture the result. It overwrites the existing data.

On seeing the event occur, EventGhost waits a few seconds, then checks for the existence in the file of “time=“ which indicates a response to the ping. It compares that to an existing variable, set by the prior result. If the variable said the device was present and it now no longer is present, the variable changes. This triggers the send of the variable to the piston endpoint, changing the virtual presence sensor.

This will not be enough to trigger a door unlock event or anything like that. It would have to run continuously, and hope the phone had connected to the network…. and I’ve no interest in doing that. But for general creature comfort things, she always takes her phone with her - so it would know relatively quickly when she has left, and when she has returned. It could adjust a thermostat accordingly or something.

I might test it on a one ping every 5 seconds basis for awhile, just for kicks. See what happens. Might set it up such that the status of the variable, combined with a daily schedule, on the PC dictates the frequency of ping. So that if she’s home it only pings once every ten minutes - and if it finds she has left during daylight hours, it pings once every 5 seconds or something until she returns.

EDIT: the ST presence sensor apparently gets pinged every 30 seconds. So I will try a shorter span, say every 20 seconds, with the phone.

1 Like

Here are the batch file contents to accomplish this:

ping -n 2 |find “TTL=” || “C:\Program Files (x86)\EventGhost\EventGhost.exe” “-event” “wifeout”

ping -n 2 |find “TTL=” && “C:\Program Files (x86)\EventGhost\EventGhost.exe” “-event” “wifehome”

The first line pings, and looks to see if the ping does NOT include “TTL=” which is included in every successful ping. If that’s not included, it generates an EventGhost event called Main:wifeout.

The second line pings, and looks to see if the result DOES include “TTL=”. At which point, it logs Main:wifehome in EventGhost.

EventGhost is then programmed to, upon receiving either of those events, change the state of a virtual presence via Webcore.

In testing, it works. Question will be whether it works in real-world, as she comes and goes. Will be interesting. Next step is to figure out how to get it to run appropriately - every 20 seconds when she’s not here to detect her return, and every ten minutes when she is here. Might have to have separate commands.

It is the other way around. It is the arrival/presence sensor pinging every 20 seconds. so ‘not present’ is an absence of received pings for a defined duration.

If we think of it in terms of a test for presence, then it is highly specific. You aren’t going to get a false positive. However there might be a sensitivity problem as if the phone is off, WiFi disconnected, or there is a transient connectivity problem then you will get a false negative.

You may need to consider it like the arrival sensor and wait for multiple negatives before asserting ‘not present’.

My immediate thought about 10 minutes v 20 seconds pings is that it only works one way.

Do you have a short timeout on the pings?

1 Like

Each ping is twice, so between the two that’s four seconds. I cannot account for power issues (phone off, WiFi off) of course. But it is four pings in four seconds, and if all come back negative it will try again in 20 seconds. So the “false negative” is not highly likely.

And as long as I’m willing to have a hidden command window open in the background at all times, I can of course just build the batch file into a loop. The errorlevel result if the ping test series comes back positive is 0, and if negative is 1. So
If not errorlevel 0, pause 20 seconds
If not errorlevel 1, pause 900 seconds
go to top

would do the job.

I will, however, shut it down at night. Have it run only at times she’s likely to go out.

EDIT: it occurs to me that, if it’s going to be in a constantly looping batch file, there’s no need to even write the EventGhost event unless the presence changes. So a variable, %presence%, gets compared to the errorlevel. If the %presence% is 0 and %errorlevel% is 1, then write the EventGhost event and set %presence%=%errorlevel%. And the reverse of course. But if %presence%=%errorlevel%? No need to do anything but return to the top of the loop.

A better batch file. It no longer bothers with errorlevel, instead using a %presence% variable to compare to an %indicator%.

set presence=home
setlocal EnableDelayedExpansion

set “time_to_compare=220000”

for /F “skip=1 delims=.” %%A IN (‘wmic OS get localdatetime’) do (
for /F “delims=” %%B IN ("%%A") do (
set “_time=%%B”
if !_time:~-6! GEQ 220000 (call :after) else (call :before)

exit /b 0


if %presence%==home timeout 900

if %presence%==NOTHOME timeout 20

ping -n 2 192.168.1.x |find “TTL=” || set indicator=NOTHOME

ping -n 2 192.168.1.x |find “TTL=” && set indicator=home

if %indicator%==%presence% echo ----no change—

if %indicator% NEQ %presence% if %presence%==home (
|| “C:\Program Files (x86)\EventGhost\EventGhost.exe” “-event” “wifeout”
set presence=NOTHOME

if %indicator% NEQ %presence% if %presence%==NOTHOME (
|| “C:\Program Files (x86)\EventGhost\EventGhost.exe” “-event” “wifehome”
set presence=home

goto start

Ok, this works. Real world, it turned on the front light and unlocked the door this morning when the phone returned to the walkway coming up to the house.

We will see how it does over time.

1 Like

I think in my case, though I expected it should’ve worked based on using my same account, i had to again set my home address in the Android app, buried under settings. It seems to be working fine, for now…

1 Like

Thanks Derek,

My presence stopped working like a week ago for some reason… But reset my home location and then it worked again.


1 Like

Glad it worked for you too!

A followup on my wife’s Samsung phone as presence via IP: it works, but twice did not unlock the front door until she was already entering her code at the keypad. Sooo….

I have a wireless router that I had just replaced. I set it up on a smart plug at the corner of the house closest to the driveway. I also increased the pings when the phone is away so that it’s pinging once every five seconds.

When the phone is away, the smart plug turns the router on. (It turns off when she returns.) The range of the wireless therefore extends at least another 25 feet into the driveway. Between the increased range and the increased distance, it should help. We’ll see over the next week.

How do you increase the pings? I too have noticed some very late notifications of my arrival, like almost to unlocking the door. Most times it recognizes my departure or arrival a block away, but no always…

Each ping takes one second if successful, takes perhaps three to time out if unsuccessful. The ‘timeout’ is the number of seconds wait time until those pings begin again.

I wish my old router had an external antenna. I could then make a yagi configuration that would reach further down the driveway. Might end up buying a cheap new router or extender specifically for this purpose!

How did you do this?

I didn’t. The phone does it. I figured it out by accident, while merely installing new routers and reserving IP addresses. I don’t know what is or isn’t set on her phone, but whatever it is it wakes up as a result of being pinged.