MQTT Tasmota state not update item


I’m using OH3 and Mosquitto MQTT v3.1 as my broker.
Everything seems to work fine but I doesn’t seem to figure out what is going wrong with the below thing and item.

So I use an Shelly Plug S which is flashed with Tasmota, the correct template is used for this plug, I’m able to switch the socket on and off. Configured the MQTT parameters and created the following thing:


Bridge mqtt:broker:mosquitto [ host="192.168.x.x", secure=false ] {
Thing topic ShellyStekker1 "ShellyStekker1" @ "Code" {
    Type switch : power             "Power"         [stateTopic="stat/ShellyStekker1/POWER",   commandTopic="cmnd/ShellyStekker1/POWER", on="ON", off="OFF"]

And this Item:

//Shelly plug switch
Switch ShellyStekker1_Switch      "ShellyStekker1" ["Switchable"] {channel="mqtt:topic:mosquitto:ShellyStekker1:power", homekit="Lighting", autoupdate="true"}

I got this config from the Tasmota GitHub page for Openhab: openHAB - Tasmota

Now I’m able to switch the switch on and off by command/item, but when I change the state on the Tasmota GUI the item don’t get updated and will retain the previous state.

When I connect to the MQTT Broker using MQTT Explorer and switch plug on the web GUI I see that stat/ShellyStekker1/POWER is changing from ON to OFF and the other way around. So I assume the the thing also reads this update but doesn’t change the item for some reason.

Any thoughts why this is happening?

I suggest setting autoupdate to false. I turn it off for almost all of my switches, and it might be causing some confusion.

I also don’t think your thing definition needs the on/off states. I don’t have these in any of my Tasmota switches and they work fine:

, on="ON", off="OFF"

Just a guess but you might need your mosquitto username and password in your bridge details?

Bridge mqtt:broker:mosquitto "mosquitto" @ "MQTT" [ host="*********", port=1883, secure=false, retain=false, username="**********", password="*********", qos=0, keep_alive_time=30000, reconnect_time=60000 ]

I always use something like MQTT.fx to test my code first. If your devices show up on there then you know it’s working.

I tried both changes, so I set autoupdate to false and removed on=“ON”, off=“OFF” but unfortunately the state still don’t change when I toggle the switch on the Tasmota GUI.

Do you know what to set if you don’t use an username and password, can I just leave them blank?

Yea the strange thing is, I test with the tool MQTT Explorer, when I toggle the switch on the Tasmota GUI, I see that there is an update on stat/ShellyStekker1/POWER, just like I set my Thing, but openhab doesn’t seem to change the state of the linked item…

This would suggest it’s a configuration problem in openHAB. Maybe try configuring your connection via the UI? Make sure to remove your old Things and Items first.

This may or may not help.

Mosquitto v2 doesn’t let you do that by default, so be sure you have set that up to work without.

But if that means controlling the device from openHAB, then your broker set up is fine.

And what is the payload of that message?

I don’t see anything wrong with your channel set up, but if you have edited your xxx.things file, the binding is rubbish about picking upin-flight changes. Restart binding or openHAB after editing to your best effort.

Nothing jumps out at me as an explanation for the problems you are having.

I use the UI to set up my Tasmota devices in openHAB 3.x, and it has worked well for me. First create a GenericMQTT Thing in the UI, then set up the channels. I usually set up 2 channels, one that gets the state with stat/tasmota-frontporch-switch/POWER and sends commands with cmnd/tasmota-frontporch-switch/POWER. The other channel gets the state from tele tele/tasmota-frontporch-switch/STATE. Both channels are linked to the same item, so get normal updates when the switch state changes, plus updates for cases such as on a reboot, where the state of the item is NULL.

1 Like

That’s why something like MQTT.fx is handy to check your configs. If it’s working in that then there might be an issue elsewhere.

Ok, really strange… so after this changes it didn’t worked right away when I tested it. So I didn’t change anything else afterwards till today, I changes the thing to:


Bridge mqtt:broker:mosquitto [ host="192.168.x.x", secure=false ] {
Thing topic ShellyStekker1 "ShellyStekker1" @ "Code" {
    Type switch : PowerSwitch             "Power"         [stateTopic="stat/ShellyStekker1/POWER",   commandTopic="cmnd/ShellyStekker1/POWER", on="ON", off="OFF"]

Originally I had “Type switch : power” and changed it to “Type switch : PowerSwitch”, and of course updated the item as well, I tested it again and still not working so I changed it back to “Type switch : power” like I had before and now all of as sudden it started working like it should be.
I really don’t understand why, but now when I toggle the switch on the Tasmota GUI, the item in Openhab also get updated to the new state :slight_smile:

Don’t want to change anything on this thing or item now it is working, I also added another 2 Shelly plugs the same way like I described now, they also work like it should be.

Just run into the same issue and think that this is exactly what I want for my Tasmota power outlets. Since I didn’t fully understand what you wrote, I tried it out myself and have now an example config, which may be useful for someone else:


Thing topic sonoff1 "Sonoff1" @ "Schlafzimmer" {
        Type switch : PowerSwitch [ stateTopic="sonoff1/stat/POWER", commandTopic="sonoff1/cmnd/POWER" ]
        Type switch : PowerState  [ stateTopic="sonoff1/tele/STATE", transformationPattern="JSONPATH:$.POWER" ]

And the items file referring this thing:

Switch Tischlampe "Tischlampe" <light> {channel="mqtt:topic:luv:sonoff1:PowerSwitch", channel="mqtt:topic:luv:sonoff1:PowerState"}