[SOLVED] Daily Counter

I’d like to record the number of times an item changes state each day. At present I have a item defined as a number, which I reset to zero at midnight each day. Is there a way using some form of persistence that would allow me to record the value of my item at 23:59 each day?

I’d like to avoid having to create separate items for each day of the week, as this is a limited workaround.

Could you not just create a rule that has a counter increase by 1 for every change of the item?

I have that in place, but want to record that number and store it for future use.

Then you have to write at EOD (23:59) in another persisted Number Item?

If you already have persistance running you could use

<item>.sumSince(AbstractInstant)

https://www.openhab.org/docs/configuration/persistence.html#persistence-extensions-in-scripts-and-rules

Use a second item which is set to the current value of your actual item at 23:59. Persisting this secondary item should be possible with any persistence servicd in stock.

1 Like

Thanks @opus I was overthinking it, this idea is simple and easy to sort out.