Tallman
(Tallman)
October 28, 2023, 5:22pm
1
How to turn a Shelly Plus Plug on and off via MQTT? It runs OH 3.4 and is configured via text files.
I receive the current status via:
Thing topic PlusPlug1 "PlusPlug1" {
Channels:
Type switch : S_PlPl1_Switch "Shelly + Plug 1 Switch" [ stateTopic="shellyplusplugs1/status/switch:0", transformationPattern="JSONPATH:$.output", on="true", off="false"]
}
Hat jemand eine funktionierende Konfiguration und kann sie mit mir teilen?
Wolfgang_S
(Wolfgang_S)
October 29, 2023, 12:26pm
2
The commandTopic is missing in your configuration.
Tallman
(Tallman)
October 29, 2023, 1:11pm
3
yes, because I don’t know what it should look like. Command isn’t sent over the same channel, is it?
hmerk
(Hans-Jörg Merk)
October 29, 2023, 1:21pm
4
You first have to make sure to have latest firmware on your plug, as there was a bug within mqtt. After that, just follow the config examples from Shelly.
Tallman
(Tallman)
October 29, 2023, 3:32pm
5
The Shelly is on firmware v1.0.3 and says it is the latest.
hmerk
(Hans-Jörg Merk)
October 29, 2023, 3:55pm
6
Ok then, please check the Shelly MQTT documentation what command needs to be send to what topic and configure the channel accordingly.
Tallman
(Tallman)
October 30, 2023, 4:19pm
7
According to the documentation that would be:
<topic_prefix>/command/<component:id>
I get the current switching status displayed, but I can’t switch myself via OH.
Type switch : S_PlPl1_Switch "Shelly + Plug 1 Switch" [ stateTopic="shellyplusplugs1/status/switch:0", commandTopic="shellyplusplugs1/command/switch:0", transformationPattern="JSONPATH:$.output", on="true", off="false"]
Tallman
(Tallman)
October 30, 2023, 7:03pm
8
The problem seems to be passing on status true and false. But for switching on and off is expected. How do you get everything working into a channel definition?
stateTopic="shellyplusplugs1/status/switch:0", transformationPattern="JSONPATH:$.output", on="true", off="false",
commandTopic="shellyplusplugs1/command/switch:0", transformationPatternOut="" , on="on", off="off"
Tokamak
(Marcus)
February 14, 2025, 7:04am
9
To complete this older thread…
I have found the following solution today. One needs to define two channels
Type switch: switchState [ stateTopic= "<topic>/status/switch:0", transformationPattern= "JSONPATH:$.output", on= "true", off= "false" ]
Type switch: switchCommand [ commandTopic= "<topic>/command/switch:0", on= "on", off= "off" ]
and bind both channels to one item
Switch ShellyPlug { channel= "mqtt:topic:shellyplug:switchCommand", channel= "mqtt:topic:shellyplug:switchState" }