Home Assistant Community

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

mqtt
automation
Tags: #<Tag:0x00007f374ca500c0> #<Tag:0x00007f374ca57f78>
#769

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

#770

@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

#771

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

0 Likes

#772

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]'
4 Likes

New MQTT config (json_attributes_topic)
Json_attributes_topic - json_attributes deprecated
#773

@benjimatt update flag is fixed.

1 Like

#774

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

#775

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

0 Likes

#776

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.

0 Likes

#777

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

#778

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?

0 Likes

#779

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?

0 Likes

#780

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

#781

What brand of phone?

0 Likes

#782

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

@andrewjfreyer what does this mean?

1 Like

#783

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.

0 Likes

#784

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?

0 Likes

#785

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

#786

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.

0 Likes

#787

Presuming you have default settings, post a blank mqtt message to the topics: monitor/scan/arrive or monitor/scan/depart

You can do this via an automation, a script, node red, whatever.

0 Likes

#788

Sorry, I worded horribly what I meant. I was asking what to use as a trigger. So far I can only use one door and to my understanding you can’t trigger both scans simultaneously.

I could check whether I’m present or not and trigger the other scan, but I don’t live alone so a door opening could mean either someone is leaving or someone else arriving :confused:

Could restart be a good trigger to use if I can’t determine what is happening?

1 Like