A helper project to work with the mqtt integraton in home assistant
Project description
MQTT Home Assistant Utils
A helper project designed to facilitate working with the MQTT integration in Home Assistant.
Overview
This repository contains Python code for generating Home Assistant (HA) MQTT discovery payloads. These payloads are used to configure sensors, binary sensors and others in Home Assistant via MQTT.
File Structure
mqtt_homeassistant_utils.py: Python script containing the data classes and enums for generating HA MQTT discovery payloads.
Usage
To use the provided code, you can create instances of the defined data classes, configure their properties, and publish the MQTT discovery messages. Here's a basic example:
# Import necessary classes
from mqtt_homeassistant_utils import HASensor, HADeviceClassSensor
import paho.mqtt.client as mqtt
# Create a sensor instance
sensor = HASensor(
component="sensor",
node_id="node1",
unique_id="temperature_sensor",
name="Temperature Sensor",
state_topic="sensor/temperature",
device_class=HADeviceClassSensor.TEMPERATURE,
unit_of_measurement="°C"
)
# Configure MQTT client
mqtt_client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)
mqtt_client.connect("mqtt_broker_address", 1883)
# Publish the MQTT discovery payload
sensor.publish(mqtt_client, qos=1)
Make sure to customize the configurations according to your specific setup.
Initial Development
This project was initially developed for personal use in my own Home Assistant projects. While it's tailored to my specific needs, I welcome feedback and contributions. If you have specific entries you'd like to see added, feel free to open a request!
Enums
The code includes enum classes:
HADeviceClassBinarySensor: Enum for binary sensor device classes.HADeviceClassCover: Enum for cover device classes.HADeviceClassSensor: Enum for sensor device classes.HADeviceClassSwitch: Enum for switch device classes.
Contributing
Feel free to contribute to this project by opening issues or submitting pull requests. Your feedback and contributions are welcome!
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mqtt_homeassistant_utils-0.0.10-py3-none-any.whl.
File metadata
- Download URL: mqtt_homeassistant_utils-0.0.10-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85fc351d64786964c7f5a98171b499045a95760790d3b56435e40de478236a90
|
|
| MD5 |
b481b690991b27d4e9001faae1d26496
|
|
| BLAKE2b-256 |
62033056547451cafbe3c7f0ce91c4249e1039b65d9e111a8e9f6e011c4d0db6
|