Presence Sensors

@mike.maxwell, @mattw, @dalenberg

My HubDuino (ST_Anything) supports Child Presence Devices. This was a recent addition for a ST user (long story...:wink: )

I am guessing that the Asus router code could be modified to send the properly formatted LAN packet (no OUATH required) to my HubDuino Bridge Driver / Service Manager App / Child Presence Sensor Driver. It just needs a LAN packet that contains the string "presence1 present" or "presence1 not_present" for the driver to parse() and create events for the service manager to use to automagically create child devices and keep them up to date.

2 Likes

I gave that code a shot, it works great. I added this to the update method so I could get the right urls:

def updated() {
    log.debug "away url: ${fullLocalApiServerUrl('away')}?access_token=${state.accessToken}"
    log.debug "home url: ${fullLocalApiServerUrl('home')}?access_token=${state.accessToken}"
}

Here is what I get in the logs:

2018-03-15 16:12:33.795:debughome url: http://192.168.1.15/apps/api/776/home?access_token=2a16f329-7e13-4d62-b925-7682abdc7985
2018-03-15 16:12:33.790:debugaway url: http://192.168.1.15/apps/api/776/away?access_token=2a16f329-7e13-4d62-b925-7682abdc7985

here are the commands I used to invoke:

curl -X POST "http://192.168.1.15/apps/api/776/home?access_token=2a16f329-7e13-4d62-b925-7682abdc7985"
curl -X POST "http://192.168.1.15/apps/api/776/away?access_token=2a16f329-7e13-4d62-b925-7682abdc7985"

With the new version of the hub 1.0.3 (available today) you can also call it like this:

curl -H "Authorization: Bearer 2a16f329-7e13-4d62-b925-7682abdc7985" -X POST "http://192.168.1.15/apps/api/776/home"
curl -H "Authorization: Bearer 2a16f329-7e13-4d62-b925-7682abdc7985" -X POST "http://192.168.1.15/apps/api/776/away"
3 Likes

I must be missing something here. I followed the guide here adding in the log.debug you showed above, edited the CheckUser file to just have my and my wife’s phone mac address and replaced the curl commands as you’ve shown above, but with my own ip, api # and access tokens. I’m getting the following error on the CheckIfHome script:

./CheckIfHome: line 13: qcsapi_sockrpc: not found
[: 0: unknown operand

If I try to post the curl command directly, I get a html error 500 response to:

curl -X POST "http://192.168.x.x/apps/api/391/home?access_token=fa7a7129-0382-4f53-xxxx-bf659f9f5226"

I got it sorted out. Whew.

I seem to be missing something. I cannot get anything to show up in my logs. Totally empty. Not just for this app/device, but for everything. What am I missing, I’m sure its probably pretty simple. Thanks in advance

Can you give the steps necessary to find my appid? Also the API #? I'm brand new here, so I may figure it out on my own, but it's taking me a while to understand how to find these things. :slight_smile:

At this moment, I have the app installed, I added the debug code you provided. I even created a virtual presense sensor and used the app and pointed to that sensor. But cannot find the info to add to my router script.

Thanks in advance

For each copy of the AsusWRT Wifi Presence app you install, selecting the (i) will give you the app id in the url at the top <ipaddress>/installedapp/status/<appid>

And if you selected oAuth when you installed the app driver, the access token will be listed as well on that page.

Awesome thanks for the tip. I’ve now got two presence sensors working with my asus router. Same as I had with ST. I like to use wifi for unlocking doors, because it requires me to be even closer to the house.

In order to get the Asus presence i need to install HubDuino right? I have it all working on smartthings.

Ummmm, no. Asus Presence is a combination of an Asus Router and an OAUTH App running directly on the Hubitat hub.

HubDuino is used for integrating an Arduino or ESP8266 with Hubitat. Two completely different things.

Earlier, I was only suggesting that one could follow the HubDuino design in order to implement Asus Presence on Hubitat without the need for an OAUTH App.

Sorry for any confusion!

No? I have an app installed in Hubitat called AsusWRT wifi presence.

Asus also supports IFTTT and can trigger something (i.e. a Hubitat virtual switch) when a device connects. However, and for unknown reasons, they don't have an IFTTT service for when a device disconnects, unlike TP-Link and Google WiFi which support both connect and disconnect triggers.

can you point me to this app

Scroll up: I think it's just the smartthings app unedited.

Is there a ping command that we can use in a dh? If yes then this could be a way to detect presence. But only if our phone is getting static IP from the router. @mike.maxwell is this possible?

I installed the app and then added a virtual sensor. When i try to hit
http://192.168.2x.x/apps/api/324/home?access_token=xxx i get error 500 from a browser.

324 is the url when i goto http://192.168.2x.x/installedapp/status/324

any ideas what i am missing should this work in a browser?

You have AsusWRT Merlin installed on your router?

Yes everything works on smarthings. I installed the same app in hubitat.

All working i needed to check the app per Chuck's post and then use the curl -H commands.

1 Like

Been trying to get this to work with no success. This works fine in SmartThings but tried the various commands in this thread to no avail. Was there something that has changed in the recent firmware to cause this to no longer work?

OK. Finally got it working. Was using an older version of the app and not the one posted in this thread.