Skip to main content

A Home Assistant MQTT client library

Project description

NirahMQ

A complete Home Assistant MQTT Python library with ease of use in mind

[!WARNING] This library is currently in ALPHA! Expect things to change or break!

✨ Features

  • Supports all Home Assistant MQTT components and all their features
  • Use of device-based discovery instead of component-based for simpler organization
  • Support for automatic cleanup of topics on exit
  • Device wide and per component availability support
  • MQTT birth and last will support for both device and Home Assistant
  • Ease of use by simple static definitions, while allowing runtime modifications
  • Full Python type hint support
  • Validation of definitions and user inputs on load thanks to pydantic
  • Extensible API through simple class inheritance

📦 Installation

NirahMQ requires Python 3.12 or later and can be installed simply with pip install nirahmq.

🚀 Simple example

Below is an example of a simple Text component that prints its contents on update:

Example code
from nirahmq.components import Text
from nirahmq.device import Device, DeviceInfo, DiscoveryInfo, OriginInfo
from nirahmq.mqtt import MQTTClient


def callback(text: Text, payload: str) -> None:
    print(f"Got new text: `{payload}`")
    text.set_text(payload)


dinfo = DiscoveryInfo(
    device=DeviceInfo(
        name="NirahMQ Test Device",
        identifiers="NirahMQ-Test-Device"
    ),
    origin=OriginInfo(
        name="Python Program"
    ),
    components={
        'component1': Text(command_topic="~/cmd", state_topic="~/state", command_callback=callback)
    }
)

with (MQTTClient("homeassistant.lan", 1883, "user", r"password") as client,
      Device(client, dinfo, "node_id") as device):
    input("Press enter to continue...\n")

📝 License

Copyright © 2025 Dionisis Toulatos

NirahMQ uses the AGPL-3.0+ license

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nirahmq-0.1.2a0.tar.gz (53.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nirahmq-0.1.2a0-py3-none-any.whl (36.8 kB view details)

Uploaded Python 3

File details

Details for the file nirahmq-0.1.2a0.tar.gz.

File metadata

  • Download URL: nirahmq-0.1.2a0.tar.gz
  • Upload date:
  • Size: 53.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for nirahmq-0.1.2a0.tar.gz
Algorithm Hash digest
SHA256 7557aa3da8726905ab741bb12dc63272c5a1b83aab39f6413939f1db10a1595e
MD5 7f909bb6afc455a5545834cc3a39ce9f
BLAKE2b-256 60ad78cc33549f5888fa56c56f2ae52d9362e2926950b0dff7131383ee98e0b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirahmq-0.1.2a0.tar.gz:

Publisher: release.yaml on dionisis2014/nirahmq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nirahmq-0.1.2a0-py3-none-any.whl.

File metadata

  • Download URL: nirahmq-0.1.2a0-py3-none-any.whl
  • Upload date:
  • Size: 36.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for nirahmq-0.1.2a0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe10cc8d843353df531883b1a58c07e53123a1541458722097d295b52eff7755
MD5 5d275ebd43d368bd106d5a139add1c35
BLAKE2b-256 255c73aa7d65f31f119a4ea49a395284120dd4ac826df7ee7f45fd1f44318229

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirahmq-0.1.2a0-py3-none-any.whl:

Publisher: release.yaml on dionisis2014/nirahmq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page