MQTT Sonoff stuck in on/off loop

Hi

I’m trying to get sonoff working with OH2, I have setup Tosmota and Mosquitto, I can use MQTTLens to turn the sonoff on and off with no issues.

I have now tried to setup OH2 which does send commands to the sonoff but it gets stuck when I press button it starts turning on and off rapidly as though stuck in a loop.

My MQTT.cfg has:
mqtt.url=tcp://192.168.178.42:1883
mqtt.clientId=openhab2

Items:
//Sonoff Basic / Sonoff S20 Smart Socket
Switch LivingLight “Living Room Light” (LR,gLight)
{ mqtt=">[mqtt:cmnd/sonoff/power:command:*:default],<[mqtt:stat/sonoff/POWER:command:default]" }

and log of some debug information from OH http://txt.do/d96mw

Does anyone have an idea what I’ve done wrong?

Thanks

You have created a loop with the command :slight_smile:

When requesting incoming status from mqtt, use the status (not the command):

Switch LivingLight "Living Room Light" (LR,gLight)
{ mqtt=">[mqtt:cmnd/sonoff/POWER:command:*:default],<[mqtt:stat/sonoff/POWER:state:default]" }
1 Like

Thank you! Something so simple :slight_smile:

1 Like

This helped me as well. Thanks @Dim !

1 Like