Problem min and max since?

Hi

I have try out this sample https://github.com/openhab/openhab1-addons/wiki/Samples-Rules#how-to-display-the-minimum-and-maximum-values-of-an-item-in-a-given-period

but i cant get it to work pls help

item part

Number Temperatur_Udebygninger_Udv "Temeratur udenfor [%.1f °C]" <temperature> { channel="zwave:device:b277fbae:node10:sensor_temperature3" }
String Temperatur_Udebygninger_Udv_Min "- Min. Temp [%.1f °C]" <temperature>
String Temperatur_Udebygninger_Udv_Max "- Max. Temp [%.1f °C]" <temperature>

Rules part

rule "Temperatur Min-og Max values"
when
        Item  Temperatur_Udebygninger_Udv received update
then
        var Number Min
        var Number Max
        var String tmp
        var SimpleDateFormat df = new SimpleDateFormat( "HH:mm" ) 

        if (Temperatur__Udebygninger_Udv.state instanceof DecimalType) {
            Min = (Temperatur__Udebygninger_Udv.minimumSince(now.toDateMidnight, "rrd4j").state as DecimalType)
            tmp = (Math::round(Min.floatValue*10.0)/10.0) + " °C (" + df.format(Temperatur__Udebygninger_Udv.minimumSince(now.toDateMidnight, "rrd4j").timestamp) + " )"
            postUpdate(Temperatur__Udebygninger_Udv_Min, tmp)

            Max = Temperatur__Udebygninger_Udv.maximumSince(now.toDateMidnight, "rrd4j").state as DecimalType
            df = new SimpleDateFormat( "HH:mm" ) 
            tmp = (Math::round(Max.floatValue*10.0)/10.0) + " °C (" + df.format(Temperatur__Udebygninger_Udv.maximumSince(now.toDateMidnight, "rrd4j").timestamp) + ")"
            postUpdate(Temperatur__Udebygninger_Udv_Max, tmp)
        }
end

Sitemap part

 Frame label="Ude temp" { 
 Text item=Temperatur_Udebygninger_Udv label="Temperatur udvendig"
 Text item=Temperatur_Udebygninger_Udv_Min label="Min temperatur udvendig"
 Text item=Temperatur_Udebygninger_Udv_Max label="Max temperatur udvendig"
 }

it lock likes this is my problem

The string items hold the formatted String to be displayed in the UI. The number item holds the current temperature, it must be updated periodically and persistence must be configured for this item. This example assumes, that the rrd4h persistence service is used, for other services the string “rrd4j” in the rule below must be modified accordingly.

but i dont know what this is

help me :slight_smile:

You mean that you don’t know what is the rrd4j persistence service?

If yes: Check http://docs.openhab.org/configuration/persistence.html. Follow the link to the OH1 Wiki :slight_smile:
(or https://github.com/openhab/openhab1-addons/wiki/rrd4j-Persistence)

Basically: A Persistence service stores historical information about the state of your items in a database.
Read more about this on:

Hi,

Following your posted rule, you are trying to update a string item with some information from the variable tmp.
Up to this point everything seems to be ok!
If you are using OH1 (as per the example you have provided), you should confirm your item state at http://your_ip:8080/rest/items/Temperatur_Udebygninger_Udv_*

In order to visualize the state of the described sitemap linked items, your syntax is wrong, try:

 Text item=Temperatur_Udebygninger_Udv_Min label="Min temperatur udvendig [%s]"

At least this is what I remember!

Best regards,

George

Hi I also have problems with this rule, I have the same items as the partner and I get this in the log

[ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'Update max and min temperatures'
java.lang.NullPointerException: null
	at org.eclipse.xtext.common.types.util.JavaReflectAccess.getRawType(JavaReflectAccess.java:107) ~[na:na]
	at org.eclipse.xtext.common.types.util.JavaReflectAccess.getConstructor(JavaReflectAccess.java:90) ~[na:na]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateConstructorCall(XbaseInterpreter.java:511) ~[na:na]
	at sun.reflect.GeneratedMethodAccessor101.invoke(Unknown Source) ~[na:na]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
	at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291) ~[na:na]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218) ~[na:na]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateVariableDeclaration(XbaseInterpreter.java:601) ~[na:na]
	at sun.reflect.GeneratedMethodAccessor95.invoke(Unknown Source) ~[na:na]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
	at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291) ~[na:na]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218) ~[na:na]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateBlockExpression(XbaseInterpreter.java:321) ~[na:na]
	at sun.reflect.GeneratedMethodAccessor103.invoke(Unknown Source) ~[na:na]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
	at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291) ~[na:na]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218) ~[na:na]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:204) ~[na:na]
	at org.openhab.model.script.internal.engine.ScriptImpl.execute(ScriptImpl.java:59) ~[na:na]
	at org.openhab.core.scriptengine.ScriptExecutionThread.run(ScriptExecutionThread.java:44) ~[na:na]

I’m with openhab 1.8
a greeting

Hi,
i have problem with my rule. I need min and max temperature for last 12h and 24h.
Number - min and max temperature for last 12h and 24h - example: 6.78
String - min and max temperature for last 12h and 24h with time when reached - example: 6.78 °C (11:20)
rule file:

import java.text.SimpleDateFormat

rule "Aktualizace Min a Max hodnot venkovni teploty"
    when
    	Item  Homie_ZD_BME280_Venku_Temp received update
    then
    	var Number Min12h
    	var Number Max12h
    	var Number Min24h
    	var Number Max24h
    	var String tmp
    	var SimpleDateFormat df = new SimpleDateFormat( "HH:mm" ) 
     	
     	if (Homie_ZD_BME280_Venku_Temp.state instanceof DecimalType) {
    		Min12h = (Homie_ZD_BME280_Venku_Temp.minimumSince(now.minusHours(12), "influxdb").state as DecimalType)
    		tmp = (Math::round(Min12h.floatValue*100.0)/100.0) + " °C (" + df.format(Homie_ZD_BME280_Venku_Temp.minimumSince(now.minusHours(12), "influxdb").timestamp) + ")"
    		postUpdate(ZD_Venku_Temp_Min12h_Formatted, tmp)
    		postUpdate(ZD_Venku_Temp_Min12h_Formatted_Value, Min12h)
    		
    		Min24h = (Homie_ZD_BME280_Venku_Temp.minimumSince(now.minusHours(24), "influxdb").state as DecimalType)
    		tmp = (Math::round(Min24h.floatValue*100.0)/100.0) + " °C (" + df.format(Homie_ZD_BME280_Venku_Temp.minimumSince(now.minusHours(24), "influxdb").timestamp) + ")"
    		postUpdate(ZD_Venku_Temp_Min24h_Formatted, tmp)
    		
    		Max12h = (Homie_ZD_BME280_Venku_Temp.maximumSince(now.minusHours(12), "influxdb").state as DecimalType)
    		tmp = (Math::round(Max12h.floatValue*100.0)/100.0) + " °C (" + df.format(Homie_ZD_BME280_Venku_Temp.maximumSince(now.minusHours(12), "influxdb").timestamp) + ")"
    		postUpdate(ZD_Venku_Temp_Max12h_Formatted, tmp)
    		postUpdate(ZD_Venku_Temp_Max12h_Formatted_Value, Max12h)
    		
    		Max24h = (Homie_ZD_BME280_Venku_Temp.maximumSince(now.minusHours(24), "influxdb").state as DecimalType)
    		tmp = (Math::round(Max24h.floatValue*100.0)/100.0) + " °C (" + df.format(Homie_ZD_BME280_Venku_Temp.maximumSince(now.minusHours(24), "influxdb").timestamp) + ")"
    		postUpdate(ZD_Venku_Temp_Max24h_Formatted, tmp)
    	}
    end

rule "Aktualizace Min a Max hodnot teploty Handy"    
    when
    	Item  Handy_BME280_Temp received update
    then
    	var Number Min12h
    	var Number Max12h
    	var String tmp
    	var SimpleDateFormat df = new SimpleDateFormat( "HH:mm" ) 
     	
     	if (Handy_BME280_Temp.state instanceof DecimalType) {
    		Min12h = (Handy_BME280_Temp.minimumSince(now.minusHours(12), "influxdb").state as DecimalType)
    		tmp = (Math::round(Min12h.floatValue*100.0)/100.0) + " °C (" + df.format(Handy_BME280_Temp.minimumSince(now.minusHours(12), "influxdb").timestamp) + ")"
    		postUpdate(Handy_Temp_Min12h_Formatted, tmp)
    		postUpdate(Handy_Temp_Min12h_Formatted_Value, Min12h)
    		
    		Max12h = (Handy_BME280_Temp.maximumSince(now.minusHours(12), "influxdb").state as DecimalType)
    		tmp = (Math::round(Max12h.floatValue*100.0)/100.0) + " °C (" + df.format(Handy_BME280_Temp.maximumSince(now.minusHours(12), "influxdb").timestamp) + ")"
    		postUpdate(Handy_Temp_Max12h_Formatted, tmp)
    		postUpdate(Handy_Temp_Max12h_Formatted_Value, Max12h)
    	}
    end

but sometimes i got this error:

2018-10-11 18:21:18.160 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Aktualizace Min a Max hodnot venkovni teploty': 'state' is not a member of 'org.openhab.core.persistence.internal.QueryablePersistenceServiceDelegate$1'; line 20, column 17, length 77

…but it looks, that it works…

Could somebody explain me the error?
Thanks
P.