Presence detection with low cost BLE devices and Raspberry Pi/Zero W

No problem, I’ll whip something up tomorrow for you.

Big Big Thanks!!!

Sorry for the delay. I tried to install this on a fresh copy of hassbian and node had updated the armv6 version today. I couldn’t get the latest 8.9 to work at all. However using the older version 6.11.5 worked perfectly.

Please excuse the crude instructions, I’m quite new to this.

cd ~
wget https://nodejs.org/download/release/v6.11.5/node-v6.11.5-linux-armv6l.tar.gz

cd /usr/local
sudo tar xzvf ~/node-v6.11.5-linux-armv6l.tar.gz --strip=1

Then I followed the instructions for room-assistant on github and used the following for my config.

{ "app": { "unsafe": false }, "mqtt": { "enabled": true, "url": "mqtt://000.00.0.00:1883", "username": "username", "password": "password", "reject_unauthorized": true, "topic": "downstairs" }, "console": { "enabled": false }, "ble": { "enabled": true, "channel": "room_presence", "max_distance": 6, "whitelist": ["fe2f4b3892a7"], "use_mac": false, "system_noise": 0.01, "measurement_noise": 3, "update_frequency": 5000 }, "ibeacon": { "enabled": false, "channel": "room_presence", "max_distance": 0, "whitelist": [], "system_noise": 0.01, "measurement_noise": 3 }, "temper": { "enabled": false, "channel": "temper", "interval": 60000, "scale": 1, "offset": 0 }, "gpio": { "enabled": false, "only_send_updates": true, "ports": [], "qos": 0, "retain": false }, "shell": { "enabled": false, "commands": [], "qos": 0, "retain": false } }

thanks, I’ll try this this evening!

I’ve tried this today on 2 Raspberry Pi Zero’s unfortunately both Pi’s crash after approx half an hour running. :frowning:

How do they crash? Run out of memory? Run out of disk space?

Remember that there are user specific parts in the config such as the URL, username, password and whitelist entries.

I don’t know how they crash.
Everything works fine for 30min and then they crash/hang up and disappear from my network, so I assume they run out of memory.

On the config file what have you set the BLE update frequency to? I originally didn’t realise it was milliseconds and not seconds, this crashed both my pi2 and pi zero after X minutes. Changing this to 5 seconds stopped any crashes.

I have that set to 5000; so 5seconds

Hm, strange.

Did you start/restart with the forever service mentioned in the docs? This caused hangs for me also, fixed with a fresh reboot every time I made any changes to the config.

I tried with and without the forever script, both times it crashes after approx. 30min.

I will try to install everything on a Pi3 now and see if this works.

Just to rule out the hardware.

Quick question: did you also run the blues script as instructed on top of the docs?

Raspbian Strech comes with a fresher release it says.

is anyone using this with a external mqtt server ? i cant seem to connect to my cloudmqtt instance

Hmm, the odd thing is…yesterday the installation was done in like 5/10seconds. Now it’s already installing for over an hour :frowning:

yeah I installed the one from the docs

Post your MQTT settings, but I would suspect that if you are using SSL you may have to turn strict checking off (somehow) as that’s the only way I’ve got CloudMQTT bridging working.

i have the below

{
“mqtt”: {
“enabled”: true,
“url”: “mqtt://cloudmqtt.com:19932”,
“username”: “mypassword”,
“password”: “mypassword”,
“reject_unauthorized”: true,
“topic”: “room-name”
}
}

I have tried both with 19932 and 29932 ( SSL)

Your URL should have a hostname I think, mine is m20.cloudmqtt.com. Also, rather than using the username and password given, consider setting up a specific one for the device using the ACL settings but it’s not essential.

@sfgreenwood made a mistake on the above i have m21.cloudmqtt.com

have set a user of roomassistant and password and read/write = true and have shared the topic # (all)

Can you see anything in the CloudMQTT log? Also you can monitor using mosquitto_sub with something like

mosquitto_sub -h m21.cloudmqtt.com -p 19932 -u username -P password -t "room_presence/#"

Also room assistant logs to the logs directory if you’ve done a standard install and that shows connection errors.