Shelly1 and mqtt: problems, how to create a working switch


i’ve got th following Problem:
I want to switch on/off ma Shelly1-Device using the mqtt I have read many posts in th group and i have tryed many examples but they all missed my problem.

My workaround:
I use a MacMini Server 2011, openHAB 2.4, mosqitto from, both as service. I can use bindings in openHAB, i have integrates my Netatmo-Devices and i can switch on and off my shelly1-Device using mqtt.fx. I can read the status of the schell1-Device, if i switch it on or off ba using mqtt and i have used following configuration files:


Bridge mqtt:broker:mosquitto “Mosquitto” [ host=“localhost”, port=1883, secure=false, username=“XXXXX”, password=“XXXXX”, clientID=“openHAB2” ]
// shelly1
Thing topic shelly1 “shelly1” @ “Some Room” {
Type string : mode “Mode” [ stateTopic=“shellies/shelly1-500ECD/relay/0” ]
Type switch : power “Power” [ stateTopic=“shellies/shelly1-500ECD/relay/0”, commandTopic=“shellies/shelly1-500ECD/relay/0/command” ]


Group GF_shelly1
(GF_Kitchen, shelly1)

Switch GF_shelly1_Power
//mappings=[ON=on, OFF = off]
{ channel=“mqtt:topic:mosquitto:shelly1:power”}

String GF_shelly1_Mode
“Mode: %s”

{ channel=“mqtt:topic:mosquitto:shelly1:mode” }

The switch is reachable in the kitchen.
In the openhab.log i get the message:

2019-01-02 18:15:50.233 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘localhost’ with clientid openHAB2 and file store ‘/Applications/openhab-2-4/userdata/mqtt/localhost’
2019-01-02 18:15:50.240 [WARN ] [eneric.internal.generic.ChannelState] - Command ‘off’ not supported by type ‘OnOffValue’: No enum constant

Is there anbody with same problems or better with a solution for my problems?

thanks for answering


Had the very same issue doing the same you need to add some transformation to the thing item for on and off.

Thing topic StudyShelly1 "Shelly1" @ "Study" {
                Type switch : power "Power" [ stateTopic="shellies/shelly1-056DD7/relay/0", on="on", off="off", commandTopic="shellies/shelly1-056DD7/relay/0/command", on="on", off="off" ] 

Added my example above.


1 Like

Thank you for your help. Now it works fine. Do you integrate the shelliies/#/announce or the schellers/+++++/online topic?
They are only once as topic, because they are send only at startup of the shelly.



Glad to hear it, I haven’t as yet played with the new 1.4.3 MQTT features like announce but may do when I have some time.
If I do I will post an update.



Also in case your interested the following topic and utility is most useful for looking at the MQTT traffic, I just used it to see the announce message from one of my Shelly1’s which will help me creat a general announce item (hopefully)