[monitor] Reliable, Multi-User, Distributed Bluetooth Occupancy/Presence Detection

Great, thanks a lot.

So I did a bit more digging and I realized I couldn’t execute the apt -get commands and others in terminal because I’m running Hassio (the one with all the extra addons) with MQTT using Mosquitto broker instead of HA on docker. Is that neccessary to make this work? I find that trying to run these scripts directly just results in a load of errors without any output.

I have enabled bluetooth tracking via this command:

#Device tracking
device_tracker:
  - platform: bluetooth_tracker
    interval_seconds: 5
    consider_home: 180
    new_device_defaults:
      track_new_devices: true
  - platform: mqtt
    devices:
      Pi_man_sam: 'location/Pi_man_sam'
    qos: 1
    payload_home: 'present'
    payload_not_home: 'not present'
    source_type: bluetooth_le

It finds a lot of bluetooth devices and under one of the entities it lists device.tracker.pi_man_sam however it’s listed under “mobile app” and that doesn’t show me any bluetooth options for some reason. I’m not sure if I can just go ahead and use that device tracker for my automations?

Thanks a lot for taking the time! this has already brought me a few steps closer to understanding what I need to do.

Well, you’re running the thing that was called Hass.io about a year ago - and hasn’t been since :wink:

For you there’s an add-on.

The bluetooth tracker is fine, if you don’t mind that you’re going to see every Bluetooth device that ever passes your house. Unless you live in a fairly isolated location, do expect to gain many hundreds, if not thousands, of device_tracker entities as a result. That’s why many of us use monitor :wink:

Looking for instructions to install monitor.sh on Ubuntu. The GitHub Monitor page is very RPi specific.

I’m running HA on a NUC in Docker (Supervised version). Looking to install Monitor on the Ubuntu host and connect it to my Mosquitto add-on.

The instructions are not pi specific.

#install git
cd ~
sudo apt-get install git

#clone this repo
git clone git://github.com/andrewjfreyer/monitor

#enter `monitor` directory
cd monitor/

#(optional) switch to beta branch for latest updates and features (may be unstable)
git checkout beta  
1 Like

I have it setup like that. NUC covers most of the flat and a Pi the more Remote Parts.

I see this after downloading monitor

**mark@mschome** : **~/monitor** $ sudo bash monitor.sh

> **starting** monitor.sh (v. 0.2.200)...

./support/init: line 33: --help: command not found

./support/init: line 34: --help: command not found

> **error:** required package 'mosquitto_pub' not found. please install 'mosquitto' and 'mosquitto-clients'.

> **error:** required package 'mosquitto_sub' not found. please install 'mosquitto' and 'mosquitto-clients'.

> **error:** required package 'hcidump' not found. please install 'bluez-hcidump' (e.g., sudo apt-get install bluez-hcidump).

**> warning:** monitor.service not installed. Install service? (y/n)

Well that means that you have to install the missing packages via apt-get install

Hi

I got my Monitor up running, but i don’t understand wat messages to send for triggering a new scan in the simplest way

The plan was using the main door sensor for triggering an mqtt to the the 2 units
presence/1floor/
presence/2floor/

Can i use 1 unit to trigger scan on the other one, or do i need to send Arrive and Depart for both of them

heeeelp?

Thats why I’m asking for more info. Do I need a full mosquito install on Ubuntu as well as the add-on inside my HA, or in place of it? The instructions assume a stand-alone Pi install.

It tells you what to install :wink:

sudo apt-get install mosquitto mosquitto-clients bluez-hcidump

Monitor is a Shell Script. That means the mosquitto binaries have to be accessible to the script.

So if you run monitor outside the HA Container, you also have to have the mosquitto Client binaries available/installed outside, on the base OS.

1 Like

Trying to get MQTT device tracker working. Within HA, using MQTT integration Subscribe Topic, I can see the topic messages from monitor:

Message 17 received on monitor/acepc01/pixel_2_xl_bt/device_tracker at 9:56 AM:
home
QoS: 0 - Retain: false

That shows that monitor seems to be configured correctly (my assumption).

Within HA configuration.yaml has device_tracker: !include device_trackers.yaml. Inside that I have the following:

- platform: mqtt
  devices:
    iphone_8_bt_tracker: 'monitor/acepc01/iphone_8_bt/device_tracker'
    pixel_2_xl_bt_tracker: 'monitor/acepc01/pixel_2_xl_bt/device_tracker'
  source_type: bluetooth
  payload_home: 'home'
  payload_not_home: 'not_home'

If I put random garbage in it and check config it fails, so I know the file is being parsed.

I’m expecting to have two entity as defined above with a name like device_tracker.pixel_2_xl_bt_tracker and I don’t… neither one gets created. No errors in the homeassistant.log.

Thanks, that was the info I was looking for.

monitor.sh started successfully and configures mqtt_preferences to point to HA MQTT.

I’m getting the cycling hci0 messages. Seems the bluetooth on Intel NUC and Ubuntu don’t play well together.

1 Like

No idea there as I am on Debian.

What does „hcitool dev“ report?
Maybe you have to power up the Bluetooth device manually.
Launch bluetoothclt and issue „agent on“ and „power on“ commands.

I have the same problem as msbc.
Running it with debian buster and backported kernel 5.8.
(Backported Kernel because i have an intel ax200 wifi card with bluetooth on it that needs a newer kernel than 4.x)
Monitor only prints the cycling hci0 messages. hcitool dev reports hci0 34:C9:3D:BE… and bluetoothctl ‘scan on’ finds my phone and various bluetooth devices in the house.
Any idea where i can look any further?

Edit:
If the monitor.service runs, bluetoothctl shows:

[CHG] Controller 34:C9:3D:BE:FE:E1 Class: 0x00000104
[CHG] Controller 34:C9:3D:BE:FE:E1 Powered: yes
[CHG] Controller 34:C9:3D:BE:FE:E1 Class: 0x00000000
[CHG] Controller 34:C9:3D:BE:FE:E1 Powered: no
[CHG] Controller 34:C9:3D:BE:FE:E1 Discovering: no
[CHG] Controller 34:C9:3D:BE:FE:E1 Class: 0x00000104
[CHG] Controller 34:C9:3D:BE:FE:E1 Powered: yes
[CHG] Controller 34:C9:3D:BE:FE:E1 Class: 0x00000000
[CHG] Controller 34:C9:3D:BE:FE:E1 Powered: no
[CHG] Controller 34:C9:3D:BE:FE:E1 Discovering: no
[CHG] Controller 34:C9:3D:BE:FE:E1 Class: 0x00000104
[CHG] Controller 34:C9:3D:BE:FE:E1 Powered: yes
[CHG] Controller 34:C9:3D:BE:FE:E1 Class: 0x00000000
[CHG] Controller 34:C9:3D:BE:FE:E1 Powered: no
[CHG] Controller 34:C9:3D:BE:FE:E1 Discovering: no

If i stop the monitor.service everything is fine and the controller stays powered: yes

Thanks

Mike

Sorry if I’m blind or something, but are different monitor flags (sudo bash monitor.sh -h) documented somewhere or should I always log to my Pi to read the documentation?

I’ve got some questions regarding how the monitor works. Here’s some background info of my setup:
1x RPi Zero outside where I enter the house.
2x RPi (3B+ & Zero) inside the house

I’m monitoring one ibeacon in my keyring and my IPhone. When I arrive, outside monitor node will pick up my phone and my keys. When inside, keys are usually detected by both inside nodes, but my phone sometimes only by one node. Outside node will detect both my keys and phone occasionally when I’m inside.

Could someone explain what is happening in my current setup when I go inside. Are the nodes communicating to each other so that the outside node knows I’m home based on the nodes inside? So that the outside node is not starting to search for me when it detects random BT signal e.g. from neighbor and I’m not detected outside anymore?

Without sending any manual DEPART messages, when does my monitor detect I’m not home anymore (keys and Iphone not home)? If I’d be to hasty sending the depart-scan and I’d still be in the BT coverage, when would the next depart scan take place? I’m thinking does it make any difference to delay depart-scan for 1-2 minutes after front door opens, or should I just trust the system to detect my absence at its own pace.

This project has already improved my coming-home-presence by a ton, thank you so much for it!

Hi Guys,

I recently got a new router and have a new network SSID and password. Is there anyway i can change the WIFI credentials on the Pi Zero (Monitor.sh) that I have. I would prefer not to start from scratch again.

I thought i would edit the wpa_supplicant but I cant find it.

If you can ssh to it then step 4 here should get you going.

OOpps sorry didnt see the last part of your post!
Stand by

Did you look here sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Anyone using bloody2k docker container?
Where can I enter the flag options such as -tadr or -x?

Edit: You can pass these to the environment variable MON_OPT