GithubHelp home page GithubHelp logo

mqtt-homeassistant-utils's Introduction

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 and binary sensors 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_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 two enum classes:

  • HADeviceClassSensor: Enum for sensor device classes.
  • HADeviceClassBinarySensor: Enum for binary sensor 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.

mqtt-homeassistant-utils's People

Contributors

xembalo avatar

Stargazers

 avatar Steffen Müller avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.