Limych / addon-presence-monitor

Hassio Add-on. Passive Bluetooth presence detection of beacons, cell phones, and other Bluetooth devices.
MIT License
55 stars 9 forks source link

Can we use the flags for retain and scanning preference? #6

Closed Sjeff closed 4 years ago

Sjeff commented 4 years ago

Is your feature request related to a problem? Please describe.

When Home Assistant restarts the sensors created by the addon are unavailable. (Because retain is not enabeld by default)

Describe the solution you'd like The ability to use the following flags:

        monitor -h      show usage information
        monitor -R      redact private information from logs
        monitor -S      silent operation (no logging)
        monitor -c addr create connection to bluetooth device
        monitor -C      clean retained messages from MQTT broker
        monitor -E      report scan status messages:
                                [topic path]/scan/[arrive|depart]/[start|end]

        monitor -v      print version number
        monitor -d      restore to default behavior settings (mqtt settings and known device settings are not effected)
        monitor -u      update 'monitor.service' to current command line settings
                        (excluding -u and -d flags)

        monitor -s  report all mqtt messages to a single topic with
                                $mqtt_topicpath/$mqtt_publisher_identity  (defined in MQTT preferences file)

        monitor -f      format MQTT topics with only letters and numbers
        monitor -a      report all known device scan results, not just changes
        monitor -x      retain mqtt status messages
        monitor -b      report bluetooth beacons (e.g., generic beacons, ibeacons, and so on)
        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
        monitor -D[dir] use alternative directory for configuration files

i personally use the following flags on my main setup: -a -x -b -tdr and on my secondary setup i use : -a -x -tad

Additional context

To find this info use the -h flag on startup:

monitor.sh

Andrew J Freyer, 2018
GNU General Public License

----- Summary -----

This is a shell script and a set of helper scripts that passively
monitor for specified bluetooth devices, iBeacons, and bluetooth
devices that publicly advertise. Once a specified device, iBeacon, or
publicly device is found, a report is made via MQTT to a specified
MQTT broker. When a previously-found device expires or is not found,
a report is made via MQTT to the broker that the device has departed.

----- Background -----

By default, most BTLE devices repeatedly advertise their presence with a
random mac address at a random interval. The randomness is to maintain
privacy and to prevent device tracking by bad actors or advertisers.

----- Description -----

By knowing the static bluetooth mac address of a specified
bluetooth device before hand, a random advertisement can be used
as a trigger to scan for the presence of that known device. This
construction enables the script to rapidly detect the arrival of
a specified bluetooth device, while reducing the number of times
an affirmative scan operation is required (which may interfere
with 2.4GHz Wi-Fi).

usage:

        monitor -h      show usage information
        monitor -R      redact private information from logs
        monitor -S      silent operation (no logging)
        monitor -c addr create connection to bluetooth device
        monitor -C      clean retained messages from MQTT broker
        monitor -E      report scan status messages:
                                [topic path]/scan/[arrive|depart]/[start|end]

        monitor -v      print version number
        monitor -d      restore to default behavior settings (mqtt settings and known device settings are not effected)
        monitor -u      update 'monitor.service' to current command line settings
                        (excluding -u and -d flags)

        monitor -s  report all mqtt messages to a single topic with
                                $mqtt_topicpath/$mqtt_publisher_identity  (defined in MQTT preferences file)

        monitor -f      format MQTT topics with only letters and numbers
        monitor -a      report all known device scan results, not just changes
        monitor -x      retain mqtt status messages
        monitor -b      report bluetooth beacons (e.g., generic beacons, ibeacons, and so on)
        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
        monitor -D[dir] use alternative directory for configuration files
Sjeff commented 4 years ago

Hi @Limych after updating the following error appears in the addon logs after starting and setting extra arguments:

/usr/local/bin/monitor: illegal option --  

after that the addon just restarts.

Thanks for all your work!

Limych commented 4 years ago

Sorry, I do not have the opportunity now to fix this error as quickly as the past. Will try to fix it tonight…

Sjeff commented 4 years ago

Take your time. Thanks for the fast response