Display value decreased with historical value

Hello everyone!

I have an energy counter and want to display how much energy was used in last week.

Here’s how I think it should be done:
I need an item displaying some value (from MQTT) decreased with historical value of another item (persisted in influxdb).
I assume, I need to create separate item and use transformation (let’s say in JS). But the question is how I can access influxdb from transformation?
Any suggestions?

You can’t.

What you need to do is use a Rule. You can access historic states, sums of the state since a certain date, etc on the Item stored in InfluxDB from the Rule.


Ok, but how can I show the result of such rule in BasicUI, or in habpanel?

You post the result of the calculation to an Item and put the Item sitemap or HABPanel.

Cool. It seems your tip is what I was looking for last days. Thanks!