Hi all,
is there a way in OpenHAB component oh-time-axis to specify a formula as value, e.g. the sum of two item values?
Or is there any other way to show a formula of 1 to n item values on a time axis?
Thanks for any answer in advance!
No, I don’t believe there is. The data is fetched from the default persistence service for the specified item and there is no built-in method for performing array manipulations in the persistence system.
You can create an axis that stacks the different series sent to it so that you get something like a summed value. Most people who seek to do something like this, however, just create an additional item that is populated by a rule which will do the math and then chart that new item instead.
Thanks for the hints. The stacking would work - but only if I wanted a sum. The additional item would work too - but only from the time of creation of the item. However, I want to find out the relationships of item values over time and need to try out multiple relationships and formulas to see if the graphs match. This way, I would need days or weeks to find out what I’m looking for because after the creation of the item, I would need to wait 1-2 days to be able to analyse the graphs.
Or can I write historic values for the newly created item into the persistence via script?
You can use the API to set past persistence values, so technically it’s possible to write a script that will do this.
Honestly, though, it sounds to me like you’re better off with some external tool. You’ll loose more time trying shoehorn this function into OH then just finding the right tool from the start. Once you’ve got the formulae you need, then you can return to OH and set up the item(s) (or just connect OH to whatever tool you’ve found that might do the trick, e.g., Grafana).