OH2 using colorpicker with MQTT not publishing

I have seen many examples on how to do this but I cannot get a single one to work. In my log I can see the correct information has been set to a string but in my items the MQTT never publishes due to an error that make no sense. This is basically from one of the many examples I came across.

Group WIFI_RGB_2 "WiFi RGB 2" (All)
Color fWIFI_RGB_2 "RGB" <slider> (WIFI_RGB_2)
String WIFI_RGB_2_RGB (WIFI_RGB_2) {mqtt=">[broker:bruh/sensornode1/set:command:*:default]"}
var HSBType hsbValue
var int redValue
var int greenValue
var int blueValue
var String RGBvalues


rule "Set RGB 2 value"
 when
 Item fWIFI_RGB_2 changed
 then
 hsbValue = fWIFI_RGB_2.state as HSBType

 redValue = hsbValue.red.intValue
 greenValue = hsbValue.green.intValue
 blueValue = hsbValue.blue.intValue

 RGBvalues= "{state:ON,color:{r:"+redValue.toString + ",g:" + greenValue.toString + ",b:" + blueValue.toString +"}}"
postUpdate( WIFI_RGB_2_RGB, RGBvalues )

 logInfo( "fWIFI_RGB_2", RGBvalues )
end

The error in the log file is

org.eclipse.smarthome.model.item.BindingConfigParseException: Configuration 'broker:bruh/sensornode1/set:color:*:default' is not a valid outbound configuration: Invalid type.

Yet I know something is partially working because I also see the correct syntax in the log file which I am wanting to publish.

2017-06-15 00:14:17.161 [ItemStateChangedEvent     ] - WIFI_RGB_2_RGB changed from {state:ON,color:{r:51,g:19,b:15}} to {state:ON,color:{r:51,g:15,b:33}}

But if I open a terminal on the MQTT server the following works just fine.

pi@raspberrypi:~ $ mosquitto_pub -t "bruh/sensornode1/set" -m "{state:ON,color:{r:51,g:19,b:15}}"

Yes broker and mosquitto are set to one in the same and receiving information from the sensor via broker works just fine. I can only assume I am looking something obvious over. Hopefully once this is figured out it will help those too who either are transitioning from Home Assistant or using some of the Arduino sketches created to work with Home Assistant, which I fall into the later.

For what it’s worth I literally installed Home Assistant just to try out this one feature and it works so I know it’s not anything hardware wise.

There seems to be a difference in the mqtt config for your item and the log entry (set:command which is correct vs set:color which won’t work). For type you can only use command and/or state (Link)
Maybe there is another wrongly configured item in your system? (check with items list in the console)
Try restarting OH2 just in case to get rid of any stale items

Also: shouldn’t you be using: WIFI_RGB_2_RGB.sendCommand(RGBvalues) instead of postUpdate ?
I don’t remember if postUpdate will trigger the MQTT publish

Thanks so much. After all the examples I saw none of them used sendCommand which is what was wrong. Still learning and greatly appreciate your insight.

I was swapping back and forth command and color and did not realize that after I went back to using command the error message would disappear.

1 Like