Flatten a temperature curve

Hello

I am saving 2 temperature values in persistence RRDJ4 and displaying it in a graph.
Is there a way to flatten the curve? I best case there should only be two flat lines.

grafik

Thanks for any help

You want to change the picture or the data? What are you using to create the graph?

Hmm good question, I think I want to change the picture and keep my data.

These two item/values are used for the graph

Number HeatPump_Probe_in ā€œErdkollektor Ausgang [%.1f Ā°C]ā€ (gHeatpump, gHeatpump_VorRueck_HZ, gHeatpump_VorRueck, gHeatpump_Aussen_Kollektor) { novelanheatpump=ā€œtemperature_probe_inā€ }

Number HeatPump_Temperature_1 ā€œAuƟentemperatur [%.1f Ā°C]ā€ (gHeatpump, gTemperatur_Aussen, gGA_Aussen, gRPiTemp, gHeatpump_Aussen_Kollektor) { novelanheatpump=ā€œtemperature_outsideā€ }

Ooookay, what are you using to create the graph?

Thereā€™s not much you can do with a sitemap Chart widget. It is deliberately simple, with few options, for use on underpowered hosts.

If you want fine control of charting, many people use Grafana.

I donā€™t really understand what you want to see, two flat lines seems useless.
You want to suppress noise? i.e. take average values over time and store that for charting (alongside real data)

1 Like

I would use grafana and plot the average over a period of time.

That is exactly what I want, but I have no idea how to do neither what to google for

Grafana looks so difficulty to me ā€¦

Keep your sensing Item as it is, and persist it, and you can use the persistence service itself to do the averaging for you.

Make a new Item like

Number sensing_average "averaged readings"
rule  "get an average"
when
   Item mySensor changed
then
   val av = mySensor.averageSince(now.minusMinutes(20), "rrd4j")
   sensing_average.postUpate(av.toString)
end

Persist this averaged Item, plot your chart from that data.

rrd4j isnā€™t the best database for accuracy here, as it has built-in data compression and averaging.

1 Like

Its not that hard if you have openhabian which can install it for you.

Why not use the built-in data compression exactly for the desired output? In the default setup rrd4j stores the average from 720 minutes (archive 5) for each value when looking for a year. Just set it up for a larger timeframe.
If the OP looks for a ā€œflattenedā€ line accuracy seems not to be the point!

Sounds good and easy. Maybe you have an example for me how to do it?

correct

Have a close look into the rrd4j documentation.
The default setup is explained in depth.
Changing the archive number five to store a single value per day instead of two would look like:

defaultNumeric.archives=AVERAGE,0.5,1,480:AVERAGE,0.5,4,360:AVERAGE,0.5,14,644:AVERAGE,0.5,60,720:AVERAGE,0.5,1440,365:AVERAGE,0.5,10080,520

NOTE:
Using this setup your rrd4j database would need to restart, in other words you are losing all your stored data. That is because all consolidated values are calculated on the go.

True enough, but it does depend on what else they do (or might in future want to do) with the data. I have a phobia about discarding data forever :wink:

1 Like

Moving average in graphana should do the trick.

Sorry for reopening this issue.

Today I upgraded to 2.5.3 and this rule is now firing errors, before upgrade no issues:

rule  "Mittelwert und Minimal bilden"
when
   Item HeatPump_Temperature_1 changed
   or
   Item HeatPump_Probe_in changed
then
   val av_1 = HeatPump_Temperature_1.averageSince(now.minusHours(24), "rrd4j")
   val av_2 = HeatPump_Probe_in.minimumSince(now.minusHours(24), "rrd4j")
   HeatPump_Temperature_1_average.postUpdate(av_1)
   HeatPump_Probe_in_average.postUpdate(av_2)
end

2020-04-06 21:37:17.365 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ā€˜Mittelwert und Minimal bildenā€™: An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.postUpdate(org.eclipse.smarthome.core.items.Item,org.eclipse.smarthome.core.types.State) on instance: null
2020-04-06 21:37:17.368 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ā€˜Mittelwert und Minimal bildenā€™: An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.postUpdate(org.eclipse.smarthome.core.items.Item,org.eclipse.smarthome.core.types.State) on instance: null

Any ideas or solutions for me?

Thanks

Minimumsice and maximumsince are a bit different then average since, while the later givesavaluethetwoformer give a historic object, which contains the value. . Try to use the.state of this object.
Like:
val av_2 = (HeatPump_Probe_in.minimumSince(now.minusHours(24), "rrd4j").state as Number)

1 Like