If openHAB has a Persistence service configured, the time of the last Item update (and a couple other times) is available in Rules. This makes it quite handy to check if a certain item hasn’t been updated in a long time. As example I have the Tankerkoenig Binding installed, and this data is persisted in InfluxDB. This way I can see historic gas prices in Grafana.
When the Telegram Bot answers the /tanken question, it appends the timestamp of the last gas prices update.
In this case I might have different update timestamps from different stations, because the result returns the top N prices. I just pick the last price here.
| |
The entire code is explained in this blog posting. The relevant part is this:
| |
This defines a DateTime variable. While looping through the results, the lastUpdate timestamp from the influxdb persistance service is stored. And later when the result string is created, the formatted timestamp is appened.
Keep in mind that openHAB can have multiple Persistance services configured. The one you want to use (influxdb) is specified here.
Comments
With an account on the Fediverse or Mastodon, you can respond to this post. Known replies are displayed below:
Note: This will load data from mastodon.social.
Learn how this is implemented here.
Share: