I would like to display Max and Min temperatures of a year and therefore created two Items:
Number OutdoorTempMax
Number OutdoorTempMin
Simple rule:
rule "Update Max Outdoor temp"
when
Item OutdoorTemp changed or
System started
then
postUpdate(OutdoorTempMax, OutdoorTemp.maximumSince(now.minusDays(365)).state)
end
rule "Update Min Outdoor temp"
when
Item OutdoorTemp changed or
System started
then
postUpdate(OutdoorTempMin, OutdoorTemp.minimumSince(now.minusDays(365)).state)
end
But everything I see for Max and Min ist the current temperature.
Even when the temperature changes, both (Max/Min) change too and displaying the current temp.
All values are stored well as I can see them in a chart.
Any idea what IĀ“m doing wrong here?
Have you fixed their strategies yet?
Edited strategies do not come into effect until the next restart.
There might be some interaction between having these both restore-on-startup and calculated by system started rule, you donāt really need both, but I canāt see an issue really.
ItĀ“s tracked well with logInfo:
MaxTemp: 6.0, etc
but this is exactly the current temperature IĀ“m getting for item OutdoorTemp, but itĀ“s not the MAX.
I can draw charts for last two years, so Max and Min are present.
Returning:
Maximum was: 34.5Ā°C at Sat Aug 08 14:00:00 CEST 2020
Minimum was: -1.2Ā°C at Sat Dec 26 01:00:00 CET 2020
Maximum was: 10.2Ā°C at Tue Dec 22 06:30:00 CET 2020
Minimum was: -1.2Ā°C at Fri Dec 25 07:15:00 CET 2020
Maximum was: 4.6Ā°C at Wed Dec 30 15:44:12 CET 2020
Minimum was: 1.6Ā°C at Tue Dec 29 15:45:00 CET 2020
All returns are as they should be!
Did you check with a REST call for the persisted item-states or a chart wether the persisted data can be called when it is not working?
What would the .timestamp show for a .maximumSince .state with the actual (false) value be?
Could you do the checks as posted above when it is not working?
Note: Iām fishing in the dark, in other words: I have no clue!
The .timestamp part does give the actual date of the HistoricItem.
I think IĀ“ve found the problem. Although default persistance rrd4j was selected via Habmin it disappeared at each restart of OH!
IĀ“ve checked every file under /conf/ and found a āruntime.cfgā.
There are several entries all commented out with a ā#ā, apart ādefault persistence serviceā which was set to āmapdbā. A big question for me, as I never touched this file and definitely checked the default persistence within Habmin which was set to rrd4j (and disappeared after restart).
Anywayā¦ IĀ“m happy it works fine now and I THANK you very much for your effort to help me!
how to display the Max/Min timestamp in the sitemap?
IĀ“ve created an item
DateTime OutdoorTempMinTime
Sitemap entry
Text item=OutdoorTempMinTime label="Min [%1$td %1$tb %1$tR]" icon="time"
and a rule
rule "Update Min Outdoor temp"
when
Item OutdoorTemp changed or
System started
then
postUpdate(OutdoorTempMin, OutdoorTemp.minimumSince(now.minusDays(365)).state)
postUpdate(OutdoorTempMinTime, OutdoorTemp.minimumSince(now.minusDays(365)).timestamp)
logInfo ("TestMaximumsince","Minimum was: " + OutdoorTempMin.minimumSince(now.minusDays(365)).state + "Ā°C at " + OutdoorTemp.minimumSince(now.minusDays(365)).timestamp)
end
For this I get an error:
2021-01-02 09:13:35.089 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule 'Update Min Outdoor temp': Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.postUpdate(org.eclipse.smarthome.core.items.Item,java.lang.String) on instance: null
getting 2021-01-04 08:54:33.901 [WARN ] [rthome.model.script.actions.BusEvent] - Cannot convert 'Wed Jan 22 13:00:00 CET 2020' to a state type which item 'OutdoorTempMinTime' accepts: [DateTimeType, UnDefType].
getTimestamp instead of timestamp brings the same error message
If you really want to only display it, using a string item should show something like ā2020-12-18T15:15+01:00[Europe/Berlin]ā ( at least it shows like that in a logInfo)
Using postUpdate(Test, CPU_Load.minimumSince(now.minusDays(17)).timestamp.toString) on a string item and sitemap label set to "[%s]" I got the above posted string.