Integrate Shelly RGBW2 with MQTT in openHab

Can you add code fences to your post, please?

does anybody have an improvement on the op setup for adding functionability for rgbw strips?
he noted his setup didnt have the things/items and rules relating to the white channel?
just ordered a shelly rgbw so will be looking to setup soon :slight_smile:

@Taffy: Meanwhile is also a shelly Binding available. I think this should make life easier. I never tried because this is my only device with original shelly firmware.

I am not sure what to do. Wether to keep stock firmware and make your setup work for me. Use the Shelly binding or flash it with tasmota!

God evening @ all
I’m trying to use the shelly rgbw with the embedded broker created via GUI. Can anybody point my how to get the - transformationPattern=“JSONPATH:$.ison” in one line with - shellies/shellyrgbw2-xxxxxx/color/0/status in the definition of the generic MQTT Thing via GUI

Thanks in advance

Ok in the mean time I tryied to help my self. I managed to read the JSON Payload adding a channel to the generic MQTT Thing
I created an item:
`

String LGTV_RGBW_Status "Sideboardstatus [%s]" { channel="mqtt:topic:82734824:shelly_RGBW_status"[transformationPattern="JSONPATH:$.ison"] }

`
on the site map a can see the whole JSON string with:

Text item=LGTV_RGBW_Status

normaly it should only show the status of “ison” but it shows the whole string.
I also tried:

String LGTV_RGBW_IsOn "IsOn [%s]" { channel="mqtt:topic:82734824:shelly_RGBW_status"[profile="transform:JSONPATH", function="$.ison"]}

found in here: https://www.openhab.org/addons/transformations/jsonpath/
Unfortunately this also does not work.
When I switch on/off the shelly via its webinterface the log says that

LGTV_RGBW_Status

changes but

LGTV_RGBW_IsOn

does not appear in the log.

Please can anyone give me a hint what I’m doing wrong.

What openHAB version are you using?

Thank you for your reply. I’m using Version 2.4 on a Raspberry with raspbian.

Solved! Forgott to install the JSON Transformation via paperUI :roll_eyes:

@olialb Oliver A.

I red your publication codes for working with shellyrgbm2 and I reproduced it to my openHAB Version 3.3.

I can nearly get all of the settings displayed, but how can you (me) simply switch a light strip on or off via MQTT?

Thank you for answering and best regards. PJH

Hey @pjhaucke, wow its a while ago that I implemented that. Really nice that it still help someone.

I switch the lightstrip off by sending 0 to item Dimmer_WohnzimmerTisch.

The rule WohnzimmerTisch_DimEvent:

/* Shelly RGBW2 Dimmer update */
rule "WohnzimmerTisch_DimEvent"
when
	Item Dimmer_WohnzimmerTisch changed
then
	var jsonString = "{"
	val Number dimValue = Dimmer_WohnzimmerTisch.state as DecimalType;
	
	if (dimValue > 0)
			jsonString = jsonString + "\"turn\":" + "\"on\""
	else
			jsonString = jsonString + "\"turn\":" + "\"off\""
	

	jsonString = jsonString + ",\"red\":" + Red_WohnzimmerTisch.state.toString
	jsonString = jsonString + ",\"green\":" + Green_WohnzimmerTisch.state.toString
	jsonString = jsonString + ",\"blue\":" + Blue_WohnzimmerTisch.state.toString
	jsonString = jsonString + ",\"white\":" + White_WohnzimmerTisch.state.toString
	jsonString = jsonString + ",\"gain\":" + dimValue.toString
	jsonString = jsonString + ",\"effect\":" + Effect_WohnzimmerTisch.state.toString
	jsonString = jsonString + "}"
	sendCommand(Command_WohnzimmerTisch, jsonString)
end

is reacting on this change and does the conversion to a mqtt json command.

I hope that explains the idea!? For sure there are many other possibilities to implement this in another way.

Have a good weekend!