reelyActive Smart Spaces Revisited

Step 5.

Rich,
Here is my service file:

/lib/systemd/system/reelyActive.service

[Unit]
Description=reelyActive
After=network.target iptables.service firewalld.service

[Service]
Restart=always
WorkingDirectory=/reelyActive/pi-suite/node_modules
ExecStart=/reelyActive/pi-suite/node_modules/node server.js

(also tried:)
ExecStart=/usr/local/bin/node server.js
ExecStart=/home/reelyActive/pi-suite/node_modules/node server.js
ExecStart=/reelyActive/pi-suite/node_modules/sudo node server.js

[Install]
WantedBy=multi-user.target

Mike

Honestly, I haven’t done anything with RA in a couple years so I’m not going to be a whole lot of help. You might search for help on how to properly run a node.js service with systemd.

Back when I wrote the above tutorial it all just worked. I never had to deal with any problems like this.

It’s also possible that the code has changed and that 1.5 year old tutorial may no longer work.

Did you abandon using the ble detection or still use it for presence detection?

The problem is that the phones change their advertised MAC address frequently. So I could tell that an iPhone was near by, but never that my wife’s specific iPhone was near by. I suspect my new phone would behave the same. It’s a privacy feature.

Carrying around a key fob or the like really isn’t an attractive option so I stopped messing with BT detection all together.

For what I need, network detection is more than adequate to serve as presence detection.

Rich,

Agreed, my iPhone changes MAC address every time you breath. I was planning on using an Edystone for ble detection; I have one, seems to work great!. I just need to figure out the systemd problem.

Does the iPhone work with network detection if it goes into a deep sleep? I have read Mariuts28’s Tutoria and Example in Hping3 and ARP but it seems like there might be problems with the iPhone? I have an Xs and my wife has a 6s & soon to upgrade.

I am just looking for a way to speed up presence detection compared to the iCloud binding. It works but you can sit in your driveway for 5 minutes before things start happening which is not acceptable to me.

Just want you to know how much your posts have helped me out on the openHab trail. I really enjoy HA and OH has helped me fulfill my goal of localizing my HA system!

Anyway Rich, I really appreciate your input! Thank you!

When my wife had an iPhone it worked great using hping3. The hping3 stuff continues to work well with our Pixels. I run OH in Docker so couldn’t (until recently) use arping but that is reported to work well too. Though most iPhone users these days seem to use the iCloud binding.

Some have also written scripts that run on their wifi routers to report when certain devices join the network.

Hi all!

Coming late to this conversation, and with absolutely zero knowledge about OH and reelyActive, I’m just trying to evaluate if these tools are worth investing in to create the following solution:

  • Environment: schools
  • Equipment: BLE keyfob or custom wearable (under development), we can create a whitelist of authorized devices
  • Goal: determine if/when teachers, staff and children are in the school and in which classroom. The neighbour school director asked me to imagine a system which could be used on emergency conditions to display whether any people in in or out of the school, should the building be evacuated or locked down.

Constraints

  1. Schools are, by definition, installed in public areas, so many BT devices could be detected; whilelist seems mandatory to sort people out…
  2. Need to manage lots of devices: a typical school is 200 children, 15 teachers, 5 to 8 staff
  3. Need to detect several devices concurrently: up to 20 children may enter the school at the same time.
  4. Children are not so quiet when arriving at school :wink:, so the system accuracy should be high enough to discriminate when one or several children have crossed the virtual entry line and are 1m inside the school perimeter (iow “really” entered the school and not swinging across the doorstep)

Questions

I’ve read with great attention the above thread and come with a few questions:

  • I plan to put 3 receivers (Pi 0?) per classroom + 1 central computer (Pi 4?) to create a live map of all positions: is it enough? too much?
  • What’s the accuracy I can expect from such a solution (OH + reelyActive) + hw above?
  • What’s the lowest scan interval I need to achieve constraint #4?

Thanks in advance for any help!

Since these questions are really specific to the reelyActive system and not about OH, you will be better off asking the folks over at reelyActive. I don’t know if they monitor this thread or pay attention to OH much these days. But doing the sorts of things you describe sounds a lot like the sorts of things it was designed to do.

Thanks Rich, this is probably the best way to go! I’ll push my questions on to their developers’ forum…

Hi Jean-Luc and OH community,

We’ve made a lot of progress on our open source platform since this thread was last active, take a look at https://reelyactive.github.io/ which includes detailed tutorials on how to run on a Pi and do real-time location. Ping reelyActive via e-mail or social media if you have specific questions. Thanks!

Jeff

1 Like

Sorry Jeffrey, forgot to return to the forum… :confused: Thanks for your advice, I’m now in touch with Camille Leclerc, who’s providing much help on the topic! A future use case for your website… :wink:

Thanks again to all for your kind help!

This comment pertains to v1.x reelyActive from reelyActive.github.io:
(I posted it on this thread because I couldn’t get through the install steps in the OP and was hoping I could get something to work Frankenstein style, then troubleshoot, get a working solution, and post my update.)

I finally got the ReelyActive webpage to load [Raspberry Pi IP]:3001 via the pi-suite & the bluetooth feature (sudo npm run start-hci).

I did have a heck of a time getting this to install, but I don’t know a lot about Linux so maybe that’s why. (It kept getting stuck on the npm install command, and that was taking hours to complete & my session kept dying, but ultimately my issue was the missing dependencies indicated below in my steps.)

What worked for me: (Raspberry Pi 4 running OpenHABian)

cd  (This takes me to: /home/openhabian)
npm i bufferutil
npm install utf-8-validate
cd
mkdir reelyActive
cd reelyActive
git clone https://github.com/reelyactive/pi-suite.git
cd pi-suite
npm install --verbose   (Use verbose so you can see output; mine sat here otherwise for 30+minutes & my SSH session kept dying)
  • Testing/Usage:
sudo npm run start-hci (CTRL+C to exit)
Open in browser: [PiIP]:3001
Run a web app-> Hello Tracking (To see devices transmitting)

I tried the reelyApp on my Android phone and “Advertised” but that didn’t show up in the web app. I did see my Chromecasts and my LG tv so I know “some” of it is working. I also tried a bunch of advertising & beacon apps on my phone (my phone’s bluetooth mac does NOT change like i phones do), but couldn’t get it to show up in the web apps either. Is this expected?

Side note: I went down this install path instead of the OP’s node & reelyActive part of the install because I couldn’t get this step to install: “npm install bluetooth-hci-socket”, in step 3.

UPDATE: (For any that might come across this post and want a latest update on what works and what doesn’t) I was able to get my phone to show up with the “reelyActive” phone app “Advertise Me” function, as a Google Eddystone beacon, inside the hello-tracking & hello-sniffypedia web apps (via my Testing/Usage step above). However, when I disable Advertising in the phone app, then turn it back on, the MAC changes (new random MAC). So this must be what others have been referring to (?) - where an Android app perhaps can’t use the real bluetooth device MAC due to “security concerns”. I tried several other Android apps as well and all have the same behavior, such as: “Beacon Simulator” Android phone app: beacons show up as well in the hello-tracking & hello-sniffypedia web apps, with random MACs. What mislead me (and PLEASE correct me if I’m wrong) was that in openhab’s PaperUI I was able to add my phone as a thing via the REAL mac, therefore I figured apps would behave the same. Im thinking though that pairing your phone uses your physical bluetooth MAC, and is entirely different than transmitting a beacon via an app (which uses a random MAC). This is certainly frustrating. I’ve developed several bluetooth Android apps in the past so I could certainly look into developing an app that might overcome this, but for $19 I found an ibeacon on Amazon. My time developing the app will be at least 10-fold that, and for my purpose I just want to track general work hours for myself and my wife, so putting this beacon on our keyring or in our truck should fit the bill. (If anyone did want to create such an app perhaps I think you could overcome this random mac limitation via using a hardcoded, or user generated UUID that you would use to reference the phone, and have it run as a service on the phone. You would still then have to integrate it into openhab, but as I mentioned in my other post, I couldn’t get Richs OP install to work, so I’m not sure how then to integrate a phone via this custom app into MQTT or openhab directly.)

My issue here, and certainly no different than any other functionality from openhab I experienced in the past (its addicting to see how much you can make it do!!), was I read a ton of old information (indicating people used their phone as a beacon), and never even heard of Presence Detection or a Becon until a few days ago!

This comment pertains to v0.x reelyActive from OP:

npm install bluetooth-hci-socket

wouldn’t install for me, likely due to this issue . But it installs this way:

npm install "https://github.com/abandonware/node-bluetooth-hci-socket"

However, once I start it with “sudo node server.js” I get this error:

reelyActive barnowl instance is listening for an open IoT
reelyActive Chickadee instance is curious to associate metadata in an open IoT
/opt/reelyActiveRich/server.js:18
app.bind( { protocol: 'hci', path: 'null' } );
    ^
TypeError: app.bind is not a function
    at Object.<anonymous> (/opt/reelyActiveRich/server.js:18:5)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

Perhaps because my workaround won’t work with this, or I botched something else up.

Thanks @Kevin71246 for giving this a go and for sharing key debug output which makes it easy to identify the underlying issues.

Important Note: There are two versions of pi-suite, one based on the v0.x reelyActive open source software which @rlkoshak describes in his posts and another based on the v1.x reelyActive open source software which is what currently recommend.

Most of the issues in the above two posts stem from mixing the two in ways which will break things.

If you’d like to replicate what’s described earlier in this thread (based on v0.x), I suggest following the original pi-suite tutorial/code where the dependencies should still work with Node.js versions 8 and below. The challenge is that the hci-bluetooth-socket package has stopped being maintained by its original author, and Node.js has “outgrown” it in recent versions. It needs to be swapped out for abandonware/hci-bluetooth-socket as you’ve (painfully) discovered, likely because you’re on a recent version of Node.js.

If a member of the OpenHAB community would like to extend the integration to the current (v1.x) version, it might be easiest to simply integrate the barnowl-hci code which will provide the real-time data stream of BLE decodings: https://github.com/reelyactive/barnowl-hci

Let us know and we’ll do our best to support!

@Jeffrey_Dungen I appreciate the feedback! I updated my above post to reflect the fact that I got a lot of your demo working with various Android apps. (Once I got your newer version installed, I’m not sure if my issue with “getting my phone & transmitter apps not showing up” was that it was getting late, or that I still had my phone configured -but NOT paired- with openhab as a thing. I removed it and tested again today and got it to show up.) I wanted people to know that if they have ideas or direction with openhab-integration, they will at least get this far!

While I’m thinking a stand-alone $19 ibeacon will resolve my desire to try and get bluetooth presence working with a cell phone (and I wanted this to work with a phone for obvious reasons such as you won’t need to ducttape a beacon on your chest, but we DO voluntarily do that with our cell phones :slight_smile: )… much time is freed up these days due to the virus. Sigh. So I may tinker with it more. I never heard of node until recently, so there’s much of a learning curve. Sigh again!

Questions:

  • Could my issue from Rich’s OP (error posted above) & my @abandonware “fix” be resolved by replacing Rich’s “app.bind( { protocol: ‘hci’, path: ‘null’ } );” with something along the lines of “app.addListener…”? (It seems app.bind function doesn’t exist in the older reelyActive version. I saw you call that in your /pi-suite/bin/pi-suite-hci script.) Is there much extra needed to get it working from there? (And is there a URL in github or whatever that would help a little with dev or documentation of classes/methods, etc?) I totally understand if this question is out-of-bounds, but I was still curious about the mqtt integration with pi-suite. (Or do you already have a pi-suite/mqtt tutorial? :slight_smile:)
  • During my testing with your pi-suite demo, I could only get ibeacon & eddystone transmitters via Android phone apps, and Chromecast to show up in the hello-tracking demo web-app. I could not get my phone to show up when I put it in pair/discover mode, or any other time, without these transmitter apps. Is this expected? Does reelyActive only support “transmitting beacons”, which my phone is NOT without an app? If so, would it be much to add this functionality so that pi-suite could “see” my phone in discover mode? I also noticed when I go to discover mode on my phone, my wife’s phone shows up sometimes - so it appears there is so kind of traffic being generated - could pi-suite pick up this traffic? (I know many presence detection use-cases required very frequent updates, but I don’t, so this could be useful enough. And if one needed more updated frequencies they could look into an android app, UUID detection, or getting a beacon.) (Sidenote: Via the updated openhab Bluetooth Binding here I was able to get my phone to show up in openhab and report its rssi value, and had it get higher/lower depending on how far my phone was from the pi - so it appears the hardware will support it.)
  • Does or could the pi-suite recognize the UUID of the bluetooth device service? This could then overcome the random mac that phones unfortunately use for security reasons. If so, I could see a phone transmitting a signal via either, the already-existing discover/pair/connect mode I mentioned above (same signal that allows my phone to automagically connect to my truck’s bluetooth when I drive it, though I don’t know if that is a service with a UUID) -OR- have an Android app send a unique service UUID (many apps exist already) to identify that phone/user. (Then this gets passed to mqtt and so on.)

Thanks again!

Obviously it has been a couple of years since I’ve revisited reelyActive. I don’t use it at home because I can only tell that an iPhone is present, not which specific iPhone is present because of MAC address spoofing. That’s great for privacy, not so great in trying to see who is home. Is there a way around that now?

It will probably take a good deal of time but if someone doesn’t beat me to it, I’ll give it another go and try to get the 1.x software working with MQTT. Once you have that, integration with openHAB, Home Assistant, and a host of other systems is basically done.

Hello,

Anyone knows how to connect to mosquitto now? It seems part:

app.addNotificationService( {
service: “barnaclesmqtt”,
hostname: HOSTNAME,
topic: TOPIC,
clientOptions: CLIENT_OPTIONS
});

is not working. I’m getting: TypeError: app.addNotificationService is not a function

For now, to start server I use:

const HLCServer = require(‘hlc-server’);
const BarnowlHci = require(‘barnowl-hci’);
const options = {
barnowl: { enableMixing: true },
barnacles: { acceptStaleRaddecs: true }
};
let app = new HLCServer(options);
app.addListener(BarnowlHci, {}, BarnowlHci.SocketListener, {});

Log response:

reelyActive barnowl instance is listening for an open IoT
reelyActive Chickadee instance is curious to associate metadata in an open IoT
barnowl-reel: UDP listening on 0.0.0.0:50000
reelyActive hlc-server is listening on port 3001

@reelyActive - do you have any propositions?

Glad to see there’s still interest in this thread! @orzechszek, there have been several iterations of our open source software since the thread began. For the MQTT feature to work with OpenHAB, you’ll want to install hlc-server 0.x, as the code no longer applies to 1.x.

The documentation for the MQTT service is in barnacles v0.4: GitHub - reelyactive/barnacles at release-0.4

If we were to revive integration today, we would recommend using Pareto Anywhere (the current evolution of hlc-server) and we would create a separate barnacles-mqtt module to forward the data, unless OpenHAB can ingest socket.io data, in which case it could grab the real-time data feed from Pareto Anywhere on port 3001.

Let us know if there’s interest to revive and improve, or if the legacy code does the job fine? Thanks!

Hi @reelyActive ,

Thanks for info!! I would be grateful if you provide how to cover cooperation with openhab in a new way.
I’m in the beggining of configuration so I can try a pareto approach.

I run pareto-anywhere. What’s next? When I use barnowl-hci-forwarder I’m able to read BT notifications in pareto.
Can I set up pareto configuration to start forwarder automatically?
Should I push messages to mosquitto somehow or get directly from pareto ?
Can you provide some needed configuration examples?