I used a command strip to attach each directly to the power brick. Probably adds wild interference, but whatever.
@andrewjfreyer Yup it looks like you understood exactly why I stop the service. I think your solution will be better since I wont have to wait for the monitor service to boot back up after the door opens. With your fix it should save me a few seconds on depart. If I am reading your solution correctly than this would essentially allow me to turn off my phone once it has arrived even if both devices are not home.
My only worry is if I leave, how long will it do the depart scan for? My elevator is relatively close to my front door. I would still want it to scan for a couple minutes just to make sure that I have truly left the house.
thanks for this BTW, I didnt want to ask because you are already doing a bunch of work on the project and I didnt know how many people actually let there phones die when they are at home.
@Odianosen25 I am not 100 percent worried about the security part of things, it was more of an annoyance. In my actual Door lock settings (August Lock) I have it set to lock immediately when the door closes (about 3 seconds). So my front door is essentially always locked. I am only stopping the service when all devices are home for 4 minutes. If my devices are both home and my door hasnāt opened there is no longer a need for monitor to worry about anything until my door actually opens again (since both devices are already home).
currently if I donāt stop the service my phone will turn on after recovering from off/dead and monitor would sense that I am home an open my door. (the august lock will auto re-lock if the door hasnt been open for 1 minute)
First iām really sorry for insisting on something that people have answered so many times but my ignorant head stidd doesnāt get it:
So I, like some others, must have more then one instance of monitor running, but I know for a fact that If I havenāt connect to a specific one Iām not at home this is where -t option enters:
monitor -t[adr] scan for known devices only on mqtt trigger messages:
a \$mqtt_topicpath/scan/ARRIVE (defined in MQTT preferences file)
d \$mqtt_topicpath/scan/DEPART (defined in MQTT preferences file)
r send ARRIVE or DEPART messages to trigger other devices to scan
This is perfect āstop everythingā until I say i need your help.
Just for the sake of making this as clear as water (monitor+mqq for dummys (like ME) )
HA: 192.168.1.1
front door: 192.168.1.2 (topic: /door/00:00:00:00:00:00 )
bed room: HA: 192.168.1.3 (topic: /room/00:00:00:00:00:00 )
Now the problematic part for someone like me (maybe even just me)
I use HA so my mqtt server is on my HA server, which means I have credentials setup on my mqtt_preference file for my HA server (HA: 192.168.1.1)
Now for me to get this option to work I need to send/publish messages to the topics
/room/00:00:00:00:00:00 which on my exemple is on server 192.168.1.3
I have mosquitto running:
pi@monitor_quarto:~ $ mosquitto
1537520034: mosquitto version 1.5 starting
1537520034: Using default config.
1537520034: Opening ipv4 listen socket on port 1883.
1537520034: Error: Address already in use
This gives me nothing
pi@monitor_quarto:~ $ mosquitto_sub -t /#
This all seam correct since I publish to my HA server and noting is ālocalā to each monitor pie, so How can I publish in a way to get the -t option working?
can i publish on a āautomationā frm the HA to the HA mqtt server? This means that both monitors are subscribed to the topic on my mqtt server (if so this is the missing link, that i wasnāt able to undesrtand).
So I ask again, based on the exemple I gave, how can I trigger an arrive/departure scan on any of the pieās running the monitor since both publish to a remote mqtt server (my HA pie)
Thank you and once more sorry for the āinsistingā on the ābasicā topic for many of you but i canāt get this to work.
Honestly if you look at @andrewjfreyer commits he seems to be changing a lot of code in the last several hours.
Just my personal opinion. The -t option is good but BY DEFAULT you can already do manual triggers anyways. -t just makes it where it is required that you do a manual depart and a manual arrive trigger.
if you know your MQTT decently you need to get a broker on a different terminal windows or on a different computer and subscribe to your current MQTT server for ā#ā.
Now put the Piās in the default mode without any parameters. After you reboot the Piās you should see what type of messages are posted. Once you have the device detected turn on the bluetooth on your device/phone and see what depart message is sent on the computer that you have subscribed to # from the mqtt broker.
This will essentially give you the correct format for how to publish the triggers manually. By default if 1 Pi puts the confidence to 0 it will sent a depart trigger and vice versa when a Pi puts the device at 100 percent confidence.
short answer: Subscribe to your Mqtt server with # and read the messages that the Piās are ending in depart mode. This will tell you what arrive/ depart signal the Piās are listening to. Once you have these messages if you desire to ONLY scan for depart and arrive on trigger than you can put the piās back in -t mode and use the messages that you just saw when subscribed to #.
Hopefully one of the last questions Iāll be asking hereā¦(as things are working really well for me now).
If youāre using multiple Pi Zeros, and the idea is that if one Pi canāt āseeā your bluetooth entity it then (and only then) triggers a scan on the other Zerosā¦can those Zeros also be used for arrival scans? Basically I have two possible routes of entry into my house and Iād like it possible that all of my Zeros are actively scanning for arrivals. Is this do-able?
I think this is something that is still being implemented. In previous versions it would send the depart to the Other piās and they would ignore the arrival scans until the depart scan was completed. Essentially it would reject the arrive scan.
It looks like in version [0.1.629] he may have changed this behavior where it doesnāt actually reject the arrival scan it just queues it up. Donāt quote me but this either was just recently added or it is something he is still working on.
ah - thanks - so at the moment only one Pi Zero can detect arrivals, but they can all detect departures?
Well I have tried,
I have updated the monitor to the latest version [v. 0.1.635] created all new required properties:
preference: beacon rssi change required for reporting = 10
preference: bluetooth environmental report frequency = 300
preference: forced departure check interval = 240
preference: interval until beacon is considered expired = 145
preference: trigger a departure scan at other nodes below confidence = 25
preference: preferred HCI device = hci0
preference: minimum time between the same type of scan = 15
I got the topic:
0.1.635 02:54:24 pm [CMD-SCAN] (No. 1) 5C:1D:D9:19:AB:00 departure?
0.1.635 02:54:25 pm location/monitor/quarto/5C:1D:D9:19:AB:00
{
retain: false
version : 0.1.635
confidence : 100
name : JPM
timestamp : Fri Sep 21 2018 14:54:25 GMT+0100 (WEST)
manufacturer : Apple, Inc.
type : KNOWN_MAC
}
tried from another machine publishing to the topic:
location/monitor/quarto/00:CD:FE:C9:AB:00/scan/ARRIVE (no message)
and
location/monitor/quarto/00:CD:FE:C9:AB:00 message: /scan/ARRIVE
on the server that is running the monitor and nothing.
I give up, iāve just added an sonoff pow with the trigger of my door sensor and voila, I keep getting my 2.4Ghz channels āunderwaterā but hey this is still by far the best location monitor for what i need.
Thank you @andrewjfreyer for all your personel time you have dedicated to us, and thank you @benjimatt for the help
I found a bug and updated this morning. That may solve your issue. But, again, your MQTT topics are incorrect. Try subscribing to # and see exactly what is being received by a broker
@jpm Iāve also updated this morning to output the exact MQTT topic path you should subscribe to for all your known devices.
As far as the scan/arrive messages, your topics are not correct. The entire topic should be just:
location/monitor/scan/arrive
or
location/monitor/scan/depart
(NOTE: please verify in your mqtt_preferences file that your mqtt_topicpath is actually ālocation/monitorā, your logs above show a non-default topic path)
These scan messages indicate to all nodes connected to your broker that they should scan.
this are correct since I seperated the pies according to the topic:
PUBLISHER IDENTITY
mqtt_publisher_identity=ādivision where i put the pieā
MQTT PUBLISH TOPIC ROOT
mqtt_topicpath=location/monitor
Thinking about itā¦if you ran two Pi Zeros, but didnāt have them operating master/slaveā¦couldnāt you achieve the same aim? I think if you had a Pi Zero in the house tracking arrives/departs and one at the end of the garden watching out for arrivals onlyā¦that would work.
Basically in your HA automations you could simply not program any action for departure scans received from that particular Pi. Does that make sense?
EDIT: The more I think about this, the more I think this is the answer. Donāt ālinkā the Pis, just have BOTH setting arrival in HA, but only ONE of 'em setting depart.
So, if youāre running monitor
with default settings, and you publish to the topic ālocation/monitor/scan/departā your node should trigger a scan for your known devices.
What happens instead?
First iām sorry but Iām assuming you are on USA or another GMT+xx hours so we have āoppositeā schedules:
I have published to location/monitor/quarto/scan/depart and i think i saw something:
TIME
TIME
MQTTlocation/monitor/scan/depart (null)
Just as a side note, this version is causing a lot more ānoiseā on my wifi, as soon as i power up the device I immediately see packageās dropping on connection to a point I really need to get this āon triggerā to function or i can use it, but I recommend more feedback because i leave on a building and maybe some neighbor connected something and is causing this interference
Another note I think that time worked but any subsequent trials didnāt either depart or arrive, this last didnāt work ever.
Is this what Iām suppose to see?
how many devices are you trying to monitor? Are you worried that one device will be leaving and a depart scan start while another device is returning home?
Idea: when a scan is finished post to a topic and then ha can be in charge of whether another scan is needed.
Might be simpler than queuing?
That log shows that you are posting to location/monitor/scan/depart
and the script has responded, so everything seems to be working fine.
How many devices are in your known_static_addresses file? Can you run monitor.sh
from the command line and post all the results here or to github?
Update: 0.1.642
Major Change Log:
-
Triggers are updated! Now, we can specify whether we trigger only on arrive or only on depart or only on both.
I know thatās a bit confusing. Sorry. Iāll explain:
-td
only scan for device departure in response to receiving$mqtt_topicpath/scan/depart
-ta
only scan for device arrive in response to receiving$mqtt_topicpath/scan/arrive
-tad
only scan for device departure in response to receiving$mqtt_topicpath/scan/depart
and only scan for device arrive in response to receiving$mqtt_topicpath/scan/arrive
In addition, we can now specify whether a monitor script will trigger other nodes. Also use the
r
option with the trigger flag will cause a device to trigger scans at other notes -
MQTT reporting on node reboot bugfixes
-
argv processing bugfixes
-
readme updates
Iām having a problem with my mother-in-lawās phone. She has an iPhone and as soon as she turns the screen off, her confidence level drops to zero. My wife has an iPhone, and that doesnāt happen. I use Android, so Iām not sure if there is setting I need to change or something. Thanks!