Anyone seen this (Find internal positioning)?

Yes, server should run always. It do all magic.
You can use public if you don’t mind

Have you tried tuning the parameters? You can change the mixin paramter between 0 and 1 which will bias the calculation to one of two algorithms. Also are you monitoring random forests? That is a third algorithm that some people report doing better. In general, also try adding more learning, maybe a few hundred points.

I’m using public FIND server. How use random forest on it?
And another question regarding mixin. 0 use Naive-bayes and 1 use RF. Am I right?

how do you get the find server to autostart when the rpi first boots up?

I don’t know about rpi (maybe google about adding a startup service), I did it on Ubuntu, but the important part is that the start command must include a change to the working directory, something like:

cd <your-path>/go/src/find && ./find -mqtt localhost:1883 -mqttadmin mqtt_find_user -mqttadminpass mqtt_find_user_pwd > /var/log/find.log 2>&1 &

got it I used

crontab -e

@reboot cd &lt;your-path&gt;/go/src/find && ./find -mqtt localhost:1883 -mqttadmin USERNAME -mqttadminpass PASSWORD &

seems to be working fine now on restart thanks again mrmep

Ok - so I’ve given this a go and it’s working great over the public server. What I’d really like to do is run my own server alongside my hass.io installation on my pi. I think I should be able to do this by installing find as an add on, but am struggling to get it to work.

I’ve set up the config.json file as below, and was expecting (hoping) that this would copy the docker hub image across - however it doesn’t seem to be working (does not even install the add on). I’ve been experimenting with various details in the dockerfile and run.sh files in my addons\find folder, but haven’t found something that works.

Am I on the right track or have I missed something? Apologies for the novice questions, as I’m going up a steep learning curve.

config.json:
{
“name”: “Find”,
“version”: “latest”,
“slug”: “find location server”,
“image”: “schollz/find”,
“description”: “Find by Zack Schollz”,
“url”: “Docker”,
“startup”: “before”,
“boot”: “auto”,
“options”: {},
“schema”: {}
}

1 Like

This looks like a great project :slight_smile:

Will you provide FIND as a component to Hass.io for a easy install?
Integrations - Home Assistant

Hi @schollz

I’ve set up my local FIND server and up till now it was working fine, however I now get …

2017/12/04 18:17:31 [Recovery] panic recovered:
GET /location?group=izzywizzy&user=keithh666 HTTP/1.1
Host: 192.168.1.254:8003
Accept-Encoding: identity

runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/runtime/panic.go:458 (0x89134)
gopanic: // ran out of deferred calls - old-school panic now
/usr/local/go/src/runtime/panic.go:62 (0x875ac)
panicmem: // the arguments of fn are in a perilous state. The stack map
/usr/local/go/src/runtime/sigpanic_unix.go:24 (0x9ffb0)
sigpanic: panicmem()
/usr/local/go/src/fmt/print.go:182 (0xdfe34)
Fprintf: // These routines end in ‘f’ and take a format string.
/home/zns/Documents/find/rf.go:85 (0x45ba4)
/home/zns/Documents/find/api.go:312 (0x14408)
/home/zns/Documents/find/api.go:409 (0x15ef0)
/home/zns/work/src/github.com/gin-gonic/gin/context.go:98 (0x1ae2ec)
/home/zns/work/src/github.com/gin-gonic/contrib/sessions/sessions.go:65 (0x251b80)
/home/zns/work/src/github.com/gin-gonic/gin/context.go:98 (0x1ae2ec)
/home/zns/work/src/github.com/gin-gonic/gin/recovery.go:45 (0x1bda90)
/home/zns/work/src/github.com/gin-gonic/gin/context.go:98 (0x1ae2ec)
/home/zns/work/src/github.com/gin-gonic/gin/logger.go:77 (0x1bcedc)
/home/zns/work/src/github.com/gin-gonic/gin/context.go:98 (0x1ae2ec)
/home/zns/work/src/github.com/gin-gonic/gin/gin.go:290 (0x1b43ec)
/home/zns/work/src/github.com/gin-gonic/gin/gin.go:271 (0x1b40f8)
/usr/local/go/src/net/http/server.go:2202 (0x135f18)
serverHandler.ServeHTTP: name string
/usr/local/go/src/net/http/server.go:1579 (0x133108)
(*conn).serve: type ServeMux struct {
/usr/local/go/src/runtime/asm_arm.s:998 (0xc20cc)
goexit: MOVW R0, m_fastrand(R1)

When HA tries to get my location, it seems to be a memory problem?

@keithh666 Could you open this as an issue on Github? Its easier to have this discussion there. Are you using Random Forests (-rf)?

Ahhh you just made me think, I think it’s because I didn’t start rf, let me go try…

Yep … that was it :slight_smile: Thanks :smile: I must find a way to automatically start both of them :stuck_out_tongue:

rc.local maybe or systemd?

Here is my guide to getting FIND working… any comments let me know :slight_smile:
Quick and dirty guide to installing and runing FIND on Hassbian/AIO install
ssh into your pi
make a find directory
mkdir find
mine is under /home/pi
I then downloaded the server binary
https://github.com/schollz/find/releases/download/v2.4.1/find_2.4.1_linux_arm.zip
(This will likely change in the future so check the release names and edit the above as appropriate)
to my pc, unzipped it and then downloaded the files to my pi with winscp - you can
probably download it directly then unzip and copy the files into the find dir. However
I find it easier and quicker to do it on my pc.

You will also need the FIND fingerprint app on your Android Phone - it won’t
work on an Iphone as Apple won’t allow apps to use the wifi data :frowning:
https://play.google.com/store/apps/details?id=com.hcp.find

Back on the pi
install sklearn for python3 - needed for random forest
sudo apt install python3-sklearn

cd find
run the Random Forest python program in the background…
python3 rf.py --port 5009 &

Set the server to be executable
sudo chmod 777 findserver

Last but not least run the FIND server - probably best to do this in a seperate ssh
shell as it outputs stuff to the terminal window

the command line is as follows :-
-rf 5009 - the random forest port from above
-mqtt ip address of your broker:1883
ip address of the pi:port

./findserver -rf 5009 -mqtt ip:1883 192.168.1.254:8003 &

Back on the app
Open the app and goto options
press change server - http://ip of pi:8003
press change user - some username - batman
press change group - some group - myhome
press go back
press learn - type in one place to learn - it takes a while to learn each place and you
have to do it multiple times, but when it works it works really well

HA config

sensor:
  - platform: rest
    resource: http://192.168.1.254:8003/location?group=myhome&user=batman
    value_template: '{{value_json.users.batman[0].location}}'
    method: GET
    name: Batmans Internal location
    scan_interval: 5

Next step is to make it all run on start up
To run both files automatically…
sudo mkdir /etc/find
sudo nano /etc/find/start.sh
#!/bin/bash
python3 rf.py --port 5009 &
./findserver -rf 5009 -mqtt 192.168.1.41:1883 192.168.1.254:8003 &

Then remember to chmod start.sh
sudo chmod +x /etc/find/start.sh

Then
sudo reboot
and check on reboot that both rf and findserver started

ps -aux |grep “python3 rf”
root 623 0.7 5.3 75956 50624 ? S 01:00 0:08 python3 rf.py --port 5009

ps -aux |grep “findserver”
root 624 24.3 1.8 797716 17236 ? Sl 01:00 5:09 ./findserver -rf 5009 -mqtt 192.168.1.41:1883 192.168.1.254:8003

In all of the above you will need to change my mqtt ip address and my HA ip address to your own :slight_smile:

3 Likes

Hello @schollz. Are random forest available on your public server?

Thanks for this but got stuck on this line, unable to locate package

You may have to install dependencies …

pip install numpy, scipy, scikit-learn

What are you trying to install it on?

Also are you using pip3?

BTW you don’t need RF to run FIND, so you can leave out all the RF bits :slight_smile:

thanks running on pi, managed to get it working using pip3

1 Like

Hey, So I have this all setup and working nicely now but i’m just trying to work out how i can use it to integrate with my already setup devices to appear at the top of homeassistant rather than separate sensors?

Am I able to use https://home-assistant.io/components/device_tracker.mqtt/ ?

I used the above :slight_smile:

sensor:
  - platform: rest
    resource: http://192.168.1.254:8003/location?group=myhome&user=batman
    value_template: '{{value_json.users.batman[0].location}}'
    method: GET
    name: Batmans Internal location
    scan_interval: 5 

but I can’t seem to get that hooked into the device_tracker.

Any tips or suggestions ? :smiley:

If you want it hooked into the device tracker you need the mqtt device tracker component.

~Cheers

Hey Thanks, however I can’t seem to get it to work? Is there a particular configuration i need to use?

I’ve tried:

device_tracker:
  - platform: mqtt
    devices:
      name1: 'group/location/name1'
      name2: 'group/location/name2'

I don’t know how this actually works as I have never done this myself but what may be the case here is that you need actually have set up the zones that get reported by find. Did you look into the topic of the MQTT server and have a look at what actually gets published there?

~Cheers