OpenHAB keeps last read value. Not going to NULL

Hi All,

I’ve got a problem where I measure temperature, and humidity from Sonoff Dual R2, with an AM2301 connected to it.

It reads the values correctly, but when I remove power from Sonoff, OpenHAB retains the last recorder value, and doesn’t show NULL…?

I’m missing something somewhere.

Below is the things file & item config.
Please assist.

Tasmota11.things

        Channels:
                Type switch : power "Power Switch 11" [
                        commandTopic="cmnd/Tasmota11/POWER",
                        stateTopic="stat/Tasmota11/POWER",
                        on="ON",
                        off="OFF"
                ]
                Type switch : reachable "Reachable" [
                        stateTopic = "tele/Tasmota11/LWT",
                        on="Online",
                        off="Offline"
                ]
                Type number : temperature "Temperature" [
                        stateTopic="tele/Tasmota11/SENSOR",
                        transformationPattern="JSONPATH:$.AM2301.Temperature"
                ]
                Type number : humidity "Humidity" [
                        stateTopic="tele/Tasmota11/SENSOR",
                        transformationPattern="JSONPATH:$.AM2301.Humidity"
                ]
}

Items was created in UI.

    "class": "org.openhab.core.items.ManagedItemProvider$PersistedItem",
    "value": {
      "groupNames": [],
      "itemType": "Switch",
      "tags": [
        "Point"
      ],
      "label": "Reachable",
      "category": ""
    }
  },
  "Powerswitch1921680111_Temperature": {
    "class": "org.openhab.core.items.ManagedItemProvider$PersistedItem",
    "value": {
      "groupNames": [],
      "itemType": "Number:Temperature",
      "tags": [
        "Measurement",
        "Temperature"
      ],
      "label": "Temperature",
      "category": ""
    }

Thanks!!

That’s expected behavior and working as designed. OH is event based: if you’re device is going offline than no new event is coming in. The current item state will not change automatically without a new event from the device or a rule triggering an update.

If you want your item state to become null after certain time, you need to create a rule for this.

Btw: if you post thing / item definition, please use the code tags

A rule is not required, use expire instead.

2 Likes

Hi All.
Thanks for the feedback!
I’ll give the expire a go, and revert back.

Also, just some general help…
How do I “if you post thing / item definition, please use the code tags” ??

Thanks Rich!

Hi All,

Just want to confirm that the expire parameter works 100% as suggested by pacive above.

Seeing as my item is not textually defined, I was able to add expiration timer in the UI under add metadata tab in Items.

Thank you for the help!!

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.