Find: High-precision indoor positioning framework for most wifi-enabled devices

Awesome Find Rich! See what I did there. :joy:

Very very interesting @rlkoshak!

Slightly off-topic, again as part of the presence detection
I was wondering if it was possible to detect the presence of devices in the proximity of my wifi AP but not (yet) connected. The example can be a friend who comes to visit me at home and his phone will not connect to my wifi (maybe does not have the password).
In this way my automation would know if there is “a stranger” in the house!
I came across these readings: here, here and here
I have to go deepen …

@villaRob, it looks it might be possible through packet capturing but that will require the friend’s phone to have wifi enabled and for the phone to be actively probing to find a wifi device to connect to. The odds are actually pretty decent that will be the case but you will not find all phones all the time.

You could do something similar with Bluetooth but as far as I have been able to figure out, their phone needs to be in pairing mode for the standard BT libraries to find it.

What could end in the same pitfall, I have usually switched off Bluetooth :slight_smile:

Hello!

I’ve installed and tried FIND and it does work pretty well, at least with their dashboard. The thing I’m not sure about is, how to access this data to use it in OH? I’ve tried searching their website, but I could not find any mention of API or something similar I could use. Do you have any idea how to utilize this?

Best regards,
Davor

From my initial investigation you can use the following REST call:

http://<server/port>/location/{group}/{user}

Doing so will give you a similar response to :

{"time":"2016-04-19 16:37:15.453137166 -0400 EDT","location":"kitchen","bayes":{"bedroom":0.2162923607006726,"frontroom":-0.6973330125963102,"kitchen":0.48104065189563866}}

which you can extract the location from.

Edit: I found the following link which looks useful

Thank you for the quick reply. I’ll try to make some rule to utilize this, and if I make some progress, I’ll post it here.

Best regards,
Davor

Hi @danielwalters86, I just changed this API - sorry! Its more of a typical GET REST call now:

http://<server/port>/location?group={group}&user={user}

You can also leave user off and it will give you all the users. The link you found is indeed the API link (which should stay up-to-date) but its a little hidden since its not quite frozen yet :). Please let me know if you’d like more functionality for your purposes - I’m happy to make more routes.

1 Like

I went through the steps of creating a password and I can connect to the ml.internalpositioning.com mqtt server but I don’t see and updates when I subscribe to the channel “YOURGROUP/location/#”. yes I replaced it with my group name.

Thanks for letting me know. Try now. I noticed that I had forget to reset the mosquitto PID on the server (I opened an issue so I don’t make this mistake again: #94 ).

Hi @schollz

I thought the idea of Find sounded quite cool so I’ve had it up and running on my RPi for about 2-3 weeks now. Unfortunately I haven’t had any specific use cases for it outside of just tinkering with it. However last night I had an idea - I created a quick proof of concept for “follow me music” using openHAB2.

I’ve got the squeezelite addon running on my Kodi media machine and a separate RPi running piCoreplayer (another squeezelite client) connected to a portable stereo. I’m also using the SqueezeBox binding for OH2.

The basics were as follows:

  • I have an item bound to the results of a user location query in Find (using HTTP Binding)
  • I have a Thing set up for my Kodi squeezelite client
  • I have a Thing set up for the pCp squeezelite client
  • I have a rule setup that changes which player the music plays from based on the result of the Find location query

General comments / conclusions:

  • It was cool to have the music follow me to the correct speakers depending on the location :smiley:

  • The refresh on the HTTP binding was set to 15 seconds. The Find server had usually updated my location within 1 poll interval of me arriving in a location. I have some PIR motion sensors for lights and they react almost instananeous, I don’t think Find would be suitable for this purpose (at least in this setup - maybe websockets would help?).

  • A users location doesn’t seem to timeout, so I would probably need to check the last seen timestamp to make a sensible call whether to trust the result of the Find user location query.

  • Tracking works well when the Android app is in tracking mode in the foreground but when the app goes into the background it stops tracking (this is on Android Marshmallow - don’t know if the app is getting Doze’d or not)

Hopefully this may give people some inspiration. Maybe even some inspiration to you @schollz to keep up the good work.

If anyone else has innovative ideas for using Find I’d love to hear them!

2 Likes

I added a Application integration page to start with https://github.com/openhab/openhab/wiki/FIND

I found I needed to add my username after /location/ to get the data to populate in Openhab.

2 Likes

Hi @danielwalters86!

That is such a Awesome Idea! I love it. :smile: Variation on the theme: What about making a Pi-powered boombox that you can carry around and it plays different music in different rooms?

Some comments:

I have some PIR motion sensors for lights and they react almost instananeous, I don’t think Find would be suitable for this purpose.

You’re definitely right - if you need instantaneous motion sensing a PIR sensor is better. FIND is limited by the scanning frequency, which typically can’t be faster than once every 2 seconds on most devices. Your polling interval of 15 seconds with FIND could probably be shortened. Realistically it usually takes two scans to get a good result, so I’d use a polling time of 4-6 seconds.

need to check the last seen timestamp to make a sensible call whether to trust the result of the Find user location query

Currently the “location” guess is the location with the highest value Bayes measurement, so there are times you might not trust it. If you call the /location route or use mqtt you’ll also get all the Bayes and SVM information -lots more info. There might be extra benefit in using this extra information to make a better call of the current location. Perhaps using a confidence threshold computed from the actual Bayes scores to ignore “bad” classifications, or using previous locations to make a better guess of where you are (i.e. if its impossible to go from one room to another in < 2 seconds). I’m totally open to implementing this if you think it would help.

when the app goes into the background it stops tracking

This might be a bug…the phone should keep tracking in background mode. Try this, if you hit “Tracking” and then hit your homescreen button, do you should see the FIND symbol in your upper dash? The phone should still be transmitting. However, there is an issue with tracking/learning when the phone sleeps (usually 30 seconds after no activity). In the sleep mode tracking/learning also still happens, but the polling time can increase to up to 2 minutes. See issue #60 in the Github for some data on this (sorry I can’t seem to post anymore links to the github in this thread!). Please let me know if the former is a problem, as that may be another issue I haven’t seen!

I added the JSONPATH transform so now it pulls just the current location name string to the item.

String  mqqtfind_david              "David FIND [%s]"   (All)   {mqtt="<[find:YOURGROUP/location/USERNAME:state:JSONPATH($.location)]"}

I can imagine that blowing people’s mind when they can’t work out why the music changes with the room! :joy:

My point was a lot more simple than that. Here’s the current output from my Find server:

{"message":"Correctly found locations.","success":true,"users":{"daniel":[{"time":"2016-05-11 22:52:24.706419487 +0100 BST","location":"bedroom","bayes":{"bathroom":-0.4242640687119286,"bedroom":0.4242640687119286},"svm":null}]}}

The last updated time is several days old but the location is still set to bedroom even though I’m no longer in the bedroom.

Edit: @schollz I opened Find, hit tracking mode and checked the Find response. Time was 18:32. I then hit the home button, checked the icon was in the notification bar and went about my business for a bit. Checked back just now and the time is still 18:32.

Thanks @danielwalters86. These sound like bugs to me. :blush:

I think they might be server-based, so would you be so kind as to send me your database and log file (if your running locally) or send me your Group name (if your using the public server)? You can send privately via the email address on the Github README.

I can’t find the log file. Where should I be looking?

The MQTT server is sending an update once every 3 seconds!

2016-05-13 12:58:17	smokeing
2016-05-13 12:58:20	smokeing
2016-05-13 12:58:23	frontconference
2016-05-13 12:58:26	frontconference
2016-05-13 12:59:12	smokeing
2016-05-13 12:59:14	smokeing
2016-05-13 12:59:17	frontconference
2016-05-13 12:59:20	frontconference
2016-05-13 12:59:39	frontconference
2016-05-13 12:59:42	frontconference
2016-05-13 13:00:00	frontconference
2016-05-13 13:00:04	fabrication
2016-05-13 13:00:07	fabrication
2016-05-13 13:00:16	smokeing
2016-05-13 13:00:19	smokeing
2016-05-13 13:00:22	frontconference
2016-05-13 13:00:26	frontconference
2016-05-13 13:00:46	frontconference
2016-05-13 13:00:49	frontconference
2016-05-13 13:01:10	frontconference
2016-05-13 13:01:13	frontconference
2016-05-13 13:01:19	smokeing
2016-05-13 13:01:22	smokeing
2016-05-13 13:01:25	smokeing
2016-05-13 13:01:28	smokeing
2016-05-13 13:01:54	office
2016-05-13 13:01:57	office
2016-05-13 13:02:00	office
2016-05-13 13:02:03	office
2016-05-13 13:02:06	office
2016-05-13 13:02:09	office
2016-05-13 13:02:12	office
2016-05-13 13:02:15	office
2016-05-13 13:02:18	office
2016-05-13 13:02:22	office
2016-05-13 13:02:24	office
2016-05-13 13:02:27	office
2016-05-13 13:02:30	office
2016-05-13 13:02:33	office
2016-05-13 13:02:36	office
2016-05-13 13:02:39	office
2016-05-13 13:02:42	office
2016-05-13 13:02:45	office
2016-05-13 13:02:48	office
2016-05-13 13:02:52	office
2016-05-13 13:03:02	office
2016-05-13 13:03:05	office
2016-05-13 13:03:08	office
2016-05-13 13:03:11	office
2016-05-13 13:03:14	office
2016-05-13 13:03:17	office
2016-05-13 13:03:20	office
2016-05-13 13:03:23	office
2016-05-13 13:03:26	office
2016-05-13 13:03:29	office

Sorry, you won’t have a log file unless your using /etc/init.d or you ran with nohup. That’s okay, I can still glean the important info from the database file.

@LeXLuther422, the MQTT server posts on any incoming /track fingerprint, and your device should be sending a fingerprint every 2-3 seconds, so that sounds about right! Its a lot better than the polling I have to do on the dashboard which pings every 2 seconds no matter what…

Btw, thanks for adding an Application integration page - it looks great! :slight_smile: