[SOLVED] Shelly 1 mqtt works oneway

(Gary Clarke) #1

I am using the shelly 1 native mqtt service, when i send on or off from openhab it works and the icon on my panel changes with it, but if i turn the shelly on or off via the attached light switch it does not get update on openhab, i can see the mqtt messages sent to the mqtt server when pressing the light switch.
shellies/shelly1-3288D6/relay/0 on
shellies/shelly1-3288D6/relay/0 off

this is my item.
//Shelly Units
Switch Shelly_1 “Shelly 1” [“Switchable”] {mqtt=">[broker:shellies/shelly1-3288D6/relay/0/command:command:on:on],>[broker:shellies/shelly1-3288D6/relay/0/command:command:off:off],<[broker:shellies/shelly1-3288D6/relay/0:state:default]"}

not sure what i have wrong on the inbound <[broker:shellies/shelly1-3288D6/relay/0:state:default]

(Richard) #2

Hello Gary,

for a Shelly 1 device with 6.3.0 Tasmota Firmware running, this is my working item in OpenHAB:

Switch Light "small Light" { mqtt=">[mqttbroker:test/switch/cmnd/Flur_Treppenlicht/POWER:command:*:default], <[mqttbroker:test/switch/stat/Flur_Treppenlicht/POWER:state:default]" }

the Shelly has these MQTT settings:


Are you using the HomeKit Binding?


(Gary Clarke) #3

Hi Richard

I am NOT using Tasmota I’m using the new Shelly firmware that has mqtt included.

Thanks for the reply.

(Vincent Regaud) #4

According to the Sheely website your topic is correct.
You need a MAP transform to change on to ON and off to OFF

Create a shelliesonoff.map file in the transform folder with the following content:


Your item:

Switch Shelly_1 "Shelly 1" [ "Switchable" ] { mqtt=">[broker:shellies/shelly1-3288D6/relay/0/command:command:*:MAP(shelliesonoff.map)],<[broker:shellies/shelly1-3288D6/relay/0:state:MAP(shelliesonoff.map)]" }

(Gary Clarke) #5

when I set it that way nothing works, I see mqtt traffic but device does not react.

shellies/shelly1-3288D6/relay/0/command MAP(shelliesonoff.map)
shellies/shelly1-3288D6/relay/0/command MAP(shelliesonoff.map)

(Vincent Regaud) #6

You may need to install the MAP transformation in the paperUI

(Gary Clarke) #7

Thank you both, I had not used MAP before so yes it was needed to be installed in paper UI, also I changed the map file and it worked, I love these little units fits in the electrical box and no need to flash tasmota.


(Elenio) #8

Please, which is the THING I have to specify with the Shelly?
I will configure it as a Switch

(CM6.5 H102) #9

Are you using mqtt binding version 2.4 or 1.x?

(Elenio) #10

just installed 2.4
(thank you)

(Kristof Rado) #11

If you are using MQTT Binding 2.4, you don’t even need to have a MAP transform. You can define specific ON/OFF values for the Switch item type in the channel configuration.

(Elenio) #12

can I ask to show me an example
IJust defined the broker thing in file as follow

mqtt:broker:myBroker [ host="192.168.xx.xx", secure=false ]

but I’m stucked as I don’t understand how to create the needed channels type in config files

(Kristof Rado) #13

I have configured my through PaperUI, but it should work from files as well. Please use the provided example from the docs:

Bridge mqtt:broker:myUnsecureBroker [ host="", secure=false ]
    Thing topic mything {
        Type switch : lamp "Kitchen Lamp" [ stateTopic="lamp/enabled", commandTopic="lamp/enabled/set" ]
        Type switch : fancylamp "Fancy Lamp" [ stateTopic="fancy/lamp/state", commandTopic="fancy/lamp/command", on="i-am-on", off="i-am-off" ]
        Type string : alarmpanel "Alarm system" [ stateTopic="alarm/panel/state", commandTopic="alarm/panel/set", allowedStates="ARMED_HOME,ARMED_AWAY,UNARMED" ]
        Type color : lampcolor "Kitchen Lamp color" [ stateTopic="lamp/color", commandTopic="lamp/color/set", rgb=true ]
        Type dimmer : blind "Blind" [ stateTopic="blind/state", commandTopic="blind/set", min=0, max=5, step=1 ]

So the Bridge connects to your MQTT Broker, and you add Things to this bridge, which should be your MQTT devices. Channels should be the used topics in that device.

Type switch : fancylamp "Fancy Lamp" [ stateTopic="fancy/lamp/state", commandTopic="fancy/lamp/command", on="i-am-on", off="i-am-off" ]

As you can see, this is how you can add specific on off values to a switch item.

You will need on=“on”, off=“off” for Shelly devices

(Mikaël) #14

Can you post a screenshot of how you configure the transformation in the channel through paperUI ?
I can’t seem to find the right syntax.


(Vincent Regaud) #15

What transformation you want to use?

Syntax is here: https://www.openhab.org/addons/bindings/mqtt.generic/#incoming-value-transformation
Don’t use the quotes

(Kristof Rado) #16


@vzorglub this can be a confusing I think. This is not really a transformation, it is a ‘function’ of the binding.

This is how mine looks like

MQTT : Same command message in event log every 30 seconds
(Mikaël) #17

Thanks, it works with your configuration !

(Mikaël) #18

Thanks !
I was looking how to use “incoming value transformation”, but it turned out to easier by just entering on/open and off/closed values.

(Kristof Rado) #19

I’m glad! Hope that soon Shelly add more MQTT topics to each device (like RSSI and other things).

(Steve Janzen) #20

Hi I have the same configuration but I cant get my shelly to switch… Am I missing something. Please help :wink: