MQTT Entity helper library for Home Assistant
A Python helper library to manage Home Assistant entities over MQTT.
Updated for device based MQTT discovery.
Features:
- MQTT client based on paho-mqtt
- Retrieve MQTT service info from the Home Assistant Supervisor
- Manage MQTT discovery info (adding/removing entities)
- MQTTDevice class to manage devices
- Availability management (client-wide and optional per-device
availability_topics) - Manage entities per device
- Availability management (client-wide and optional per-device
- Home Assistant Entities modelled as dataclasses:
- Read-only: Sensor, BinarySensor
- Read & write: Select, Switch, Number, Text, Light
- MQTT device events
- Asyncio based
- Helpers for Home Assistant add-ons (optional)
- Add-on configuration modeled as dataclasses
- Load from environment variables, HA's options.yaml or options.json
- Load MQTT connection settings from the Supervisor
- Enable add-on logging (incl colors & debug by config)
- Add-on configuration modeled as dataclasses
Why?
This MQTT code was included in several of my home Assistant addons (SMA-EM / Sunsynk). It is easier to update a single library & add new features, like discovery removal.
Alternative options (not based on asyncio)
Credits
@Ivan-L contributed some of the writable entities to the Sunsynk addon project
Release
Semantic versioning is used for release.
To create a new release, include a commit with a 🐬 emoji as a prefix in the commit message. This will trigger a release on the master branch.
# Patch
git commit -m ":dolphin: Release 0.0.x"
# Minor - any commit
Development
To run the tests, you need to have Python 3.12+ installed.
The --mqtt connects to a live Home Assistant instance using the MQTT broker.
uv run pytest --mqtt
Metadata
Release files for mqtt-entity 1.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mqtt_entity-1.2.4.tar.gz | 22.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mqtt_entity-1.2.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 48.8 kB
Release files / mqtt_entity-1.2.4.tar.gz
| Download URL | mqtt_entity-1.2.4.tar.gz |
|---|---|
| Size | 22.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9c56eee1cc37420d1d72a9339235a4b2bb096a43cd176da8c88d11fa66b538de
|
|
BLAKE2b-256 checksum How to use checksums |
254b1131d482d43c23e93657d920a721d3ebc2ea8db5dc07b45de020efffa031
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / mqtt_entity-1.2.4-py3-none-any.whl
| Download URL | mqtt_entity-1.2.4-py3-none-any.whl |
|---|---|
| Size | 26.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e9a106f9e5a95c7d603a9e1a116f865afb5548e3fd1277ae55a36d2717b97995
|
|
BLAKE2b-256 checksum How to use checksums |
b1b9eab4a544befdd79aa3db503ad409bdd4d9b200972de8cdc5023ad7026a84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|