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

Thanks Andrew - and just to confirm with your response to @Cee, if we use -tad on the third floor, do you need to pair it with -tr on your main node to trigger the MQTT scan messages?

2 Likes

Yes. That is correct.

Yup! Thatā€™s more or less it.

1 Like

This error should be fixed now.

Update: 0.1.672

Major Change Log:

  • README.md example updates, phrasing updates
  • Updated reporting formula for confidence loss
  • Various bugfixes

Note the beta branch, if youā€™d like to test out features before theyā€™re merged with the master branch.*

2 Likes

Yeah looks good now. These are the settings im currently using.

Repetitions Sequence
2 90.0, 45.0, 0

This is giving me a very quick depart. :clap::clap:
To make sure my Depart is being seen this is the script that is ran when the door (trigger) opens / closes

mqtt_depart:
  sequence:
  - delay: 00:00:10
  - data_template:
      topic: location/scan/depart
    service: mqtt.publish
  - delay: 00:00:20
  - data_template:
      topic: location/scan/depart
    service: mqtt.publish
  - delay: 00:00:30
  - data_template:
      topic: location/scan/depart
    service: mqtt.publish
  - delay: 00:00:40
  - data_template:
      topic: location/scan/depart
    service: mqtt.publish
  - delay: 00:00:50
  - data_template:
      topic: location/scan/depart
    service: mqtt.publish

This is all works well so far. I have a fall back just in case arrival is happening same time as a depart scan. My Win 10 vm Pings my away devices every 2 seconds (yes this is aggressive) until they are declared home. Id say its about 50 / 50 for which method is triggering my arrival. But for depart / Not home status Monitor is the only thing I am using because its the only thing that is actually reliable IMHO.

Thanks for the hard work. Just a thought.,ā€¦for a further future release if you are bored. Once all the Known_Devices are declared HOME can we either stop the arrival scans or make it where I have less scans. All my devices will be home for easily 10 hours and while we are home the devices are essentially doing arrivals scans for no reason especially since my Piā€™s are set to scan depart on a trigger.

Either way I love the way things are working right now.

5 Likes

As a newbie to monitor I found things a little confusing at the start, so if possible Iā€™d like to suggest the following updates to the readme.md please as it would have helped my past self understand things quicker. :slight_smile:

  1. Could you explain some of the command line options in more detail please? For example, as you have described above, using -tr and -tad in combination to help reduce scans on far away devices. Another is the -x option - where does it retain MQTT messages and what benefit does this give? Where does the -E option report scan status messages? How does the -m heartbeat signal help? Could you give advice or insider tips on how best to combine the options?

  2. The the following default entry in mqtt_preference confused me initially because monitor doesnā€™t match up with your examples in Readme.md where all the MQTT topics start with location. Could the default entry be changed to match please?

# MQTT PUBLISH TOPIC ROOT 
mqtt_topicpath=monitor
  1. Could you also clarify that mqtt_publisher_identity=''" relates to first floor second floor, etc in your examples?

  2. The Home Assistant example name: "Home Occupancy Confidence of 00:00:00:00:00:00" doesnā€™t match up with entity_id: sensor.home_occupancy_confidence. Could you change it to something like the following please?

- platform: min_max
  name: "Home Occupancy Confidence of Andrew"
  type: max
  round_digits: 0
  entity_ids:
    - sensor.third_floor
    - sensor.second_floor
    - sensor.first_floor

- alias: Occupancy 
  hide_entity: true
  trigger:
    - platform: numeric_state
      entity_id: sensor.home_occupancy_confidence_of_andrew
      above: 10
  1. This sentence was confusing: Do this with all other cell phone/laptop devices that you'd like to track via mqtt messages posted/formatted like this: as it implies the text below that sentence should also be in the known_static_addresses file.

  2. More Home Assistant code examples would be useful if possible please. A full example showing how you do the presence automations, etc, perhaps as an extra file in GitHub that would work as a HA package file https://www.home-assistant.io/docs/configuration/packages/)

  3. Step 7 in the installation instructions has two different ways to install software - is there a difference between apt-get and aptitude?

sudo apt-get update
sudo aptitude install libmosquitto-dev mosquitto mosquitto-clients

Sorry to rip apart your instructions like that, I just want to help others adopt your excellent software easier than how I found things.

Thanks!

2 Likes

Thank you again, just ran it on default settings for the last 24 hours with just my MAC in and seemā€™s to be almost a interference free zone now, tablet only dropped out once or twice instead of way too many times, it was filling my log with annoying errors.

Just added in a second MAC, will see how that goes :+1:

1 Like

Clever! Iā€™m going to implement this myself. Good solution.

1 Like

By default, when monitor starts an ARRIVE scan, it will only scan for addresses that are currently away. So if all devices are home, no arrive ARRIVE are performed at all.

If you are seeing different behavior, please post a log.

I can agree with SOME of what you are talking about but other issues I think you just need to have a little common senseā€¦

Once a specified device, iBeacon, or 
publicly device is found, **a report is made via MQTT to a specified **
**MQTT broker**. When a previously-found device expires or is not found, 
**a report is made via MQTT to the broker that the device has departed**. 

This is in the Summary at the very top. I think you need to understand your MQTT server and what it is actually doing.
1.

  • -x is retaining MQTT messages on the MQTT server. (looks up what retaining mqtt messages does, this is basic MQTT knowledge)
  • -E this posts results to the MQTT server. Where else would it report?? This entire project is based on the PI with monitor posting to an MQTT server.
  • -m Heartbeat signal. I can agree with you on this one. It isnt clearly defined.
  • monitor -t[adr] ------ The problem with these settings is that they are mainly based on opinion and your house structure. For instance I disagree with the settings that andrew recommends in some cases but its because of how my place of living is set up, its all relative.
  • mqtt_topicpath=monitor I can 100 percent agree with this default setting being changed to mqtt_topicpath=location Im pretty sure that it used to be and andrew changed it one day.
  • I guess I can agree with this one too. I think since all of your examples state First Floor you should just make the default mqtt_publisher_identity='First Floorā€™
  1. You are correct, this example needs to be corrected because it isnt consistent.

  2. I disagree this is pretty clear IMHO

  3. I think you are asking a lot here lol. Let be honest try to look at all the other HASS components and notice how they do not have clear examples or the examples are no longer working. You are asking a lot here. again just my opinion.

  4. I think these are the same. Im not sure why he chose aptitude instead of apt-get. I personally never use aptitude but thats just me.

1 Like

Tiles are working when using the -g flag and placing them their Mac in the known_static_addresses file.

2 Likes

@benjimatt @jarrah you are both right. Documentation and explanation is by far the weakest point right now

Your config is clearly wrong as it has no indentation.

1 Like

There is but it doesnā€™t show on the forum. Are there any other problems you see in the code? Thanks!

1 Like

@fillilutten, if you put 3 back ticks (top left of keyboard) on the line before the ā€˜codeā€™ and 3 on the line after the code it will.

Or else look at the picture at the top of the forumā€¦ :slightly_smiling_face:

The forum posts use ā€˜markdownā€™ - google it to learn how yo use itā€¦

1 Like

Iā€™m so sorry! First time posting here :slight_smile:

binary_sensor:
  name: 'Home'
  platform: 'bayesian'
  prior: 0.2
  probability_threshold: 0.9
  observations:
    - entity_id: 'sensor.me_in_apt'
      prob_given_true: 0.95
      platform: 'numeric_state'
      above: 45

So this is my code. I canā€™t seem to find anything wrong.

1 Like

Why do you have quotes round the binary platform, entity_id and observation platform?

1 Like

I looked at the docs at

1 Like

As the to_state variable is ā€˜requiredā€™ Iā€™d suggest you need it (makes sense) and the examples are wrong (in some cases).

1 Like