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

So I’m new to Monitor and getting it up and working on Hassio.

I’m mainly interested in using arrive/depart scans triggered by motion sensor at front door.

The arrive scan seems to be working well both from the hassio script (below) and the Hassio MQTT developer tool (Hassio add-on). But the depart scan oddly only seems to work from the Hassio MQTT developer tool.

Am I being thick? Is their something wrong with my departure script below? Could someone help point me to a way to troubleshoot?

In my script.yaml

#----------------------------------------------------------------------------------------------------------------------
#  Monitor
#----------------------------------------------------------------------------------------------------------------------
arrival_scan:
  alias: Arrival Scan
  sequence:
    - condition: template
      value_template: "{{is_state('binary_sensor.mqtt_bingbong_home', 'off')}}" 
    - service: 'mqtt.publish'
      data: 
        topic: monitor/scan/arrive
    - delay: 00:00:15
    - condition: template
      value_template: "{{is_state('binary_sensor.mqtt_bingbong_home', 'off')}}" 
    - service: 'mqtt.publish'
      data: 
        topic: monitor/scan/arrive
    - delay: 00:00:15
    - condition: template
      value_template: "{{is_state('binary_sensor.mqtt_bingbong_home', 'off')}}" 
    - service: 'mqtt.publish'
      data: 
        topic: monitor/scan/arrive
      
departure_scan:
  alias: Departure Scan
  sequence:
    - condition: template
      value_template: "{{is_state('binary_sensor.mqtt_bingbong_home', 'on')}}" 
    - service: 'mqtt.publish'
      data: 
        topic: monitor/scan/depart
    - condition: template
      value_template: "{{is_state('binary_sensor.mqtt_bingbong_home', 'on')}}" 
    - delay: 00:00:60
    - service: 'mqtt.publish'
      data: 
        topic: monitor/scan/depart
    - condition: template
      value_template: "{{is_state('binary_sensor.mqtt_bingbong_home', 'on')}}" 
    - delay: 00:00:60
    - service: 'mqtt.publish'
      data: 
        topic: monitor/scan/depart
    - condition: template
      value_template: "{{is_state('binary_sensor.mqtt_bingbong_home', 'on')}}" 
    - delay: 00:00:60
    - service: 'mqtt.publish'
      data: 
        topic: monitor/scan/depart

EDIT: Yep, I’m thick:) Can’t have 60 seconds!! All good now… I’ll leave the post up for mild amusement of others…

2 Likes

I think that’s happened to me before and my SD card ended up being corrupt. Try to save your configs and completely reformat. (Yeah a little inconvenient)

1 Like

Thanks I’ll give it a try

Well why didn’t you say you had tried rebooting? I guess I should have been able to use my crystal ball to know this, but it died from overuse when I have to guess what people have tried because they don’t say.

2 Likes

This is clearly unnecessary I didn’t ask for your direct help it was a general question.
I’ll take note to provide more information to ensure I’m not insulted again.

1 Like

You insult everyone here by not posting clearly. I suggest you read this

I have Montior setup for my phones and it works great. However i cannot get Montior to find my new Fitbit Inspire HR. I have no clue on how to find my Fitbits bluetooth macadress. Can anyonte help?

Hi! I’m trying to do the same thing. Did you ever get it to work?

I never got this to work, fwiw :frowning:

I have not tackled this type of presence detection since I rather want a solution that works for a broad range of use cases. Therefore I am aiming for Android/iOS and BT Tags.

How do you install ok hassio environment , because its dockerized?? And after a reboot ,anything you install o doit its gone? I’m wrong

On Hass.io you need to install software using add-ons

1 Like

Your question isn’t so clear to me, if you clarify I may be able to help.

Maybe I didn’t explain this quite right too though…

I use the Hassio addon/integration for MQTT. The set up for that is a little confusing despite the documentation. If you Google hard you’ll find threads that will help. Let me know if you need help/get stuck.

I had a bit of a hard time setting up Monitor despite the quite good instructions. I got it up and running on a Pi Zero after various minor trouble shooting attempts that mostly relate to my inexperience with command line (like I didn’t know when you paste passwords you can’t see them etc etc).

My detction times aren’t satisfactory at the moment, so I’m in the process of fine tuning…

@Fredamn76 @VilleL - I used the Bluetooth Mac Finder app for Android to find my Fitbit MACs.

I’ve been using this for a while now and it works really well but I do have issues when it just stops working. From the logs it appears it can no longer access bluetooth and I’m wondering if I need different hardware. I’m currently running it on pi zero w nodes, maybe if I switched to something better (pi 3?) it would’t stop working? It’s not common but every month or so one of them stops reporting and I have to physical reboot it to fix the issue. Any tips?

I’m using Monitor on a RPi 3B+, but I also have noticed that Bluetooth sometimes becomes unresponsive. When this happens, the presence status will be become “unavailable” instead of “home” or “not_home”.

I use an automation that checks every 30 mins whether the status of my phone is unavailable, and sends a MQTT restart command to Monitor:

- id: '0000000000003'
  alias: Check Monitor service every half hour
  initial_state: 'on'
  trigger:
    platform: time_pattern
    minutes: '/30'
    seconds: 00
  condition:
  - condition: state
    entity_id: 'sensor.presence_iphonex'
    state: 'unavailable'
  action:
  - service: mqtt.publish
    data:
      topic: "monitor/scan/restart"

I also set crontab in the RPi to reboot it every day at 4AM.

Not the RPi running home assistant I hope!

I run HA in a separate VM instance :grinning:

Thank you. It works!

My Fitbit devices does not get recognized when scanned.

I use sudo bash monitor.sh -t -r -u and my fitbit devices are listed in file known_static_addresses