Skip to main content

A Home Assistant MQTT client library

Project description

NirahMQ

PyPI - Version GitHub Actions Workflow Status

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.3a0.tar.gz (53.4 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.3a0-py3-none-any.whl (37.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nirahmq-0.1.3a0.tar.gz
  • Upload date:
  • Size: 53.4 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.3a0.tar.gz
Algorithm Hash digest
SHA256 a18f10c181007e84f6b805bfe689ca4f26c28d281878edadecfcaa23596b0c83
MD5 d03fb6a6014ce59b6db8c0e76b16dfca
BLAKE2b-256 18f1aae0efe6922a5d6d0306e5e07857ddd7a67f664644910b60cea7f6e507a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirahmq-0.1.3a0.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.3a0-py3-none-any.whl.

File metadata

  • Download URL: nirahmq-0.1.3a0-py3-none-any.whl
  • Upload date:
  • Size: 37.0 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.3a0-py3-none-any.whl
Algorithm Hash digest
SHA256 3f95df52d3e0192ab44ae75c13e1d8ff28caab50c1ac0f8a5148acf2f53b06eb
MD5 57003c6c7bf37139c028aea9aa1fda98
BLAKE2b-256 020b44f12b001e41bad48d0a4a695fa105a1ed1e33eedb3eaa345d4899c8dfbc

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirahmq-0.1.3a0-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