MQTT Sonoff stuck in on/off loop


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:

//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

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


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