Reliable presence detection but not bluetooth

OK, I have updated the MAC addresses and seem to be having better luck but still not changing to home and not_home.

Here is what I see in the Terminal. I have added back in the static MAC address list but removed the alias. I can see the confidence level changing so it must have found my phones.

> starting monitor.sh (v. 0.2.197)...
> removing web request caches
> C0:EE:FB:F5:D8:BB confidence topic: monitor/android/c0_ee_fb_f5_d8_bb (has not        previously connected to hci0)
> C0:EE:FB:F5:D8:BB device_tracker topic: monitor/android/c0_ee_fb_f5_d8_bb/devi       ce_tracker [not_home or home]
> C0:EE:FB:F6:1A:49 confidence topic: monitor/android/c0_ee_fb_f6_1a_49 (has not        previously connected to hci0)
> C0:EE:FB:F6:1A:49 device_tracker topic: monitor/android/c0_ee_fb_f6_1a_49/devi       ce_tracker [not_home or home]
[+] 0.2.197 26-07-2019 02:34:06 pm [CMD-NAME]   C0:EE:FB:F5:D8:BB OnePlus 3T MC         OnePlus Tech Shenzhen Ltd
[+] 0.2.197 26-07-2019 02:34:07 pm [CMD-MQTT]   monitor/android/c0_ee_fb_f5_d8_b       b { ... confidence : 100 ... }
[+] 0.2.197 26-07-2019 02:34:10 pm [CMD-NAME]   C0:EE:FB:F6:1A:49 OnePlus 3T CH         OnePlus Tech Shenzhen Ltd
[+] 0.2.197 26-07-2019 02:34:10 pm [CMD-MQTT]   monitor/android/c0_ee_fb_f6_1a_4       9 { ... confidence : 100 ... }
[+] 0.2.197 26-07-2019 02:37:15 pm [DEL-RAND]   RAND 18:CE:E6:8C:04:75 expired after 190 seconds
[+] 0.2.197 26-07-2019 02:38:20 pm [DEL-RAND]   RAND 55:6D:19:08:4D:89 expired after 183 seconds
[+] 0.2.197 26-07-2019 02:38:25 pm [DEL-RAND]   RAND 09:C9:31:3E:1A:49 expired after 122 seconds
[+] 0.2.197 26-07-2019 02:38:27 pm [CMD-MQTT]   monitor/android/c0_ee_fb_f6_1a_49 { ... confidence : 90 ... }
[+] 0.2.197 26-07-2019 02:38:31 pm [CMD-MQTT]   monitor/android/c0_ee_fb_f6_1a_49 { ... confidence : 100 ... }
[+] 0.2.197 26-07-2019 02:40:30 pm [DEL-RAND]   RAND 40:92:9B:62:5E:A0 expired after 122 seconds
[+] 0.2.197 26-07-2019 02:40:57 pm [DEL-RAND]   RAND 6B:19:E0:29:D2:93 expired after 151 seconds
[+] 0.2.197 26-07-2019 02:41:57 pm [DEL-RAND]   RAND 4A:4A:AA:D8:EB:65 expired after 183 seconds

HA config now looks like this. I have tried the MACs with upper case and lower case and it did not seem to matter.

  - platform: mqtt
    devices:
      colleen_android: 'monitor/android/c0:ee:fb:f6:1a:49/device_tracker'
      martin_android: 'monitor/android/c0:ee:fb:f5:d8:bb/device_tracker'

In the entity states screen I see the entities but both show as not_home when both phones are home and Bluetooth is turned on and discoverable.

device_tracker.colleen_android not_home source_type: null friendly_name: colleen android
device_tracker.martin_android not_home source_type: null friendly_name: martin android

This is proving very difficult!

It never worked for me with them added in the static mac address list, try removing them from there.

OK, I tried removing them and all I got in the terminal was the following. no sign of the phones? This was after waiting 7 minutes


pi@raspberrypi:~/monitor $ sudo bash monitor.sh -b
> starting monitor.sh (v. 0.2.197)...
> removing web request caches
[+] 0.2.197 26-07-2019 03:05:07 pm [CMD-INFO]   cycling bluetooth hardware on hci0. please wait a moment...
[+] 0.2.197 26-07-2019 03:06:57 pm [DEL-RAND]   RAND 65:B3:11:0E:5A:C3 expired after 188 seconds
[+] 0.2.197 26-07-2019 03:07:17 pm [DEL-RAND]   RAND 1C:EF:18:C4:14:34 expired after 123 seconds
[+] 0.2.197 26-07-2019 03:09:07 pm [DEL-RAND]   RAND 5D:FD:66:AB:A0:5E expired after 188 seconds
[+] 0.2.197 26-07-2019 03:10:07 pm [DEL-RAND]   RAND 55:3F:2A:1A:95:10 expired after 98 seconds
[+] 0.2.197 26-07-2019 03:11:07 pm [DEL-RAND]   RAND 7A:2F:45:6B:3D:9B expired after 159 seconds
[+] 0.2.197 26-07-2019 03:11:57 pm [DEL-RAND]   RAND 6E:B1:1E:A8:DB:93 expired after 181 seconds
[+] 0.2.197 26-07-2019 03:12:17 pm [DEL-RAND]   RAND 5D:FD:66:AB:A0:5E expired after 183 seconds

Try restarting the Pi, sometimes its BT soft-cycle leads to such results, like itā€™s stuck.

On a related note, letā€™s check if Monitor and your HA instance are connected, create this sensor:

- platform: mqtt
  state_topic: 'monitor/android/status'
  name: Monitor Script Status

When you then run the script on the Pi, this sensor should show ā€œonlineā€

1 Like

OK, I restarted the Pi and also added the status monitor.

 sensor.monitor_script_status	online	friendly_name: Monitor Script Status

Looks like Monitor is talking to HA.

I am seeing this is the MQTT Broker Add-on in HA in the logs

1564151724: New connection from 192.168.1.xx on port 1883.
1564151724: New connection from 192.168.1.xx on port 1883.
[INFO] found mqtt on local database
1564151724: New client connected from 192.168.1.xx as android1047 (p2, c1, k60, u'mqtt').
1564151724: New client connected from 192.168.1.xx as android1891 (p2, c1, k60, u'mqtt').

I am still getting the following in the terminal which does not have the phones listed?


pi@raspberrypi:~/monitor $ sudo bash monitor.sh -b
> starting monitor.sh (v. 0.2.197)...
[+] 0.2.197 26-07-2019 03:49:08 pm [DEL-RAND]   RAND 6B:19:40:EB:2F:9A expired after 61 seconds
[+] 0.2.197 26-07-2019 03:49:38 pm [DEL-RAND]   RAND 6F:E3:E5:2F:AB:66 expired after 190 seconds
[+] 0.2.197 26-07-2019 03:49:38 pm [DEL-RAND]   RAND 60:D7:F8:12:B5:7D expired after 93 seconds
[+] 0.2.197 26-07-2019 03:52:28 pm [DEL-RAND]   RAND 06:85:9E:62:18:60 expired after 153 seconds
[+] 0.2.197 26-07-2019 03:55:15 pm [DEL-RAND]   RAND 41:2A:FF:A3:8E:63 expired after 124 seconds
[+] 0.2.197 26-07-2019 03:55:15 pm [DEL-RAND]   RAND 43:2D:FA:2A:1B:82 expired after 123 seconds
[+] 0.2.197 26-07-2019 03:56:45 pm [DEL-RAND]   RAND 06:85:9E:62:18:60 expired after 162 seconds

Rightā€¦then I for one am out of ideas :frowning: Right now we seem to have reduced the problem to the fact that the scan is not seeing your devices, once it sees them you should be good to go, since everything else is connectedā€¦however, I donā€™t understand why it doesnā€™t see them. Perhaps you should try asking in the main Monitor thread. Sorry :frowning:

Itā€™s a strange one and I too am just about out of ideas also.
Iā€™ll post in the main Monitor thread and see if anyone else has some ideas.

Thanks for all your help with this, its much appreciated.

I installed Hassio in a VM of Proxmox.
I have a Asus BT400 bluetooth usb dongle, but Iā€™m unable to woks it in the VM.
Just I assign it to a usb port it show this error:
Bluetooth: hci0: urb 00000000a24bb708 failed to resubmit (2)

Can anyone help me?

Sorry to comment on an old thread but Iā€™m having problems with monitor running as a service. I can use sudo bash monitor -b in a putty window and everything updates but when I close the window, everything stops, Iā€™ve tried updating the daemon and it all looks fine but any help would be great?

[Unit]
Description=Monitor Service
After=network.target

[Service]
User=root
ExecStart=/bin/bash /home/pi/monitor/monitor.sh -tdr &
WorkingDirectory=/home/pi/monitor
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target network.target

I suggest you ask in the monitor thread.