So I have a custom piece of software/hardware to drive a led strip (ws2812) via mqtt (esp, homie, etc). Its fairly simple for the most part but i’ve added the ability to control parts of the led strip individually and have been trying to making homie know how to use it appropriately to no avail so far.
Driving the led strip as a single entity is easy enough:
light:
- platform: mqtt
name: “esplight”
command_topic: “devices/dev1/switch/switch/set”
rgb_command_topic: “devices/dev1/led/color/set”
rgb_value_template: “value.rgb|join(‘,’)”
brightness_state_topic: “devices/dev1/brightness/brightness/set”
brightness_command_topic: “devices/dev1/brightness/brightness/set”
qos: 0
payload_on: “on”
payload_off: “off”
optimistic: false
state_topic: “devices/dev1/switch/status”
But I also want to divide the led strip into an arbitrary number of lights as sections. From the MQTT perspective, sending something like “0,20,on” turns on leds 0-20 but just sending “on” turns on all leds. I like to be able to keep it so that I dont have to flash the ESP when changing how the sections split up. So for example I might have “lounge light” for the entrie strip and “loung light 1”, “lounge light 2”, which are hard coded sections in home assistant and i just change the prefix on the message if i wanted to change the number of leds in each light. They all use the same MQTT topics and to control a section, prefixing it with start,end (0,20) for eg controls that section.
Sending the commands is actually quite easy enough. Interpreting the status that the ESP light responds with is proving very trick though. If i set the colour of the entire strip to 255,128,64 for eg, it reports “255,128,64” on the status topic, but setting 0-20 to 255,128,64 reports “0,20,255,128,64” on the same topic (not easy to deal with from a homie perspective).
Before i start coding a custom control i was wondering if anyone has any insights on how It might be achieved? (it’d be nice to see “lounge light 1,2,3,etc” be a sub-set of “lounge light” in the actual gui similar to what happens when you group lights, but not necessary).
As its my own code on the ESP, changing what it reports on MQTT on its status topic is possible, but I dont want to have to change which topics im using.