Monitor Unifi clients and publish status to MQTT
Project description
unifi2mqtt
Monitor Unifi clients and publish their connection status to an MQTT broker.
Installation
pip install unifi2mqtt
Usage
usage: __main__.py [-h] --unifi-url UNIFI_URL --unifi-user UNIFI_USER --unifi-pass UNIFI_PASS [--unifi-site UNIFI_SITE]
[--unifi-ignore-ssl] --mqtt-host MQTT_HOST [--mqtt-port MQTT_PORT] [--mqtt-user MQTT_USER]
[--mqtt-pass MQTT_PASS] [--mqtt-topic MQTT_TOPIC] [--mqtt-client-id MQTT_CLIENT_ID]
[--timeout TIMEOUT] [--filter-macs FILTER_MACS] [-i INTERVAL]
[--use-specific-last-seen {last_seen,_last_seen_by_uap,_last_seen_by_usw,_last_seen_by_ugw,_last_reachable_by_gw}]
[-d] [-v]
Monitor Unifi clients and publish status to MQTT
options:
-h, --help show this help message and exit
--unifi-url UNIFI_URL URL of the Unifi Controller (default: None)
--unifi-user UNIFI_USER Unifi username (default: None)
--unifi-pass UNIFI_PASS Unifi password (default: None)
--unifi-site UNIFI_SITE Unifi site (default: default)
--unifi-ignore-ssl Ignore SSL verification (env variable UNIFI_IGNORE_SSL) (default: False)
--mqtt-host MQTT_HOST MQTT broker host (default: None)
--mqtt-port MQTT_PORT MQTT broker port (default: 1883)
--mqtt-user MQTT_USER MQTT username (default: None)
--mqtt-pass MQTT_PASS MQTT password (default: None)
--mqtt-topic MQTT_TOPIC MQTT topic prefix (default: unifi2mqtt)
--mqtt-client-id MQTT_CLIENT_ID MQTT client ID (default: unifi2mqtt)
--timeout TIMEOUT Timeout in seconds for last_seen (Standard: 60) (default: 60)
--filter-macs FILTER_MACS Comma-separated list of MAC addresses to include. If not set, you'll get all
clients listed (default: "")
-i, --interval INTERVAL Interval in seconds between checks (default: 60)
--use-specific-last-seen {last_seen,_last_seen_by_uap,_last_seen_by_usw,_last_seen_by_ugw,_last_reachable_by_gw}
Comma-separated list of MAC addresses to includeIf not set, you'll get all clients
listed (default: None)
-d, --debug Enable debug logging (default: False)
-v, --verbose Enable verbose logging (default: False)
Launching it
You will need a local user for the programm to been able to run.
So go to Settings -> Admin & Users -> Admins -> Create new User and create a user and tick the "Restrict to Local Access Only". The User only needs View Only permissions.
Running it locally
unifi2mqtt --interval 1 \
--unifi-url "https://192.168.2.1" \
--unifi-user "localUser" \
--unifi-pass "localUserPass" \
--mqtt-host "mqtt.local" \
--unifi-ignore-ssl \ # if needed
--filter-macs aa:bb:cc:dd:ee:ff,11:22:33:44:55:66
Running it in Docker
docker run --d --restart=unless-stopped --name unifi2mqtt \
-e UNIFI_URL=https://192.168.2.1 \
-e UNIFI_USERNAME=localUser \
-e UNIFI_PASSWORD=localUserPass \
-e MQTT_HOST=mqtt.local \
-e UNIFI_IGNORE_SSL=true \
-e MQTT_TOPIC=unifi2mqtt \
-e TZ=Europe/Berlin \
-e FILTER_MACS=aa:bb:cc:dd:ee:ff,11:22:33:44:55:66 \
freakern/unifi2mqtt:0.2.0 -d
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file unifi2mqtt-0.3.1.tar.gz.
File metadata
- Download URL: unifi2mqtt-0.3.1.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
493c99fdcf5b351696fc8fc84fa3314af68828f49da3fbee3e147b6530dc9e4d
|
|
| MD5 |
d04e38af2267a74ab9de0389adabc98f
|
|
| BLAKE2b-256 |
0b0d613b7c746845803bcb3027082ca05a93f1a87403ff65dbe4c2d34f7fda04
|
File details
Details for the file unifi2mqtt-0.3.1-py3-none-any.whl.
File metadata
- Download URL: unifi2mqtt-0.3.1-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
398b1ba7ae00f51f12b9c6ca5d0cdef0cc6cf7cabdc8e73e757e6ddc8b669911
|
|
| MD5 |
d8c331ba336c7481e2a83691b739224a
|
|
| BLAKE2b-256 |
f1971b5f59a301a77eafdf451553ddbda15694a229053f6c3ca936c118707c32
|