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

Okay, thanks for the help, appreciated.

Good day to all. I have a notebook, ubuntu, hassio, Mosquitto broker 5.1, how to properly configure the monitor so that there are no errors?

starting monitor.sh (v. 0.2.200)ā€¦
retaining mqtt status reports
./support/init: стрŠ¾ŠŗŠ° 33: --help: ŠŗŠ¾Š¼Š°Š½Š“Š° Š½Šµ Š½Š°Š¹Š“ŠµŠ½Š°
./support/init: стрŠ¾ŠŗŠ° 34: --help: ŠŗŠ¾Š¼Š°Š½Š“Š° Š½Šµ Š½Š°Š¹Š“ŠµŠ½Š°
error: required package ā€˜mosquitto_pubā€™ not found. please install ā€˜mosquittoā€™ and ā€˜mosquitto-clientsā€™.
error: required package ā€˜mosquitto_subā€™ not found. please install ā€˜mosquittoā€™ and ā€˜mosquitto-clientsā€™.
error: minimum required mosquitto_sub version 1.5+ not found. please update.
error: minimum required mosquitto_pub version 1.5+ not found. please update.

Iā€™m not sure if you found a good way to open your garage door yet but if you havenā€™t this is what I use and it works about 95% of the time as expected.

Since you have iPhones, I just made a dummy switch in HA, named it Trigger. Then setup a switch for each person in my house.

Sent the people switches and trigger switch to HomeKit.

Created binary sensors in HA to monitor the people switches (I use these for welcome home tts automations)

I run most of my presence automations with the Apple Hone app.

ie;

If I leave the switch.corey_home turns off.
If I come home the switch.corey_home turns on.

I did this for each person.

Then I setup a automation for my garage door, if switch.trigger turns on then open my garage door.
(I set a condition to not open the garage between 11pm and 7am just in case I float out of the zone while Iā€™m sleeping. Just in case!!)

If switch.trigger turns off shut the garage door.

And I set just two more to make sure the switch.trigger is in the correct position.

If the garage door opens turn trigger on
If the garage door closes turn trigger off

So most of my automation for this is used in my native home app but works really well and has been pretty solid. The only thing I wish I could do would make the home zone through Apple smaller because even at the smallest setting I overlap the next street over so if Iā€™m not going home and I drive down that road my garage opens so Iā€™m just trying to figure how to do that part a bit better but because this works so well I havenā€™t found a better way to improve it yet.

please install ā€˜mosquittoā€™ and ā€˜mosquitto-clientsā€™

That message seems pretty self explanatory :wink:

1 Like

Iā€™m just starting to deal with mqtt. and thought broker mqtt was enough. thanks for the answer

arturs@samsung:~$ systemctl status mosquitto.service
ā— mosquitto.service - Mosquitto MQTT v3.1/v3.1.1 Broker
Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2020-04-06 08:24:41 EEST; 13min ago
Docs: man:mosquitto.conf(5)
man:mosquitto(8)
Process: 23335 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (code=exited, status=1/FAILURE)
Main PID: 23335 (code=exited, status=1/FAILURE)

Š°Šæр 06 08:24:41 samsung systemd[1]: mosquitto.service: Main process exited, code=exited, status=1/FAILURE
Š°Šæр 06 08:24:41 samsung systemd[1]: mosquitto.service: Failed with result ā€˜exit-codeā€™.
Š°Šæр 06 08:24:41 samsung systemd[1]: Failed to start Mosquitto MQTT v3.1/v3.1.1 Broker.
Š°Šæр 06 08:24:41 samsung systemd[1]: mosquitto.service: Service hold-off time over, scheduling restart.
Š°Šæр 06 08:24:41 samsung systemd[1]: mosquitto.service: Scheduled restart job, restart counter is at 5.
Š°Šæр 06 08:24:41 samsung systemd[1]: Stopped Mosquitto MQTT v3.1/v3.1.1 Broker.
Š°Šæр 06 08:24:41 samsung systemd[1]: mosquitto.service: Start request repeated too quickly.
Š°Šæр 06 08:24:41 samsung systemd[1]: mosquitto.service: Failed with result ā€˜exit-codeā€™.
Š°Šæр 06 08:24:41 samsung systemd[1]: Failed to start Mosquitto MQTT v3.1/v3.1.1 Broker.

after installation, now conflates with broker mqtt. and monitor starts normally without errors

deleted mosquitto, left the client, left the broker in the container, and everything worked.

Hi guys,

Iā€™m new to HA, Iā€™m trying to use monitor app, but facing some problems.

I installed it using HACS, configured the AppDaemon 4.0 then monitor app.

I can track some MQTT messages sent by the app:
monitor/state

{"locations": [], "version": "2.3.2", "nodes": 0, "online_nodes": [], "offline_nodes": [], "last_changed": "2020-04-06T13:56:43-03:00", "state": "idle"}

monitor/setup/ADD STATIC DEVICE
xx:xx:xx:xx:xx:xx My_phone
monitor/scan
arrive

The appdaemon\apps\Monitor-App folder was created and has a home_presence_app.example.yaml file. I just updated this file and itā€™s like this:

home_presence_app:
  module: home_presence_app
  class: HomePresenceApp

  known_devices:
    - xx:xx:xx:xx:xx:xx My_phone

(xx:xx:xx:xx:xx is my phoneā€™s bluetooth mac adress)

In my HA I can see three binary sensors:
binary_sensor.everyone_home
binary_sensor.everyone_not_home
binary_sensor.somebody_is_home

But all of them are ā€œoffā€.

So the question is: how can I debug this problem? my phone is at home, near my RPi running HA.

Hello,
I think i missed something very basicā€¦ but canā€™t get out of it
Monitor is not connecting to MQTT server:

[CMD-MQTT] warning: issue connecting to mqtt server (lookup error). enqueuing command to try again after a delay
[CMD-ERRO] fatal mqtt error - messages may not be delivered as intended (issue connecting to mqtt server (lookup error). enqueuing command to try again after a delay / 4)

I tested the connection manually and it workedā€¦
mosquitto_sub -h 192.168.1.11 -u mqtt_user -P PASSWORD -t ā€œ#ā€

What am I missing?

Thanks


good evening. This is normal ???

Looks pretty normal to me

1 Like

I"ve added a gateway and enabled debug. Is this ok?

2020-04-06 18:42:17.086236 DEBUG home_presence_app: Gateway Sensor light.luz_da_sala now on
2020-04-06 18:42:17.087531 DEBUG home_presence_app: Canceling timer with handle 3e1fb2e3a9404dd9839d9f39001487f4 for home_presence_app
2020-04-06 18:42:17.090492 DEBUG home_presence_app: Registering run_in in 0 seconds for home_presence_app
2020-04-06 18:42:17.108856 INFO home_presence_app: Previous message repeated 1 times
2020-04-06 18:42:17.109771 DEBUG home_presence_app: call_service: mqtt/publish, {'topic': 'monitor/scan/arrive', 'payload': ''}
2020-04-06 18:42:17.122918 DEBUG home_presence_app: Registering run_in in 30 seconds for home_presence_app
2020-04-06 18:42:17.134832 DEBUG home_presence_app: monitor/scan/arrive payload: 
2020-04-06 18:42:18.018907 DEBUG home_presence_app: call_service: mqtt/publish, {'topic': 'monitor/echo', 'payload': ''}
2020-04-06 18:42:18.038062 DEBUG home_presence_app: monitor/echo payload: 
2020-04-06 18:42:18.040492 DEBUG home_presence_app: Echo received from unknown: 


freezes up. have any suggestions ??? thank you in advance.

Please stop posting pictures of text.

Copy and paste has been with us a while now :slight_smile:

1 Like

./support/btle: line 352: printf: write error: Channel break
What is this mistake?

Is there any reason why if I turn the bluetooth off on my phone, it still shows up on monitor as a confidence of 100? Trying to test this out without leaving the house :slight_smile: this is after me publishing monitor/scan/depart

2 Likes
  • Logs begin at Fri 2020-03-06 16:15:26 EET. -
    Apr 07 22:14:31 samsung bash [29819]: ./support/btle: line 352: printf: write error: Channel break
    Apr 07 22:58:35 samsung bash [29819]: ./support/btle: line 352: printf: write error: Channel break
    Apr 07 23:08:54 samsung bash [29819]: ./support/btle: line 399: printf: write error: Channel break
    Apr 07 23:13:17 samsung bash [29819]: ./support/btle: line 352: printf: write error: Channel break
    Apr 08 01:54:49 samsung bash [29819]: ./support/btle: line 399: printf: write error: Channel break
    Apr 08 02:49:39 samsung bash [29819]: ./support/btle: line 352: printf: write error: Channel break
    Apr 08 03:28:40 samsung bash [29819]: ./support/btle: line 352: printf: write error: Channel break
    Apr 08 05:59:12 samsung bash [29819]: ./support/btle: line 352: printf: write error: Channel break
    Apr 08 06:34:08 samsung bash [29819]: ./support/btle: line 399: printf: write error: Channel break
    Apr 08 07:33:17 samsung bash [29819]: ./support/btle: line 352: printf: write error: Channel break
    what is this mistake? And how to deal with it? Thank you in advance

Hello @pedromargarido,

There is a different thread for this, as its not part of the core Monitor project here. But to answer your question, from the topic the app isnā€™t seeing any nodes as it says "nodes": 0. So there is no data to process.

So I think you need to look into the setup of the monitor system. Please any further questions, kindly ask in the main thread.

Kind regards

Hello,

Maybe Iā€™m having a hard time understanding some limitations, but, somehow, the script doesnā€™t detect non-static devices. I sometimes could get it to see an ā€œiTagā€ beacon, it sees a device thatā€™s into the static configuration, but does not detect any new devices.

Iā€™m running it on rPi 4.

root@beepi:/home/pi/monitor# hcitool scan
Scanning ...
        ...1C:23       A31s-Tablet
        ...A4:9E       Bluetooth Audio
root@beepi:/home/pi/monitor# bash monitor.sh -r

===================================================

              *** BETA/DEV BRANCH ***

===================================================
> starting monitor.sh (v. 0.2.200)...
> removing web request caches
> warning: periodic scan mode may cause interference with 2.4GHz networks if run on a Raspberry Pi
> warning: for security purposes, please consider changing 'username' in: mqtt_preferences
> warning: for security purposes, please consider changing 'password' in: mqtt_preferences
> warning: variable mqtt_port does not appear in mqtt_preferences. using default port 1883.
> warning: variable mqtt_publisher_identity does not appear in: mqtt_preferences. using hostname: beepi.
> warning: operating in anonymous and unprotected mode for mqtt broker at 192.168...
> ...A4:9E confidence topic: home/monitor/beepi/bluetooth_audio (has not previously connected to hci0)
[-] 0.2.200 11-04-2020 12:43:17 AM [CMD-NAME]   ...A4:9E Bluetooth Audio  Unknown
[-] 0.2.200 11-04-2020 12:43:17 AM [CMD-MQTT]   home/monitor/beepi/bluetooth_audio { ... confidence : 100 ... }

Scanning with the -b option also does not show the new devices. I havenā€™t altered the preferences, just the MQTT, which, seems to be working fine.

My scenario: I want to leave the script running for a while, then collect the addresses from MQTT. I could set up a separate hci scan and leave that running, collect data, feed it to the ā€˜monitorā€™, but I want to avoid the extra steps.

Is it something interfering with the scan? I often see this message ā€œcycling bluetooth hardware on hci0. please wait a momentā€¦ā€. I donā€™t use the BT hardware for anything else.

Sorry for that, I was confused and lost thinking the monitor app from HACS and the core were the same, but now I understood! Thank you very much.

I have another question, is it possible to use the monitor script on the same RPi I run HassOS/Hassio?