I have a item where is value of the energy consumption normaly still increasing.
But when there is power shut down or unit restart, this counter start again from zero :
To calculate consumption from this value for actual day, I’m using function
val ZonedDateTime zdt = ZonedDateTime.now()
val actual_day = zdt.withHour(0).withMinute(0).withSecond(0)
val today = Cons_Value_as_Number.deltaSince(actual_day) as Number
It’s working when there isn’t a restart, because then I have a negative value for this one day when reset to zero happened
Do you have any idea how to treat this special case, when counter goes to zero?
minimumSince() returns a historic item. Historic item has a timestamp. Convert this timestamp to a ZonedDateTime, substract one second.
Use deltaBetween(startOfDay, timestamp) to get the sum until reset
Use deltaSince(timestamp) to get the rest of day
Add both values and you are done.