Timing of calculations involving Items

Hi All,

The figure below shows a graph of four items, where the red line is the sum of three of the others. In fact, the blue line is the output of my solar panels, the yellow line is electricity demand from the grid, the orange is electricity supplied back to the grid. The red line (calculated) indicates the total power consumption of our house.

I have the following rule to calculate the red line:

energy = (SMA_TotalPac.state as Number) + (MEMAP.state as Number * 1000) - (MEMPP.state as Number * 1000)
TOTPowerUse.postUpdate( energy )

The problem arises with the “postUpdate”, as the calculated TOTPowerUse appears 1 minute after it was posted (sample frequency of the rule trigger). You can see the delay in the red line.

Is there a way to fix this problem? Eg, update TOTPowerUse now, rather than post an update?

Cheers, Robert.

When does the calculation rule run?
You’re plotting graph from persisted data? When does it get persisted?

This is the rule header:

rule “Calculate total power use”
Item MEMAP changed or
Item SMA_TotalPac changed

This is the persists config:

	MEMAP : strategy = everyUpdate
	MEMPP : strategy = everyUpdate

	SMA_TotalPacStr : strategy = everyUpdate
	SMA_ETodayStr : strategy = everyUpdate
	SMA_TotalPac : strategy = everyUpdate
	TOTPowerUse : strategy = everyMinute

Note that in fact the SMA data is only updated every minute based on a Cron rule (in crontab).

What kind of persistence are you using?
What kind of charting?
There’s lots of places you could be hitting granularity of a minute.

For starters, you could examine your events.log to see when your target Item gets changed in relation to source Item changes. That would allow you to distinguish a rule issue from a a persist/charting issue to begin with. Divide and conquer.

Bear in mind we cannot see over your shoulder. We could guess the calculated Item :smiley: but have no idea which other Items represent what values.

1 Like