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, DeviceTracker
    • 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.13

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.13
File Size Uploaded Provenance Actions
mqtt_entity-1.2.13.tar.gz 23.9 kB Without provenance Details for mqtt_entity-1.2.13.tar.gz

Built distribution (wheel)

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

Total release size: 50.3 kB

Release files / mqtt_entity-1.2.13.tar.gz

Download URL mqtt_entity-1.2.13.tar.gz
Size 23.9 kB
Tags Source
SHA-256 checksum
How to use checksums
895ad60b81e4864b4d34ab36e125942dee053837ba528487986f72112a0a1771
BLAKE2b-256 checksum
How to use checksums
2f80a4ebfc6bbbc357bdfc95876dcd930774d3e28f1296f47d14e4bb77799da2
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.13-py3-none-any.whl

Download URL mqtt_entity-1.2.13-py3-none-any.whl
Size 26.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f89c2c0fda606dc07f7c82f1adac4eb1ac552dd2110c0fb7c156756276c4244c
BLAKE2b-256 checksum
How to use checksums
11ca5c085d962221a995fe4e7f2d95ed38039c8eebea2cbe3987422f05423933
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.13

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