MQTT client supporting Home Assistant MQTT entity auto-discovery
Project description
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
- Manage entities per device
- Home Assistant Entities modelled as attrs classes:
- 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 attrs classes
- 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 attrs classes
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.
Alternatives 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 :dolphin: 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
git commit -m ":rocket: Release 0.x.0"
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
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 mqtt_entity-1.0.21.tar.gz.
File metadata
- Download URL: mqtt_entity-1.0.21.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97715a6f356d30286c96ea4af773e5882cab25da1d46a1594117dd3a53f43f5f
|
|
| MD5 |
265ce5a30812772fd6cec9a51b7a2b94
|
|
| BLAKE2b-256 |
28f9cbd67f10af9f51e65107da068dac94c1a04b2ee0d7b8a20ab1459de4eb8d
|
File details
Details for the file mqtt_entity-1.0.21-py3-none-any.whl.
File metadata
- Download URL: mqtt_entity-1.0.21-py3-none-any.whl
- Upload date:
- Size: 19.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b67064c968b76cff12385cc62c228702cb7bd1548316b626915f54c009af10f
|
|
| MD5 |
e3420b5065eb2d4c002ff842953f377c
|
|
| BLAKE2b-256 |
95d640e70634c3079185ac77c90a5a7e5ce7a73f97de5acc0892ad31efae3ae0
|