Presence of nearby devices using ESP8266

For a few days ago I thought about a different way to track presence, for people(friends in my case) that’s not even on my wifi. By using a ESP8266 in station mode sniffing for nearby smartphones, then posting them to my webserver which hash them and post them to my sql database.

Friend’s smartphones sends mac -> ESP8266 -> Webserver -> inserting( hashed(mac address) ) -> MySQL database.

My plan is to make a component, which loop “known_devices.yaml” and makes a HTTP_GET request with the mac address to the my webserver like: “htttp://example.com/last_active.php?mac=xx:xx:xx:xx:xx:xx”. The server then either returns TRUE or FALSE depending on whether the mac address have been detected within last 5 min or not.

The component then change the state of the device accordingly.

I haven’t make any custom components so fare, and pretty lost where to start, but I do have lots of experience with python. How can I do this using Home Assistant, maybe just as a rough coding example? Could be awesome to make this work, and have yet another method to check for user presence :smile:

If anyone would be interested in the code for the php code run by the webserver and the ESP8266 sniffing code as well as the database table. I’ll happily make a clean version and share it :smile:

1 Like

Why don’t you use the rest API instead, and whenever you see a phone notify home assistant. If you haven’t seen a Mac for some time - notify HASS the device is no longer present. I think it’s much easier than writing a custom HASS component.

Check out here:

The API call you need is documented as POST /api/services/<domain>/<service> or to mark a device as present/absent: POST /api/services/device_tracker/see

1 Like

Hi, did you ever get this working, I’m interested in a similar thing