MQTT feedback when power off

  1. My device works correctly
  2. I’m switch it to ON
  3. Then I remove device plug from electricity
  4. In OpenHab UI I see that it’s still in state ON
  5. When I’m try switch it to OFF, it returning to ON after refresh page (seems, it’s because I use autoupdate=false)

So, the question is: how to resolve this issue? How get more real update about device status?

As I understood, I have a possible solution: add additional logic with Network Health or something similar. But maybe MQTT already have something out of the box?

There is the “Last Will and Testament” (LWT) feature in MQTT to notify other clients about an ungracefully disconnected client.
The LWT message is defined by a client when the client connects to the broker. In case of an abnormally disconnect of the client, the broker will send the LWT to any subscriber of the LWT message topic.

Maybe you can set the LWT with your device.

@andreas_furrer68 good suggestion! But unfortunately ESP Easy firmware that I use with Sonoff don’t support it.