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

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.12
File Size Uploaded Provenance
mqtt_entity-1.2.12.tar.gz 23.7 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 49.8 kB

Release files / mqtt_entity-1.2.12.tar.gz

Download URL mqtt_entity-1.2.12.tar.gz
Size 23.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e85509d95030185ecc80f06815c06003a2f3230e75caf338d6445983c331a2eb
BLAKE2b-256 checksum
How to use checksums
778de72e543eabba9e2b34548cea671bb21fadf419fcf3fb13864e89532f24da
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.12-py3-none-any.whl

Download URL mqtt_entity-1.2.12-py3-none-any.whl
Size 26.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5730d3361c83dfde9b8a4b35b04dc6a008e49544f55be15f9b52ba5ad9324358
BLAKE2b-256 checksum
How to use checksums
c222062e540d120a7332983aea2c57c36062b125d3b5a51924a64945f6464eb2
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.12

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