averageSince(now.minusMinutes(120) not working


(karsten kaiser) #1

Hi,

i want to read an averaga temperature over 20 minutes to initiate the climate to go on or off.I did a lot of research but unsuccessful.

I have the following item config:

Number Temperature_DG_Studio	"Temperatur DG Studio [%.1f °C]"	<temperature>	(Temperature)	{knx=" 12/3/1 "}
Number Temperature_DG_Studio_AV	"Temperatur AVG DG Studio [%.1f °C]" <temperature>	(TempAV)

and entry into rrd4j.persist

Strategies {
	// for rrd charts, we need a cron strategy
	everyMinute : "0 5 * * * ?"

	everyMinutePV : "0 1 * * * ?"	
}

Items {
	Temperature* : strategy = everyMinute, restoreOnStartup
	TempAV : strategy = everyMinutePV, everyChange, restoreOnStartup
}

the rule itself looks like that:

// Calculate the average kW from last 75 minutes
rule "Calc Temperature_DG_StudioAverage"
when 
	Item Temperature_DG_Studio received update
then
	var tempdgAV = Temperature_DG_Studio.averageSince(now.minusMinutes(75)) as DecimalType
	postUpdate(Temperature_DG_Studio_AV, tempdgAV)
end

The rule is executed well - within the log files i could see taht - but the issue is that the average calculation is not done. the items per log are always from same value:

2017-06-23 19:15:17 - Temperature_DG_Studio received command 25.18
2017-06-23 19:15:17 - Temperature_DG_Studio_AV state updated to 25.1799999999999
2017-06-23 19:15:21 - Temperature_DG_Studio received command 24.88
2017-06-23 19:15:21 - Temperature_DG_Studio_AV state updated to 24.8799999999999
2017-06-23 19:15:26 - Temperature_DG_Studio received command 25.32
2017-06-23 19:15:26 - Temperature_DG_Studio_AV state updated to 25.3200000000000

Any idea? the update is posted from the KNX Bus to OH the time it occurs. so i cannot control how often that happens.

thanks for assistance!
Karsten


(Udo Hartmann) #2

everyMinute will trigger every hour (5 minutes after the full hour)
everyMinutePV will trigger every hour (1 minute after the full hour)

I guess, what you wanted was

Strategies {
	// for rrd charts, we need a cron strategy
	everyMinute : "5 * * * * ?"

	everyMinutePV : "1 * * * * ?"	
}