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

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

But in the docs ut says ā€œ requiring below and/or above instead of to_state .ā€

So I shouldnā€™t be needing to_state, hm. I have also seen other examples from users with, from what I can tell, functional Bayesian sensor using the same code.

2 Likes

Just a question, Since you are using a Bayesian sensor im assuming that you are using multiple means of presence detection?? I just use the Min_max sensorā€¦

- platform: min_max
  name: "Home Occupancy Benji"
  type: mean
  round_digits: 0
  entity_ids:
    - sensor.benji_living_room
    - sensor.benji_bedroom
    - sensor.benji_bedroom1

Here is what one sensor looks like

- platform: mqtt
  state_topic: 'location/bedroom/ff:ff:ff:ff:ff:ff'
  value_template: '{{ value_json.confidence }}'
  unit_of_measurement: '%'
  name: 'Benji Bedroom'
  availability_topic: "location/bedroom/status"
  payload_available: "online"
  payload_not_available: "offline"
  json_attributes:
    - id
    - name 
    - rssi
    - version
    - manufacturer
    - type
    - timestamp
    - retained
    - confidence

This is my automation

- id: Benji_Home
  alias: Benji Home
  trigger:
  - above: '30'
    entity_id: sensor.home_occupancy_benji
    platform: numeric_state
  - entity_id: input_boolean.benji_home
    platform: state
    to: 'on'
  condition:
  - below: '25'
    condition: numeric_state
    entity_id: sensor.home_occupancy_otheruser
  action:
  - entity_id: script.Benji_Home
    service: script.toggle

Hopefully this helps you a littleā€¦

1 Like

Thanks a bunch for your help!
Actually I donā€™t use any more than monitor MQTT right now. But went with a Bayesian so that I eventually with ease could expand using more presence detections.
Shouldnā€™t it work with just one observation?

1 Like

That really wasnā€™t called for - remember, you were once a newbie who was told to do their homework in the following post after asking a questionā€¦ Need help with tasker

The reason I asked about the -E option is because I didnā€™t see any MQTT messages when arrive or depart scans occur. Iā€™ve just double checked again now and still canā€™t see where this would appear.

I would expect an MQTT message saying /monitor/scan/arrive/start when *** Started arrival scan. [x2 max rep] **** appears in the log, and a /monitor/scan/arrive/end when logs show it finishes **** Completed arrival scan. ****, but Iā€™m seeing nothing related to this when using sudo bash monitor.sh -E.

Iā€™m monitoring my MQTT broker using -t "monitor/#" but only seeing the usual messages from monitor.

Iā€™m not quite sure why you highlighted this as it doesnā€™t seem related to one of my questions. Iā€™ve been using MQTT for a long time now and have all my Zigbee devices reporting to it.

I should have explained why I was asking - zigbee2mqtt retains MQTT messages either locally (for when HA is rebooting to send when back up) or asks the broker to retain them (so that HA remembers the on/off status of a device), so I wondered which method Monitor uses.

Yes true, thereā€™s many different ways to use these options. I just didnā€™t know about the useful combination of -tr and -tad at first.

Letā€™s agree to disagree.

Yes true, it probably is asking for too much here, the info provided is plenty good enough to get started with. I really like your mqtt_depart sequence above too.

I havenā€™t been happy with my current GPS-based presence tracking and this looks like a very interesting solution.

Can it be run on a Pi 3 Model B, or a laptop with a bluetooth dongle? Any particular hardware requirements or dongle recommendations?

1 Like

Hi,
I have a question. If I am using an iPhone with the latest IOS, how do I get the correct MAC address that is being discovered by the scan?

as far as I have read, iPhone change the MAC address periodically to prevent tracking.

I am very interested to make this work for me as this will make the perfect presence monitoring/detection in my house.

1 Like

It will run on a Pi 3 Model B or a Raspberry Pi Zero W. My guess is it would also run on Pi2 with a dongle

The github page has instructions for installation.

1 Like

Settings > General > About Scroll about halfway down and youā€™ll see ā€œBluetooth Addressā€ - this is the address to add to the known_static_addresses file

1 Like