Shelly Plus Plug S with MQTT

My Shelly Plus Plug S are operated via MQTT. Because the stateTopic and commandTopic are quite different, I can’t manage to assign them to just one item.
I hope someone has a better solution

Type switch : S_PlPl2_Status "Shelly + Plug 2 Status"   [ stateTopic="shellyplusplugs2/status/switch:0", transformationPattern="JSONPATH:$.output", on="true", off="false"]
Type switch : S_PlPl2_Switch "Shelly + Plug 2 Switch"   [ commandTopic="shellyplusplugs2/command/switch:0", on="on" , off="off"]

you can assign a separate stateTopic and command topic. These can be completely different, even on the same channel. Why do you think you can’t configure them both on the same Channel?

I had tried it, but it didn’t work.
My guess was that it was due to the double assignments of “on” and “off”.

What double assignment of on. and off? There is only one on and off parameter to use. It will translate “true” to ON for messages coming from the subscribe topic and it will convert ON to “true” in commands coming from the Item out to the command topic.

If you need more than that, you’ll need to use a command topic transformation to independently transform the Item commands to MQTT command topic messages.

I provide very limited support for .things files. It’s a time sink fighting syntax errors and researching options.

By double assignment I meant that the commandTopic must be on=“on” and off=“off”, but the stateTopic must be on=“true” and off=“false”.

In that case, use the command topic transformation for one and either the on/off properties for the state or add a state topic transformation for that. It can and should all be in the same channel, not split between two.

With these settings it works.


Type switch : S_PlPl3_Switch "Shelly + Plug 3 Switch" [ stateTopic="shellyplusplugs3/status/switch:0", transformationPattern="JSONPATH:$.output", on="true", off="false",
                                                        commandTopic="shellyplusplugs3/command/switch:0", transformationPatternOut=""]