Power plug disconnected - how to?

Platform: Windows, OH: 4.2.2

Hello,

I have power plug (Gosung SP111), everything is fine. But when I physically unplugged from the outlet, then OH still showing old values of plug. LWT is correct - “offline” (like on the picture):

Above that, on the page it shows that the plug is on, even though on the list of things I see that it is offline.

I tried to reset the values (energy, current, volts) cyclically every 1 min if the plug is “offline”, but the “old” values are restored :frowning:

Why does this happen and how to properly handle such a case in OH? Should I change some settings for MQTT?

Yes. In the MQTT thing configuration should have availability topic and payload settings. If you fill these in then the MQTT binding knows to use that topic and those values to display the thing’s online/offline status.

Thank you for your answer. Can you write something more, because I don’t know how to do it :frowning: Can you give some example?

I have 2 ideas…
First: Just switch off the plug before unplug from outlet… The the values should changed to 0.
Second:
Set your widget to invisible if the plug is offline…

I think you can’t change the values if the thing is active.
I set a string item from a http binding channel per rule. But this is only possible if the thing is on pause (uninitialized)
Greets.

To hide the widget it is not solution, than I will not see that the plug is working or not.

I’m looking for some other native/natural solution.

Your plug is wifi? Try network binding and ping the device…

Greets

Edit:
But you see if the device is offline and you have a rule for it… What do you want to achieve? Just set values right?
then switch off before unplug the device… :wink:

Or like I said, turn thing off, set values, and turn thing on again.
I think this will work…

I got it! I think I can use “postUpdate” command - it works!

I don’t know if it’s in accordance with art and good manners of OH and that’s how it should be used, but it works, so I can define a rule that when the device is offline, then on items like voltage/current/power I have to do postUpdate.

So finally my rule looks like this:

configuration: {}
triggers:
  - id: "1"
    configuration:
      thingUID: mqtt:topic:d2e8e6744e:5238d7ee92
      status: OFFLINE
    type: core.ThingStatusChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: "4"
    configuration:
      itemName: PowerPlug01_PowerPlug01Amper
      state: "0"
    type: core.ItemStateUpdateAction
  - inputs: {}
    id: "5"
    configuration:
      itemName: PowerPlug01_PowerPlug01Power
      state: "0"
    type: core.ItemStateUpdateAction
  - inputs: {}
    id: "6"
    configuration:
      itemName: PowerPlug01_Voltage
      state: "0"
    type: core.ItemStateUpdateAction
  - inputs: {}
    id: "2"
    configuration:
      itemName: PowerPlug01_PowerPlug01OnOFF
      state: OFF
    type: core.ItemStateUpdateAction