Explicitly persist value for arbitrary timestamp

Hi,

I have running counters for several values (total power consumption per day) which will be reset at midnight. Now I would like to create charts that give me flat lines per day instead of the increasing lines per day that the standard persistence would display.

My idea was to explicitly persist only the last value of the day at 23:59h or the max value or whatever. In order to have the values in the chart being assigned to the correct day, I think I would need to somehow make the persistence service believe that this is the value at 00:00h this specific day.

Is this possible somehow using a rule? Or can this be achieved any other way?

Thanks in advance
macmeck

Cannot be done with openHAB persistence services.
Recent related post

I suggest that it’s usually better in principle to manipulate the charting, rather than “faking” original data, but I wouldn’t know how to go about that.

That can be done: (with all counters in the group gCounters)

Strategies {
    beforeMidnight: "30 59 23 * * ?"

    default = everyChange
}

Items{
    gCounters*: strategy = beforeMidnight
}

That can be done, but I’m not really sure why you would need that?

That can be done? cool - how?

why? If I persist at 23:59, the chart would display today’s value only tomorrow (starting 23:59 today). So the values are being shown one day late.

But isn’t that the reality? If the items would have that value at 0.00 already, you could have persisted it then.

The how is in principle simple: adjust whatever you are using to make the graph such that it only takes the date part, not the time part, for the x axis.
If that can be done with the graphs you are making depends on which system you use for that.

kind of - the value I’m measuring is the total power consumption per day for which the final value exists only at the end of the day but is valid for the whole day, so to say.

I’m using the standard charts of openHAB. Is there any way to make them use the date part only when taking values from the persistence service?

The standard OH charting is deliberately quite basic. Do you actually notice this issue, if charting say monthly figures?

Some people use the more sophisticated Grafana with OH. I don’t know what stunts that can perform…

Lots. For example, in this case I would use the dates only as the x-axis as RolfV suggests and chart the values as a bar chart instead of a line graph. Then the data very neatly lines up with the usage per day visually.

My thoughts were along the same lines indeed.
Standard OpenHAB charts do not allow such things however.

Furthermore, which persistence service are you using @macmeck? Can be quite relevant to make this worthwhile as a solution for long term trends and such.