Skip to main content

MQTT control of OpenWRT LEDs with optional Home Assistant Discovery

Project description

MQTTLED

This package allows control of an OpenWRT device's LEDs over MQTT. Configured using UCI or YAML. No changes are made to the existing triggers. Uninstalling will revert to your normal LED triggers.

Config

Normal configuration is done through UCI. The configuration file is:

/etc/config/mqttled

The default configuration looks like this:

config mqtt 'mqtt'
    #MQTT Broker Address
    option host '192.168.1.1'
    option port '1883'
    #May work without this, should bind to all interfaces. Needs to be an interface matching in /etc/config/netowkr
    option interface 'lan'
    option username ''
    option password ''
    #Not tested
    option tls '0'
    option cert ''
    option discovery 'homeassistant'
    #Set your topic here: e.g. OpenWRTleds/CustomDevice/led1
    option basetopic 'OpenWRTleds'
    option subtopic 'CustomDevice'
    #Reported in the 'device' page in Home Assistant
    option model 'OpenWRT Device'

config leds 'leds'
    #Setting this to 1 will ignore any includes
    option includeall '1'
    #excluded LEDs will allways be supressed
    list exclude 'mt76-phy0'
    list exclude 'rt2800soc-phy1::assoc'
    list exclude 'rt2800soc-phy1::quality'
    list exclude 'rt2800soc-phy1::radio'
    #list include 'blue:internet'

config trigger 'triggers'
    #Only triggers listed here will be presented to HA as 'effects'
    list triggers 'none'
    list triggers 'default-on'
    list triggers 'heartbeat'
    list triggers 'timer'

Changes should be made either with UCI e.g.

uci set mqttled.mqtt.host='192.168.1.254'
uci commit

or by editing the config file directly. You will then need to restart the service with

service mqttled restart

Info

Topics

This service will publish a retained message to the discoverytopic/light on start. This will point Homeassistant to the state and availability topics of your device set under basetopic/subtopic. The current state is reported on basetopic/subtopic/ledname/state. The daemon is subscribed to basetopic/subtopic/ledname/set for commands.

Attirbutes

The mqttled service will expose the LEDs as dimmable using the value set under /sys/class/leds/led#/brightness. This doesn't seem to work on any of the devices I've tested, but perhaps some devices have working PWM on the LEDs

Local Changes

Changes made to LED state on the device are not polled. i.e. any changes you make to the LED states by any other means will not be reflected unless the service is restarted.

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

mqttled-0.1.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

mqttled-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file mqttled-0.1.0.tar.gz.

File metadata

  • Download URL: mqttled-0.1.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for mqttled-0.1.0.tar.gz
Algorithm Hash digest
SHA256 20f46b7114b6ddace6e0faaaa078640f609c3d495e4ccff8d8caeb77ac5418f7
MD5 93c62fb491e9a983aa7ce3053a84b0c6
BLAKE2b-256 5600dcd097e00299ae90dd69fba3f4a657b5db1f2d9472838af36f0ec1bc69e9

See more details on using hashes here.

File details

Details for the file mqttled-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mqttled-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for mqttled-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ee773fb15bd15f9282bc08ac3561df641bb316530384b7bc4a09bb722be804b
MD5 430d86bb8374d3a146757d387f2303e6
BLAKE2b-256 ec280ed0aa5752210d4d0b2d4c8c5e115de7964a21a13aec8a20bf1a10e51de7

See more details on using hashes here.

Supported by

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