For calculation propose.
I have some energy consumption measuring devices which add always the amount of the daily energy consumption to the one from yesterday and so on…if I now like to know the amount of the actual consumption of the day I need to subtract the latest value from the sum of values from beginning.
Therefore I want to identify the first recorded date to use the persist function .sumsince()
So you want to identify the first timestamp that an Item’s state was stored for the specific Item (your thread title is way off in this case )
If the power meter updates the Item state with the consumption delta of each 24hours, you shouldn’t really care when the persistence service started to store data. You can call the sumSince (capital S) for a predefined period of time (e.g. a month). The persistence will return whatever data it finds.
What do the meters report daily (or more frequently)? Delta or cumulative values?
Anyway… you can always use select statements and/or tools like phpMyadmin to look into the MySQL DB.
I don’t think that you can specify in one line the start and end time for the .sumSince… You may need to do this in 2 steps in your rule and then calculate the difference.
it should look something like this in your rule:
val YTDValue = ItemName.sumSince(now.minusYears(1)) // this will give you Year To Date
val CurrentValue = ItemName.state // this will give you the current state
val YTD2Last = YTDValue - CurrentValue // this will give you the YTD without the current state value
??? then you need to rethink your calculations.
If you do Sum on cumulative you will end up with a huge (wrong) number
If you want just to visualize the data (not to use them in a rule): go with a tool like Grafana (you can configure there any time period you want)