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

I’m actively testing some new features on beta. It probably won’t be reliably stable until this afternoon. Sorry for any inconvenience

Great! For future reference, the recent versions of the beta happy ability to connect directly to a device to mitigate this. Documentation coming soon

1 Like

Well, I don’t know if was upgrading to the latest hass.io, or upgrading to the latest monitor beta code, but no more dangerous client! I seem to be getting something, now just to figure out how to add something to Lovelace to play with and verify things are working correctly.

1 Like

@andrewjfreyer

So far so good on this latest Beta.

Can you check for me if your MQTT server is still retaining messages? Mine for some reason on the Beta is not retaining them. I saw you changed a couple things but it looked correct…
EDIT
it could be something im doing

EDIT

It seems that doing -u isnt working for me…
I think two of my SD cards were corrupted so I flashed an entirely new instance of monitor.

then I used sudo bash monitor.sh -u -d -tdr -x
Unfortunately this did not change the config.
I went to the service and manually changed the service parameters. and my messages are now retained and the depart scan only on trigger is also working. No reboots so far!!!

So one of my Pi’s is on 0.1.675 and the other is 0.1.878. Ill keep on testing but so far so good. Keep up the great work!!!

1 Like

Thanks for the report. I’ll see if I can figure out why it isn’t updating

Fyi in the newer versions of HASS (This took me longer than it shouldve to figure out so im posting it here)

This OLD config

  - platform: mqtt
    state_topic: 'location/first floor/[MAC ADDRESS]'
    value_template: '{{ value_json.confidence }}'
    unit_of_measurement: '%'
    name: 'Apple Watch - First Floor'
    availability_topic: "location/first floor/status"
    payload_available: "online"
    payload_not_available: "offline"
    json_attributes:
      - id
      - name 
      - rssi
      - version
      - manufacturer
      - type
      - timestamp
      - retained
      - confidence 

turn Into this new config

  - platform: mqtt
    state_topic: 'location/first floor/[MAC ADDRESS]'
    value_template: '{{ value_json.confidence }}'
    unit_of_measurement: '%'
    name: 'Apple Watch - First Floor'
    availability_topic: "location/first floor/status"
    payload_available: "online"
    payload_not_available: "offline"
    json_attributes_topic: 'location/first floor/[MAC ADDRESS]'
6 Likes

@benjimatt update flag is fixed.

1 Like

Still having issues with BT adv. Some days it works, but for most of the part it doesn’t. I’m guessing that when it works it’s because some neighbor triggered the scan (we’re reasonably close). So it seems I’m stuck with triggers, since none of my devices seem to work.

Any ideas on how to trigger an arrive scan? I could use the doors for departure. Would it be OK to use the same door for both scans?

(Btw I’ve been paying attention to this thread and I’m running the latest beta).

1 Like

How many people/devices would you estimate are within ~50m of you node?

Running the latest beta 0.1.887

I am getting the following error:
monitor.sh: line 1074: [: : integer expression expected
That line reads:
[ "$beacon_last_seen" -gt "$last_seen" ] && last_seen=$beacon_last_seen
I assume the $ is missing? I entered it but still get the same error.

Also, my ibeacon used to work well in a previous beta. Now, it will be recognized as home but wont ever lose confidence from 100 when it leaves. UUID loses confidence well. Should I just use the UUID and call it a day?

I’m using -b -u flags on my 1 and only pi running monitor.

Also, if you want to make a device_tracker out of your monitor devices, you could use MQTT Device Tracker. I made one for my dog Nilly for her Pawscout iBeacon Tag :

Create an MQTT Device Tracker:

device_tracker:
  - platform: mqtt
    devices:
      nilly_rpi: 'location/nilly-rpi'

Create automations for Home & Away:

automation:
- id: '############'
  alias: Nilly Away - RPi Monitor
  trigger:
  - platform: numeric_state
    entity_id: sensor.nillys_pawscout_tag_rpi_zero_uuid
    above: '10'
  action:
  - service: mqtt.publish
    data:
      topic: location/nilly-rpi
      payload: home

for home

- id: '############'
  alias: Nilly Away - RPi Monitor
  trigger:
  - platform: numeric_state
    entity_id: sensor.nillys_pawscout_tag_rpi_zero_uuid
    below: '10'
  action:
  - service: mqtt.publish
    data:
      topic: location/nilly-rpi
      payload: away

for away.

As soon as it publishes a payload, a new device_tracker.nilly_rpi will be made in known_devices.yaml

1 Like

Smartphones probably around 10 including two of our own. The Raspberry pi is really close to he front door so may be within range of people walking down the street. Why? Do you have something in mind?

Your theory about triggering too often may be correct. Drivers, pedestrians, etc may be triggering an arrive too frequently.

When you run btmon on its own, how many devices do you see?

Will try at home. What is sad is that I have no problems with it “triggering too much” in fact, I wish those pedestrians where outside all the time so it can recognize me coming home : ( Still have absolutely no idea why non of my phones work.

1 Like

What brand of phone?

OnePlus 3 and LG G5. Also tried with a Sony XA1 Plus.

@andrewjfreyer what does this mean?

1 Like

The filters are set default for Apple. That could be a major issue for you right now. Disable the filters in behavior press by replacing the content with an asterisk. I’d start with the manufacturer filter first.

Monitor hasn’t been reliably working for me for the past week, so I upgraded to the beta and have just run it for the first time.

I see this error in my logs:

error! attempting to correct hci0 hardware fault.

Does this indicate a bluetooth hardware fault with my rpi?

Got it. Anyway, that isn’t the issue with my devices not advertising. Since those advertisements are from an app simulating beacons. Any ideas of how to trigger both arrive and depart triggers? I can only use doors, sadly :confused:

1 Like

That means that hcitool has failed, which usually happens when two or more programs attempt to access the hardware simultaneously.

Safe to ignore. If you are seeing this error very frequently (more than once or twice per minute) you should consider restoring default settings or reducing the number of known devices you have tracked.