Skip to main content

MQTT Entity helper library for Home Assistant

Workflow Status codecov

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
  • 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)

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.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mqtt-entity 1.2.11
File Size Uploaded Provenance
mqtt_entity-1.2.11.tar.gz 23.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mqtt-entity 1.2.11
File Interpreter ABI Platform
mqtt_entity-1.2.11-py3-none-any.whl Python 3 none any Details

Total release size: 49.8 kB

Release files / mqtt_entity-1.2.11.tar.gz

Download URL mqtt_entity-1.2.11.tar.gz
Size 23.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7c5915715935ef714ef06711a081198e792755721c491b483376c12385607833
BLAKE2b-256 checksum
How to use checksums
fa67bb2d7c04563c15b8a62097d08b7d515e3b42a80acabc6b79499655f291f1
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.11-py3-none-any.whl

Download URL mqtt_entity-1.2.11-py3-none-any.whl
Size 26.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d5361a91b65ae6ca29e51857b6d912b6ab8ed8a02367ed118c376743e66c781
BLAKE2b-256 checksum
How to use checksums
cd8dae62a4814e7fea897bb28b2d4368e8fe31dce0270ab1728c1097784cf027
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}

Security for mqtt-entity 1.2.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.2.11 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page