[SOLVED] Shelly 1 mqtt works oneway

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]

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:

grafik

Are you using the HomeKit Binding?

:slight_smile:

Hi Richard

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

Thanks for the reply.

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:

on=ON
off=OFF
ON=off
OFF=on

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)]" }

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)

You may need to install the MAP transformation in the paperUI

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.

on=ON
off=OFF
ON=on
OFF=off

1 Like

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

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

1 Like

just installed 2.4
(thank you)

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.

1 Like

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

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="192.168.0.42", secure=false ]
{
    Thing topic mything {
    Channels:
        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

1 Like

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.

Thanks

What transformation you want to use?

Syntax is here: MQTT Things and Channels - Bindings | openHAB
Don’t use the quotes

Sure.

@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

Thanks, it works with your configuration !

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.

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

1 Like

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