How do you graph accumulating quantities

I have several accumulating quantities like rain_today or energy from the smart meter which either reset after a period (each day, week, month) or count indefinitely.

With these now I would like draw graphs (in a sitemap without additional tools like grafana) over time to see rainfall on 1st each day and 2nd week, month. All with an optimized persistence such that only one value per day is stored (using mysql as backend) - which for sure is the max(day) of the initial item.

I cannot believe that I am the first trying to solve this issue but I didn’t find any existing solution :frowning:

Assuming you have persistence that is not MapDB see the Chart element for sitemaps. But that’s going to be a line graph and not a bar chart which is probably more appropriate if all you care about is two data points.

See the Persistence configuration (Persistence | openHAB) for how to define a .persist file to control how often to save an Item’s state to the database. You can configure it to once a day. If there is some processing you want to do prior to saving the value you can not define the Item in the .persist file and instead use the .persist() method (Persistence | openHAB) on the Item in a rule.

1 Like

Thanks. So it’s not just that I did not find a way to draw a bar graph, but there is none in OH? I was hoping to draw something like:

not as forecast as in this screenshot and it would be perfectly fine to have the bar graph for the rain separately from the temperature line graphs (which work perfectly already in my charts)

The closest thing that looks feasible for plotting would be to have the maximum of my existing (accumulative rain gauge value) of the day stored in mysql with a timestamp of 0:00 and 23:59:59 each day and use a line plot. While the one at the end of day is no big challlenge in a rule I fear I’d need to to some external script to copy it to the beginning of the day, right?

Last but not least the current day is also interesting, so during the day somehow it would be cool to have the maximum till now in these two (start-of-day and now) data points.

Maybe best is to automatically persist every 5 minutes and in a cron-job delete all but the current maximum and additionally copy this to the time stamp 0:00h of the current day? Anyone having a script around for that?

Not in OH 2.5. OH 3 supports bar graphs.

Just trigger a rule at 23:59:59 and persist and then again at 00:00 and persist.

oh, that’s good news then. This is in the “OH3 UI”? And is there a way to configure the OH3 UI in files? Maybe you can point me to some docs - I do not really find my way to OH3 documentation :frowning:

But at 00:00 my accumulated value will be restarting at 0 and it should show the maximum of that new day.

But maybe the bar graph in OH3 will do the trick…

Not at this time.

All the existing OH 3 docs are at Introduction | openHAB as of today. If it’s not there it doesn’t exist yet.

That’s a pity. I have a mix of file based configuration and PaperUI today in OH2 and I sweared I will not configure anything in the UI next time - and the transition to OH3 would be the perfect fit for a configuration from scratch :frowning:

Ok, this is where I look but it is quite unclear to me what applies to OH2 and what to OH3, what will be deprecated in future.

Everything there is applicable to OH 3.

PaperUI does indeed really suck. But MainUI does not. You are probably doing yourself a disservice by not at least reviewing how MainUI works. Because, unlike PaperUI, it actually does work. I used to only do Things through PaperUI and text for everything else. I’m now moving everything, including my Rules, to the UI. And yes, I still maintain everything in a git repo and have history and version control and all that.

This might be true, but if I read between your lines it seems, that e. g. the chart functionality in the sitemaps is at least not what is recommended with OH3. Whether the new MainUI (I guess this is the name of the OH3-UI) is better I cannot really judge so far. I had tried it and I failed to configure charts until I watched the video of the virtual meetup as I tried to add the chart as an “element” in the page and did not expect that I need to create a new page of type chart… At least it was not intuitive for me using it the first time.

Thanks for the hint, I’ll give it a try as soon as I have persistence setup properly in my OH3 test env. If my problem above is solvable directly in OH3 charts it would be clearly my preferred solution - even if I would directly violate my “everything in text files” rule :slight_smile: