I have a item, which is increasing depends on the power consumption.(let say 2.4. at 00:00 value was 4500 and 3.4. at 00:00 value was 4800 - so a day value is 300)
Is correct calculation for current monht this ?
item.sumSince(now.minusDays(now.withDayOfMonth.dayOfMonth))
and for today this ?
item.sumSince(now.withTimeAtStartOfDay)
If the Item is forever increasing than no that’s not correct. The correct calculation will be the current value minus the value it was at the time you care about.
So what’s in the logs? Break the line apart and log each and every part.
The only apparent thing is that, per the docs, historicState returns a HistoricItem not a State. So you need to call .state on the result of that call to get at the value you might be able to do math with. If there was a problem or there is no data null will be returned.
Z_way_number_WallPlug2_totalpower ia the total power my zway plug sees …so I subtract the total power from the last day from the overall total power than I have the actual total power…