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.2
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.2.tar.gz | 22.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mqtt_entity-1.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 47.2 kB
Release files / mqtt_entity-1.2.2.tar.gz
| Download URL | mqtt_entity-1.2.2.tar.gz |
|---|---|
| Size | 22.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
51de8dac3eb4e10d2cca7c812c2ea71ee24b7103dc6dcecb65694f4784093b9f
|
|
BLAKE2b-256 checksum How to use checksums |
6425372bee2cc63bcf7e4c5c7b0538999ad4e9a9e562a3a574b13f6462c476a3
|
| 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.2-py3-none-any.whl
| Download URL | mqtt_entity-1.2.2-py3-none-any.whl |
|---|---|
| Size | 25.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e4ae7f3b7efb89711305be088c3cbf932bbeaa2f0be155520240c4075af7b295
|
|
BLAKE2b-256 checksum How to use checksums |
cc651683e89783793b343973e2eb9fba5f3bb1be54be09c7627956218c3e48bf
|
| 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}
|