I do want to create charts with a value in Euro. I do have an item with historical data from the past years that hold my energy consumption in kWh. I do have another item holding my energy price. Idealy I would be able to have value pairs for the energy price with a starting date and an associated price. But lets put this aside.
I like to have an expression instead of an item that will be the series value or instead a calculated item, that is represented as formula instead of a values comming from thing.
Any way to realize this in another way is appreciated.
You’ll have to use a rule to update the Item with the result of the calculation when the price or the kWh Item changes.
For historic values, you’ll need to query the database for the two values, loop through them, then post the result of the calculation and timestamps. This can be done with a rule too. But it’s a rule that would only run once. After that, the rule above would take over for current and future values.
All the methods you’d need to use are documented at Persistence | openHAB. You’ll mainly need one of the “getAllStates” actions and the persist(ZonedDateTime, State) method.
Beyond that how to proceed or more details depends on details not provided (e.g. rules language, size of the DB (in case it’s too big to handle all at once and processing the values needs to be broken up, etc).
If you are using rrd4j, you might be out of luck. Because of the way rrd4j works, it’s not always possible to insert data after the fact.
Hi Rich, thanks for your swift answer, more or less what I was afraid of. Do You know if there are any plans to enable expressions within charts that would allow a dynamic calculation of the rendered value of a series? Or the possibility of a calculated item?
And You are right, I used rrd4j which makes the whole effort more complicated.
I do not know anything about OH charting except that it’s based on an third party library. I don’t know how much control over what is and is not possible using it.