Hi
Following Bartus excellent how-to I have successfully gotten my LED strip to work with Openhab over MQTT. But, there’s something wrong (or unconfigured) that won’t have my items properly reflect the LED status. I’m on 2.4.0 stable and use MQTT binding v2.
I have been able to successfully get the items to update properly when setting up only one test/dummy item/reference for a channel, but with the LED strip, I’m passing a JSON string back and forth, not just one item status. I don’t know how to configure my things or items to get this properly set up. Any assistance will be appreciated. I’ve searched through the forum and some references to the Paper UI channel setup are made, but I don’t know how to do this.
A string looks like this:
{"state":"ON","color":{"r":255,"g":255,"b":255},"brightness":64,"effect":"noise","transition":30}
I have set up my MQTT broker and generic Thing through Paper UI, but I’m using .items files for my items.
Currently, I have only one channel in use for the LED strip and it’s holding both send/receive
/FrontXmasLights/state
/FrontXmasLights/command
My items file look like this:
String FrontXmasLights "Christmas Lights Front" {channel="mqtt:topic:MQTTgeneric:FrontXmasLights"}
Switch FrontXmasLights_Power "ON/OFF"
Number FrontXmasLights_FX "FX"
Color FrontXmasLights_Color "Color" <rgb>
Number FrontXmasLights_Speed "Speed [%.0f]"
Number FrontXmasLights_Intensity "Brightness [%d]"
Sending commands to the strip is done through rules
//FrontXmasLights_Power
rule "Front Xmas Lights ON/OFF change"
when Item FrontXmasLights_Power received update
then FrontXmasLights.sendCommand("{\"state\":" + FrontXmasLights_Power.state + "}") end
//FrontXmasLights_FX
rule "Front Xmas Lights effect change"
when Item FrontXmasLights_FX received update
then FrontXmasLights.sendCommand("{\"effect\":" + transform("MAP","LEDStripEffectJSON.map",FrontXmasLights_FX.state.toString) + "}") end
//FrontXmasLights_Color
rule "Front Xmas Lights color change"
when Item FrontXmasLights_Color received update
then FrontXmasLights.sendCommand("{\"color\": {" +
"\"r\": " + (FrontXmasLights_Color.state as HSBType).red + "," +
"\"g\": " + (FrontXmasLights_Color.state as HSBType).green + "," +
"\"b\": " + (FrontXmasLights_Color.state as HSBType).blue + "}}") end
//FrontXmasLights_Speed
rule "Front Xmas Lights speed change"
when Item FrontXmasLights_Speed received update
then FrontXmasLights.sendCommand("{\"transition\": \"" + FrontXmasLights_Speed.state + "\"}") end
//FrontXmasLights_Intensity
rule "Front Xmas Lights brightness change"
when Item FrontXmasLights_Intensity received update
then FrontXmasLights.sendCommand("{\"brightness\":" + FrontXmasLights_Intensity.state + "}") end
Any help on how I can get my Openhab items to update properly based on the MQTT message would be appreciated.