mqtt-presence-checker
Check if you (or your phone) is at home and notify your smarthome via mqtt. You can configure this daemon via a toml file in /etc/mqtt-presence-checker/mqtt-presence-checker.conf.
/etc/mqtt-presence-checker/mqtt-presence-checker.conf:
[main]
cooldown = 10
log = "/var/log/mqtt-presence-checker.log"
[mqtt]
host = "mqtt.example.org"
username = "<username>"
password = "<password>"
topic = "presence-checker/presence"
[mqtt.sensor.door-sensor]
topic = "zigbee2mqtt/door_sensor"
predicate = "lambda x: not x['contact']"
[ping]
hosts = [
'alice.example.org',
'bob.example.org'
]
This is rather rudimentary and might crash or behave strange. Feel free to fork me on github and send a PR if you find any bug!
Install with docker
Run with docker:
docker run \
--cap-add net_raw \
--cap-add net_admin \
--name mqtt-presence-checker \
--restart unless-stopped \
-v /etc/mqtt-presence-checker/:/etc/mqtt-presence-checker/ \
--label io.containers.autoupdate=registry \
-d docker.io/rincewindwizzard/mqtt-presence-checker:latest
You can also configure systemd to create the containers using
$ podman generate systemd --restart-policy=always --new -n -t 1 mqtt-presence-checker > /etc/systemd/system/container-mqtt-presence-checker.service
$ systemctl enable container-mqtt-presence-checker.service
Which results in the following systemd unit:
# container-mqtt-presence-checker.service
# autogenerated by Podman 3.4.4
# Sat Oct 29 17:08:56 UTC 2022
[Unit]
Description=Podman container-mqtt-presence-checker.service
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=%t/containers
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=always
TimeoutStopSec=61
ExecStartPre=/bin/rm -f %t/%n.ctr-id
ExecStart=/usr/bin/podman run --cidfile=%t/%n.ctr-id --cgroups=no-conmon --rm --sdnotify=conmon --replace --cap-add net_raw --cap-add net_admin --name mqtt-presence-checker -v /etc/mqtt-presence-checker/:/etc/mqtt-presence-checker/ --label io.containers.autoupdate=registry -d docker.io/rincewindwizzard/mqtt-presence-checker:latest
ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
Type=notify
NotifyAccess=all
[Install]
WantedBy=default.target
Now everytime
$ podman auto-update
is called, the latest container image is redeployed.
Metadata
Release files for mqtt-presence-checker 0.1.18
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mqtt_presence_checker-0.1.18.tar.gz | 9.5 kB | Without provenance | Details for mqtt_presence_checker-0.1.18.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mqtt_presence_checker-0.1.18-py3-none-any.whl | Python 3 | none | any | Details for mqtt_presence_checker-0.1.18-py3-none-any.whl |
Total release size: 20.0 kB
Release files / mqtt_presence_checker-0.1.18.tar.gz
| Download URL | mqtt_presence_checker-0.1.18.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e6111ba2c1fb027509d53d5040fe11bb19f6df226b08b2c06c0fe0c0394ba08c
|
|
BLAKE2b-256 checksum How to use checksums |
6446089fac2fdb24156f8fd03d8e03aa7956b348e1b0ffb50dde75236f4b2b73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.10.4 Linux/5.15.0-52-generic
|
Release files / mqtt_presence_checker-0.1.18-py3-none-any.whl
| Download URL | mqtt_presence_checker-0.1.18-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
caa107593654177d5ae78f0a57d5be399984baba91ca656f8886ad09b50b99d3
|
|
BLAKE2b-256 checksum How to use checksums |
7e85f391297d25421534633d5d48bef1dbb3e886a47b8c8c134d1d05afe1f4e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.10.4 Linux/5.15.0-52-generic
|
Security for mqtt-presence-checker 0.1.18
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.