For testing from the command line, use hcitool name MAC:ADDRESS:OF:YOUR:DEVICE
If nothing returns, the device is not found. If the name of your device returns, the device is found.
For testing from the command line, use hcitool name MAC:ADDRESS:OF:YOUR:DEVICE
If nothing returns, the device is not found. If the name of your device returns, the device is found.
Thanks for testing!
Finally doing some testing using monitor. Seems to be working well except when I try to use the “trigger only” mode on the command line. With presence I used the -t 1 arguments, but am using just -t with monitor. I am able to trigger the scan, but not seeing any corresponding mqtt messages. Without the -t argument, I can see the mqtt publish messages.
Hope that makes some sense - if not I can attach a log.
Thank again for all your efforts!!
…wait - I do see mqtt publish for each monitored device - but only on the initial trigger after I start monitor (with -t argument). Is it possible that mqtt publish only happens if there has been a change in status?
I have been testing for a few days now also. Just been using the out-of-the-box settings.
It seems to be working well in terms of less interference. However, I have had various crashes, which have required restarts. I am not sure how best to track down logging to identify how/when this happens, so am eagerly anticipating some brief docs
@eboon Make sure to note that the trigger options have been split into /arrive
and /depart
. Yes, by default only changes are shown. This was an often requested feature of presence
.
-h
flag for options right now
@painsom - I’m getting there! haha. Still testing, but it does seem to work much better for me now. Especially when using mqtt triggers for depart.
Good deal … so working well so far. What’s the difference between a triggered “arrival” scan versus “departure”?
Thanks again!
Just got monitor up and running and will report back on any issues. Everything is working well thus far. Thanks a bunch for putting this together!
I use this for Bluetooth tracking for announcements, it works very well!
I really like answering my own questions … hahahaha. Seems an “arrive” scan only scans for devices that are marked as away (0 confidence?), and I’m guessing a “depart” scan only looks for devices that are home (confidence 100?). So to get the same functionality that I had when using the trigger mode of presence, I’m guessing I need to trigger both a “depart” and “arrival” scan? (Based on my sensors, I wouldn’t be quite confident enough to just one or the other). It’s cool though …
Yeah, I’ve realized the same thing. So for now, it’s set to trigger both scans.
Im trying out monitor (had troubles with HA going down with “presence” and requiring power cycling to get it going again).
Do I read the code correctly that you can trigger a scan by publlshing to the MQTT channel?
I think that’d be neat - both entrances to my house can be detected by HA, so I could use those to trigger a scan and (say) turn off the alarm, rather than waiting for the full scan cycle.
Yes, you can start monitor with -t argument and publish “scan/depart” or “scan/arrive” to the topic. -h will get you a quick help blurb.
Thanks. I’ve had a look at the code now. the -t
option would seem to lead to “trigger only” scans which isn’t what I’m after. I want to do default scans most of the time, but trigger a scan when (say) my front door opens.
Reading the code I suspect that is already the case, but want to confirm. The main loop appears to respond to MQTT without being in -t
mode. Please correct me if I am wrong!
Documentation (eventually) will clarify this, but the MQTT triggers work all the time. The -t
trigger will scan only in response to the MQTT posts.
Otherwise, arrive scans are based on the rand_adv packets transmitted by nearly all BTLE devices.
The monitor script separates arrive and depart scans to reduce scan frequency. If all devices are home, for example, it’s not necessary to do an arrive scan under any circumstances. Similarly, if all devices are away, a depart scan isn’t necessary. If only one device is home, a departure scan will only scan for departure of that device. And so on…
Personally, I am using the monitor script with flags -b -P
to scan for beacons and public device advertisements in addition to my known devices. Then I trigger depart via MQTT (after a ten second delay) once my garage door and front door are opened.
This configuration has reduced scanning by a huge amount, and has increased arrival detection speed. At least anecdotally.
I recommend avoiding the -t
flag for now. Right now, it’s confusing coming from presence
Hi!
Yesterday I finished the setup of the flow for presence detection in node-red, with some changes to adapt it to my personal setup, and I’m having issues with the monitor script and the watchdog flow.
As far as I understand, the watchdog flow will only trigger the notification if no updates has occur in the MQTT topic for the last 10 minutes. Right now I’ve 4 Raspberry Pi configured, 1 is down, 1 is using monitor script, 2 are using presence script. Funny enough, the only one that is sending “not detected” alerts is the one using monitor, the other 3, including the one that is not publishing anything (the topic is not even created, I’ve configured everything, but the Pi is not there yet)
Another thing that bugs me is that the notification during the night came every 10 minutes, but sometimes takes a bit more, so it seems that it worked a few times… for example:
12:46AM,12:56AM, 1:18AM, 1:28AM, 1:38AM… [] … 11:48AM, (here I did a git pull and a restart of monitor)12:05PM, 12:15PM, 12:30PM (!), 12:40PM, 12:50PM…
Cheers!
I’ve added several debug nodes to the flow, and this is what I’m getting:
For one using presence:
7/16/2018, 2:25:53 PMnode: 9b7bb6a7.xxxxxx
location/owner/PBaja/MyMAC_Address : msg : Object
object
topic: “location/owner/PBaja/MyMAC_Address”
payload: object
confidence: “0”
name: “Galaxy S8”
scan_duration_ms: “5023”
timestamp: “lun jul 16 2018 14:25:44 GMT+0200 (CEST)”
qos: 0
retain: true
_msgid: “f2670d59.xxxxxx”
For the one that is NOT working:
7/16/2018, 2:25:53 PMnode: 9b7bb6a7.yyyyyy
location/owner/calle/MyMAC_Address : msg : Object
object
topic: “location/owner/calle/MyMAC_Address”
payload: object
confidence: “0”
name: “Galaxy S8”
scan_duration_ms: “5024”
timestamp: “Wed Jul 11 2018 20:25:10 GMT+0000 (UTC)”
qos: 0
retain: true
_msgid: “7aef5ffe.yyyyyy”
Please note the timestamo in the one that is not working :S.
I’ve also cheched the configuration in monitor files:
cat mqtt_preferences
mqtt_address=Broker_IP
mqtt_user=Super_Secret_User
mqtt_password=Super_Password
mqtt_topicpath=location
mqtt_publisher_identity=‘calle’
mqtt_port=‘1883’
And the MAC address list:
cat known_static_addresses
00:00:00:00:00:00 MyMac
11:11:11:11:11:11 WifesMac
The configuration seems ok to me…
Regards
What command line options are you using?
Hi Andrew, I’m executing it as a service, I just executed it first time, and the script created everything. I’ve checked the service and this is what is using:
cat /etc/systemd/system/multi-user.target.wants/monitor.service
[Unit]
Description=Monitor Service
[Service]
User=root
ExecStart=/bin/bash /root/monitor/monitor.sh &
WorkingDirectory=/root/monitor
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
Cheers!