Skip to main content

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: unifi2mqtt [-h] --unifi-url UNIFI_URL --unifi-user UNIFI_USER --unifi-pass UNIFI_PASS [--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] [-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-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 includeIf not set, you`ll get all clients
                                    listed (default: )
  -i INTERVAL, --interval INTERVAL  Interval in seconds between checks (default: 60)
  -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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unifi2mqtt-0.2.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unifi2mqtt-0.2.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file unifi2mqtt-0.2.0.tar.gz.

File metadata

  • Download URL: unifi2mqtt-0.2.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for unifi2mqtt-0.2.0.tar.gz
Algorithm Hash digest
SHA256 60ea7787c63737b71d99e11c71f3ca4bbf29acc9eaab631feeddc58c7c5fde1a
MD5 0aa861908c2801d33e19fad2445b05ce
BLAKE2b-256 bc077563d5a15bc3217b82d37e61267c9a7dca2190915b513a438f2304884ec1

See more details on using hashes here.

File details

Details for the file unifi2mqtt-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: unifi2mqtt-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for unifi2mqtt-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4444324797f04a0c47440d409aad1d379b1274d98598540db56f77fd0be20bac
MD5 a6876d88ec00a51436d815f4cc73225a
BLAKE2b-256 caf5703fc1cedc7c71e64ccef120a54717c5ec944d2c3229ecfba19fea2bc3e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page