RGB MQTT Help to create items and sitemap

I was reading your program and I see that is the led strip WS2811…

I have the normal strip if 12V in, R, G ,B.

Its possible to changed it? Change the head of the program to works if my strip?

Ah, that will definitely be a problem - the code I’m using has single-LED effects, so it needs a strip with addressable RGB LEDs (like WS2811, WS2812, APA102, etc…). Your PCB only allows control of full-string LED strings that take separate R, G and B voltages to set a color for all of the LEDs. What you need to do is get a WS2811 or similar strip, and connect the data pin to one of your channels (12, 13 or 14). Then, you just need to set the right number in the “#define DATA_PIN 5” line (change 5 to whatever pin you’re connecting to. For now, you won’t be able to use this code with your strip, I’m sorry!

I really wondered, I really want to thank you for your attention and patience! I want to wish you a Merry Christmas and a Happy New Year!

Thanks a lot!!!

No problem, glad to help, just keep learning/improving (that’s what I try to do). Merry Christmas and a Happy New Year to you and your family!!

Bartus, I buy the strip, but i’ts possible to biuld the command board without Bi-Directional Module?

Hi Bartus,

I followed your steps and almost everything works perfectly apart from changing colors. I bought all the parts as suggested by BruhAutomation and it worked correctly in Home Assistant so it should work in OpenHAB, too. When I try to change a color I get this error:

2018-02-15 11:36:17.369 [WARN ] [rthome.model.script.actions.BusEvent] - Cannot convert '{"color": {"r": 100,"g": 18.00,"b": 26.200000000000}}' to a command type which item 'Cab
inet1' accepts: [OnOffType, RefreshType].

Any idea what’s the problem?

Cheers,
Slaw

@slaw425 Just for completeness, as in the other topic, I’m linking the how-to post with my latest configuration here: NodeMCU MQTT LED Strip Controller Build & Config How-To Videos

Thanks, man. It’s very useful. What’s strange it works correctly for the other led strip that I have - exactly the same configuration and hardware.

Can you post your items/sitemap/rules for those two strips? I’m sure it’s just a small typo/paste error, nothing major…

Here it is:

Items:

String Cabinet1 "Left Cabinet String" {mqtt=">[broker:kitchen/cabinet1/set:state:*:default]"}
Switch Cabinet1_Power "Left Cabinet Power" (Status) [ "Switchable" ] {mqtt=">[broker:kitchen/cabinet1/set:command:*:MAP(LEDStripEffectJSON.map)]"}
Number Cabinet1_FX "Left Cabinet Fx" (Status){mqtt=">[broker:kitchen/cabinet1/set:command:*:MAP(LEDStripEffectJSON.map)]"}
Color Cabinet1_Color "Left Cabinet Color"       <rgb>   (Status)
Number Cabinet1_Speed "Left Cabinet Speed [%.0f]"               (Status)
Number Cabinet1_Intensity "Left Cabinet Intensity [%d]" (Status)

String Cabinet2 "Right Cabinet String" {mqtt=">[broker:kitchen/cabinet2/set:state:*:default]"}
Switch Cabinet2_Power "Right Cabinet Power" (Status) [ "Switchable" ] {mqtt=">[broker:kitchen/cabinet2/set:command:*:MAP(LEDStripEffectJSON.map)]"}
Number Cabinet2_FX "Right Cabinet Fx" (Status){mqtt=">[broker:kitchen/cabinet2/set:command:*:MAP(LEDStripEffectJSON.map)]"}
Color Cabinet2_Color "Right Cabinet Color"       <rgb>   (Status)
Number Cabinet2_Speed "Right Cabinet Speed [%.0f]"               (Status)
Number Cabinet2_Intensity "Right Cabinet Intensity [%d]" (Status)

Sitemap:

        Text label="Kitchen Lights" icon="light" {
                Switch item=hue_0100_0017880ac764_9_brightness label="Left light"
                Switch item=hue_0100_0017880ac764_8_brightness label="Right light"
                Switch item=Cabinet1_Power label="Left Cabinet"
                Switch item=Cabinet2_Power label="Right Cabinet"
                Selection item=Cabinet1_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"] label="Left Cabinet Effect" // visibility=[MonoPrice_Z4_PWR==ON] icon="receiver"
                Selection item=Cabinet2_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"] label="Right Cabinet Effect" // visibility=[MonoPrice_Z4_PWR==ON] icon="receiver"
                Colorpicker item=Cabinet1_Color label="Left Cabinet Color"
                Colorpicker item=Cabinet2_Color label="Right Cabinet Color"

Rules:

rule "Left Cabinet Color"
when
  Item Cabinet1_Color received update
then
  Cabinet1.sendCommand("{\"color\": {" +
    "\"r\": " + (Cabinet1_Color.state as HSBType).red + "," +
    "\"g\": " + (Cabinet1_Color.state as HSBType).green + "," +
    "\"b\": " + (Cabinet1_Color.state as HSBType).blue + "}}")
end

rule "Left Cabinet Speed"
when
  Item Cabinet1_Speed received update
then
  Cabinet1.sendCommand("{\"transition\": \"" + Cabinet1_Speed.state + "\"}")
end

rule "Left Cabinet Intensity"
when
  Item Cabinet1_Intensity received update
then
  Cabinet1.sendCommand("{\"brightness\":" + Cabinet1_Intensity.state + "}")
end

rule "Right Cabinet Color"
when
  Item Cabinet2_Color received update
then
  Cabinet2.sendCommand("{\"color\": {" +
    "\"r\": " + (Cabinet2_Color.state as HSBType).red + "," +
    "\"g\": " + (Cabinet2_Color.state as HSBType).green + "," +
    "\"b\": " + (Cabinet2_Color.state as HSBType).blue + "}}")
end

rule "Right Cabinet Speed"
when
  Item Cabinet2_Speed received update
then
  Cabinet2.sendCommand("{\"transition\": \"" + Cabinet2_Speed.state + "\"}")
end

rule "Right Cabinet Intensity"
when
  Item Cabinet2_Intensity received update
then
  Cabinet2.sendCommand("{\"brightness\":" + Cabinet2_Intensity.state + "}")
end

Well, that’s bizarre…I see no problems at all with your code or configuration. The only thing I can think of is maybe some of the items got created incorrectly/doubled up when you were typing the configs in? I.e. have you restarted your OH instance, or cleared the cache since putting these in?

I’ve just restarted OH and turned off and on the NodeMCU, now I don’t get the error message, the OH reports that color has changed but nothing happens:

2018-02-15 16:49:23.715 [ome.event.ItemCommandEvent] - Item 'Cabinet1_Color' received command 284,48,100
2018-02-15 16:49:23.733 [vent.ItemStateChangedEvent] - Cabinet1_Color changed from 21,68,100 to 284,48,100
2018-02-15 16:49:23.784 [ome.event.ItemCommandEvent] - Item 'Cabinet1' received command {"color": {"r": 87.199999998400,"g": 52.00,"b": 100}}
2018-02-15 16:49:23.810 [vent.ItemStateChangedEvent] - Cabinet1 changed from {"color": {"r": 100,"g": 55.800000000000,"b": 32.00}} to {"color": {"r": 87.199999998400,"g": 52.00,
"b": 100}}

Did the first LED (on the strip, not the NodeMCU) light up when you restarted the NodeMCU? It should turn on as soon as you apply power to the NodeMCU, then turn off after about 10 seconds. This means that it’s connected to your Wifi/MQTT broker.

Do you have MQTT.fx or another troubleshooting tool? You could subscribe to the status topic for the NodeMCU, and make sure its status message is changing when you send new commands.

It’s connected to the broker, I can turn it on and off, all the effects ‘police all’, ‘solid’ etc. work the only problem is color changing. I’ll check MQTT.fx.

Hm, I’m interested in what you see as far as status changing from the strip when you send commands - has to be something simple…

It’s weird, when I power it on:

kitchen/cabinet1/set {"state":"ON"}
kitchen/cabinet1 {"state":"ON","color":{"r":255,"g":255,"b":255},"brightness":255,"effect":"solid"}

Nothing is being sent when I change the color.

When I repeat the same exercise with the other strip:
-power on:

kitchen/cabinet2/set {"state":"ON"}
kitchen/cabinet2 {"state":"ON","color":{"r":97,"g":100,"b":97},"brightness":255,"effect":"solid"}

-color change:

kitchen/cabinet2/set {"color": {"r": 100,"g": 22.00,"b": 36.299999997400}}
kitchen/cabinet2 {"state":"ON","color":{"r":100,"g":22,"b":36},"brightness":255,"effect":"solid"}

Are you still able to run multiple ON/OFF commands on cabinet 1 after the first one?

Is cabinet 1’s strip longer than 2’s? Are you using the same power supply?

What I’ve noticed with some of my longer strips is that if I don’t run a high enough power supply, the draw of the strip can drop the voltage to the NodeMCU low enough where it just hangs - it’ll still be lit but won’t respond to any commands. The fact your brightness is set to 255 (full power) and the initial color is white means the strip goes directly into a full-power state.

Try setting the color first (before turning the strip on) with brightness at 64 or so, and see if it turns ON into the proper color, and if it starts responding to further color changes.

It works now, I rebooted my pi3. Thanks a lot for your time and help! I do appreciate it.

Ha, weird! Nothing like a little Raytheon Reset to fix a nagging problem :slight_smile:

Glad it’s working, and glad to help!

Hi! How i can create ITEM for RGB led. Every led controlled via separate mqtt topic.
Red is mosquitto/bar_node/pwm0, green is mosquitto/bar_node/pwm1, blue is mosquitto/bar_node/pwm2