How can i save the power usage of every hour or every day?

i have a power meter and get the data every 10 seconds into openhab. My persistece is rrd4j with “every minute”.

Now i want to get some charts (openhab charts engine only) with a chart of the power consumption from every hour - so a chart for a day with only 24 values. Is this possible?

Also is this possible to get a chart with the value of the whole day? So maybe a chart for 1 month with only 30 values in it?

How can i do that?

Make a new item: power_consumption_hourly and store the value of the last hour with a cron-job?

If you don’t want to average the values, then just set a one hour or daily persistence strategy for the Item… no rule needed. Although, most power meters also report a cumulative energy value too, which is probably what you’d want to be viewing. If your meter doesn’t report energy, you’d need a rule to calculate it.

I get Power (kW) and Energy (kWh) from my energymeter.

So when i set persistence for kWh to every hour, i will get a strange chart? The chart-line will go higher and higher? Because the power meter counter gets higher and higher…

I need the energy from the last hour. So i will need an additional rule, i think? And after every hour, i will have to calculate the energy again?

Have look into the Datasource documentation, especially the Counter sounds promissing (although I haven’t used this one).

Ok. I will try this.

Is there an easy way to get the data from one day out of my already saved rrd4j (every minute) data? With value for every hour? Maybe rule or something else?

So i get 24 values with the data consumption of this hour for the last 24 hours?

Cronjob - every hour send value to a new item maybe?

Getting data that is persisted is possible, however going back in time rrd4j does data consoldation.
Read this for some rule examples.

No you are talking about a new setup?
I’d read the energy consumption (kWh) every hour in a rule, calculate the delta since last hour and persist this value.

I have a new rrd4j strategy everyHour and i postUpdate the value of the last hour inside a rule to my item every hour. But my chart is empty… Do i have to persist the value everyMinute? So the same value every Minute until i postUpdate a new Value to this item at the beginning of the next hour?

If you want to use the simplistic sitemap Chart widget, then yes you do.

The alternative is to use some other charting tool like Grafana, which is more flexible about its source data.

I only use the included charts. I know about grafana, i will have to look for this when i have some spare time…

But then i have the following problem:

I have the power consumption from 9 to 10 o´clock. And this value will be visible on the chart at the time from 10 to 11 o´clock…

Is this need for the everyMinute strategy really a limitation caused by the simplistic sitemap? Creating a chart for archives with larger timeframes ( i.e. data only for houres or days) is working!
I understood that the version 1 rrd4j persistence service would not persist without that strategy.

Good point ; I don’t know. Fer sure it is necessary for the rrd4j + Chart combination.

Yes. That’s what you get with data that changes hourly on a simple chart. What would you like to happen instead?

I see, without grafana i can´t get what i want.

I want the value at that time, it was uses. --> When the next hour begins, i want to change the value of the last hour, to get the real value at the real time inside my chart. And a chart-line is the wrong image. I need a bar graph - one bar for every hour - or only 1 value point at the middle of the hour with cahrt-line. But what i get on the included chart, this is not the right thing…

Okay, it sounds like it. Does your “calculate hourly but store everyminute” not give you nice steps in Chart?

Yes, it looks ok, but the only thing, which is not so good, is that the values are 1 hour to late…

That depends wether the data is shown from an archive keeping the data by minute or by hour. If you show the data from an archive that has only a value per hour it will show the line point of that hour and connect to the next hour point. That may look odd for a couple of days, looking onto 30+ days is looks ok to me ( using such atm).
If you really want a bar display you have to look for other charting possibilities ( habpanel?, grafana).

Well, openhab persistence is geared up to record data for “now”. It would be especially hard to record data from the future.

There are difficult ways to fiddle the data, i.e. record your hourly reading as though it was half-hour earlier. I’m not even sure if you could do that with rrd4j at all though. And I really do not advise ever making “faked” data in general, it’s stupid. This is just a presentation problem.

I think you need a bar-charting solution. The Chart widget is just too (deliberately) simple for this use.

EDIT - cheapskate approach to faking the “look” with simple Chart.
Run a rule on the half-hour. This rule to calculate actual usage over previous half-hour, and predict the next half-hour. At it’s simplest that’s just double. At the fanciest, you look at trends from today and yesterday and last week and the weather forecast etc.

Now record that value and persist every minute until the next half-hour. Any errors you made in your prediction will then get taken care of, but we can’t go back and fix a poor prediction.
Result - a steppy Chart looking like a bar chart centred on the hours.

EDIT - nah, the detail here is rubbish, isn’t it. You need to predict the full hour ahead from the half-past-hour time.

What! Are you kidding me… This is suppose to be smart… And then it cant even record data from the future…:rofl:

I don´t need data from the future. It is enough, if it would be possible to tell the persistence, that the value is for the last hour in the past.

Maybe it is possible with grafana to change the scale on the axis to my needs?