Output last update of HTTP binding in UI

  • Platform information:
    • Hardware: Raspberry Pi2
    • OS: Raspbian GNU/Linux 7
    • Java Java™ SE Runtime Environment (build 1.8.0-b132)
    • openHAB version: 2.2.0

I have integrated an ESP8266 with attached reed relay into my local Wifi network. It reports the state of the reed relay via a local running WebServer on port 80. I can access this web service via a browser on my desktop machine on http://192.168.178.49/status.

Now I have configured a service:
reed.url=http://192.168.178.49/status
reed.updateInterval=5000

Additionally I have configured an item:
String reeditem { http="<[reed:10000:JSONPATH($.state)]" }

Beyond that I have integrated it into my sitemap:
sitemap my label=“ASitemap” {
Frame label=“Fensterkontakte” {
Text item=reeditem label=“Fenster Bad Dach [%s]”
}
}

This works well, as long as my ESP8266 is running. When I turn off its power, the Basic UI still reports the old state. It does not get updated for hours. I don’t see any error that the web service of the ESP8266 is no longer running nor do I see a timestamp that reports the last update of the HTTP binding. Hence, as a user I cannot say that something is wrong, as the openHAB UI makes me think the reed relay is still closed. :frowning:

Therefore my question: Is it possible to output in the UI (Basic UI/Android app) the timestamp of the last update the openHAB server received from the ESP8266 or an error message if a number of polls failed?

Thanks in advance.

Best Regards
Martin Mois

You can - if you either use persistance (<item>.lastUpdate) or you add an proxy item, which gets the timestamp whenever the item value changes.

another thing: is there a reason for your ESP8266 to run a webserver, which you have to poll?
Why not using MQTT to send your states if changing from the ESP8266: you can then:

  • tell the ESP8266 to send the state cyclical (every 10mins or so?)
  • check via MQTT the state (the ESP8266 responds with an actual state message)
  • define the item, which subscribes to the topic with expire with an defined delay (say 15mins?)
    if the item goes to “UNDEF” (or what you define via expire binding), you can have an alert saying your reed contact is down
  • plus: you get immediate Response from the reed and not only every 5secs (which also slightly reduces newtwork load)

just my 2cent.