@erickk Awesome!! I’m glad my instructions and code worked for you!
For the group, just treat it as another set of items/sitemap/rules and a separate MQTT topic (i.e. ONE command to MANY strips). All of the strips that subscribe to that group’s MQTT topic will act on whatever command you send to it.
So, say you have ledstrip1 and ledstrip2, and you want to group them together (e.g. “group_kitchen”). You’d create two sets of the items/sitemap/rules entries above for the individual strips, PLUS a third set, for the group topic:
.items file:
String LEDStrip_Group1 "Group 1 LED Strips String" {mqtt=">[broker:home/group_kitchen/set:state:*:default]"}
Switch LEDStrip_Group1_Power "Group 1 LED Strips Power" (Status){mqtt=">[broker:home/group_kitchen/set:command:*:MAP(LEDStripEffectJSON.map)]"}
Number LEDStrip_Group1_FX "Group 1 LED Strips Fx" (Status){mqtt=">[broker:home/group_kitchen/set:command:*:MAP(LEDStripEffectJSON.map)]"}
Color LEDStrip_Group1_Color "Group 1 LED Strips Color" <rgb> (Status)
Number LEDStrip_Group1_Speed "Group 1 LED Strips Speed [%.0f]" (Status)
Number LEDStrip_Group1_Intensity "Group 1 LED Strips Intensity [%d]" (Status)
.sitemap:
Switch item=LEDStrip_Group1_Power
Selection item=LEDStrip_Group1_FX mappings=[1="BPM",2="Noise",3="Fire",4="Rainbow",5="Twinkle",6="Glitter",7="Solid",8="Sinelon",9="Juggle",10="Confetti",11="Dots",12="Lightning",13="Candy Cane",14="Cyclon Rainbow",15="Ripple",16="Christmas Alternate",17="Police All",18="Police One",19="Random Stars",20="Sine Hue"]
Colorpicker item=LEDStrip_Group1_Color
Setpoint item=LEDStrip_Group1_Speed minValue=5 maxValue=240 step=5
Setpoint item=LEDStrip_Group1_Intensity minValue=0 maxValue=255 step=16
.rules:
rule "LED Strip Group 1 (Kitchen) JSON Color"
when Item LEDStrip_Group1_Color received update
then LEDStrip_Group1.sendCommand("{\"color\": {" +
"\"r\": " + (LEDStrip_Group1_Color.state as HSBType).red + "," +
"\"g\": " + (LEDStrip_Group1_Color.state as HSBType).green + "," +
"\"b\": " + (LEDStrip_Group1_Color.state as HSBType).blue + "}}") end
rule "LED Strip Group 1 (Kitchen) JSON Speed"
when Item LEDStrip_Group1_Speed received update
then LEDStrip_Group1.sendCommand("{\"transition\": \"" + LEDStrip_Group1_Speed.state + "\"}") end
rule "LED Strip Group 1 (Kitchen) JSON Intensity"
when Item LEDStrip_Group1_Intensity received update
then LEDStrip_Group1.sendCommand("{\"brightness\":" + LEDStrip_Group1_Intensity.state + "}") end
If you don’t need to set single strips individually, you can get away with just the group topic/items/sitemap/rules.
The benefit of using a group topic to send commands is that the MQTT broker sets the topic once, and all strips immediately get the update, as opposed to individual updates, where the broker will set each strip’s topic one-by-one and there will be a delay before each strip gets an update. I was also noticing dropouts where some of my 10+ strips were not getting an update at all, leaving half the strips on one effect and the rest on another…).
Let me know if you have any issues getting this set up - I may do a special how-to video just on the group setup.
-BK