Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

mqtt-leds

Overview

mqtt-leds is a Python package designed to control multiple types of LED strips using MQTT, making it easier to integrate lighting controls with the Home Assistant platform. Currently specific to the GPIO pins of the Raspberry Pi but I intend to abstract that part of the code to make it work on any platform.

Current requirements

  • A raspberry PI, since the package directly refer to the GPIO pins for data transmission, and ensure you have the necessary permissions to access them (Root access) How to set up the lights with the Raspberry Pi
  • Homeassistant instance
  • An MQTT broker to facilitate communication between the Home Assistant and the WS2811 LED strips

Local Installation (Options 1)

Use Poetry to install the package:

poetry install

PyPI Installation (Option 2) - Recommended

The mqtt-leds package is also published on PyPI, allowing you to easily install it using pip. This enables seamless integration into projects without using Poetry.

pip install mqtt-leds

Usage

Here's a quick example on how to use mqtt-leds in your project:

env file

Multiple ways of doing this:

  1. You can pass the env vars directly to the executable
  • example: MQTT_BROKER=192.168.0.100 MQTT_PORT=1883 ... mqtt-leds
  1. create an env file where the script is run, and it will automatically be loaded
  2. Pass the path to your env file as an Environment variable: WS2811_ENV_PATH and it will read from there. (Recommended)
NUM_LEDS = 50
MQTT_BROKER = "192.168.0.123"
MQTT_PORT = 1883
MQTT_USER = "your_user"
MQTT_PASS = "your_password"
MQTT_UID = "ws2811-1"

Explanation of Environment Variables:

  • NUM_LEDS: This variable sets the number of LEDs in your strip. It's essential to configure this correctly to ensure that the program knows how many LEDs it needs to control.
  • MQTT_BROKER: This is the IP address of your MQTT broker. The broker is responsible for managing the communication between the different parts of your system.
  • MQTT_PORT: The port on which the MQTT broker is running. The default MQTT port is 1883, but this might need to be changed if your setup uses a different configuration.
  • MQTT_USER: The username required to authenticate with the MQTT broker.
  • MQTT_PASS: The password for the given MQTT user. It's used alongside the username
  • MQTT_UID: A unique identifier for this particular WS2811 LED controller instance. This is used so the broker and corresponding systems know where messages should be routed.

Script arguments

usage: mqtt-leds [-h] [-v]

Control the LED strip with MQTT and API

options:
  -h, --help       show this help message and exit
  -v, --verbosity  increase output verbosity, each v adds a verbosity level, (ex: -vvv)

Running the script

if installed locally:

poetry run mqtt-leds

if installed as package

mqtt-leds

Troubleshooting

Make sure to have configured all env vars properly.

If you encounter issues, check the MQTT broker connection and ensure the LED strip is properly connected.

You can debug using the -v option to increase verbosity and get more detailed logs.

If the problem persists, you can also check homeassistant logs.

You can open an issue, I will be happy to look into it.

Contributing

Contributions are welcome! Please submit a pull request or file an issue for any enhancements.

License

mqtt-leds is licensed under the Apache License 2.0.

Support

For issues or questions, please open an issue in this repository.

Metadata

Release files for mqtt-leds-cli 1.0.0rc2

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-leds-cli 1.0.0rc2
File Size Uploaded
mqtt_leds_cli-1.0.0rc2.tar.gz 2.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mqtt-leds-cli 1.0.0rc2
File Interpreter ABI Platform
mqtt_leds_cli-1.0.0rc2-py3-none-any.whl Python 3 none any Details

Total release size: 6.5 kB

Release files / mqtt_leds_cli-1.0.0rc2.tar.gz

Download URL mqtt_leds_cli-1.0.0rc2.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2a080b4f91b590134f38cef475003cd7bf2ce953e71248eb051b53351cb1185a
BLAKE2b-256 checksum
How to use checksums
164ada1054ac7d4c2e0c1f1f3d2e5325fcc76107e82c9c41640cb69d0af3b6c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.10.18 Linux/6.17.11-200.fc42.x86_64

Release files / mqtt_leds_cli-1.0.0rc2-py3-none-any.whl

Download URL mqtt_leds_cli-1.0.0rc2-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5c222b20241393d4cdfe4a1de93e247b995a2e87be378fbe35e6d7020a8a67bd
BLAKE2b-256 checksum
How to use checksums
a0d176f23e6ef07e47c9b64b0feef6167bdbcfd0ab3ad02d1f15647c9834ac85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.10.18 Linux/6.17.11-200.fc42.x86_64

Release history Release notifications | RSS feed

This release

1.0.0rc2 This release

2 release files

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