I have a problem getting min max temperature to work after I have updated to 3.0 I have used this rules in 2.0
import java.text.SimpleDateFormat
import org.eclipse.smarthome.core.library.types.DecimalType
import org.joda.datetime.DateTime.*
rule “Temperatur Min-og Max values Carportnord”
when
Item Temperatur_Udebygninger_Carportnord received update
then
var Number Min
var Number Max
var String tmp
var SimpleDateFormat df = new SimpleDateFormat( “HH:mm” )
if (Temperatur_Udebygninger_Carportnord.state instanceof DecimalType) {
Min = (Temperatur_Udebygninger_Carportnord.minimumSince(now.toDateMidnight, “rrd4j”).state as DecimalType)
tmp = (Math::round(Min.floatValue10.0)/10.0) + " °C (" + df.format(Temperatur_Udebygninger_Carportnord.minimumSince(now.toDateMidnight, “rrd4j”).timestamp) + " )"
postUpdate(Temperatur_Udebygninger_Carportnord_Min, tmp)
Max = Temperatur_Udebygninger_Carportnord.maximumSince(now.toDateMidnight, “rrd4j”).state as DecimalType
df = new SimpleDateFormat( “HH:mm” )
tmp = (Math::round(Max.floatValue10.0)/10.0) + " °C (" + df.format(Temperatur_Udebygninger_Carportnord.maximumSince(now.toDateMidnight, “rrd4j”).timestamp) + “)”
postUpdate(Temperatur_Udebygninger_Carportnord_Max, tmp)
}
end
rule “Temperatur Min-og Max values Terrasse”
when
Item Temperature_Terrasse received update
then
var Number Min
var Number Max
var String tmp
var SimpleDateFormat df = new SimpleDateFormat( “HH:mm” )
if (Temperature_Terrasse.state instanceof DecimalType) {
Min = (Temperature_Terrasse.minimumSince(now.toDateMidnight, “rrd4j”).state as DecimalType)
tmp = (Math::round(Min.floatValue10.0)/10.0) + " °C (" + df.format(Temperature_Terrasse.minimumSince(now.toDateMidnight, “rrd4j”).timestamp) + " )"
postUpdate(Temperature_Terrasse_Min, tmp)
Max = Temperature_Terrasse.maximumSince(now.toDateMidnight, “rrd4j”).state as DecimalType
df = new SimpleDateFormat( “HH:mm” )
tmp = (Math::round(Max.floatValue10.0)/10.0) + " °C (" + df.format(Temperature_Terrasse.maximumSince(now.toDateMidnight, “rrd4j”).timestamp) + “)”
postUpdate(Temperature_Terrasse_Max, tmp)
}
end
is there anything I may have forgotten to install or set up when I switched to 3.0
rule “Temperatur Min-og Max values Carportnord”
when
Item Temperatur_Udebygninger_Carportnord received update
then
var Number Min
var Number Max
var String tmp
var SimpleDateFormat df = new SimpleDateFormat( “HH:mm” )
if (Temperatur_Udebygninger_Carportnord.state instanceof DecimalType) {
Min = (Temperatur_Udebygninger_Carportnord.minimumSince(now.with(LocalTime.MIN), “rrd4j”).state as DecimalType)
tmp = (Math::round(Min.floatValue10.0)/10.0) + " °C (" + df.format(Temperatur_Udebygninger_Carportnord.minimumSince(now.with(LocalTime.MIN, “rrd4j”).timestamp) + " )"
postUpdate(Temperatur_Udebygninger_Carportnord_Min, tmp)
Max = Temperatur_Udebygninger_Carportnord.maximumSince(now.with(LocalTime.MAX, “rrd4j”).state as DecimalType
df = new SimpleDateFormat( “HH:mm” )
tmp = (Math::round(Max.floatValue10.0)/10.0) + " °C (" + df.format(Temperatur_Udebygninger_Carportnord.maximumSince(now.with(LocalTime.MAX), “rrd4j”).timestamp) + “)”
postUpdate(Temperatur_Udebygninger_Carportnord_Max, tmp)
}
end
Maybe it is a totally different problem but I also have a problem with a temperature rule.
rule "Heater Tuinschuur"
when
Item ZWaveNode010FGBS001UniversalBinarySensor_Temperature2 changed
then
if (ZWaveNode010FGBS001UniversalBinarySensor_Temperature2.state < 9 )
{ ZWaveNode007ZMNHYDSmartPlug_Switch.sendCommand(ON)
}
if (ZWaveNode010FGBS001UniversalBinarySensor_Temperature2.state > 11 )
{ ZWaveNode007ZMNHYDSmartPlug_Switch.sendCommand(OFF)
}
end
I feel a bit stupid asking the question here but within OH 2.5 it worked.
When I delete ‘then’ and ‘if’ parts the plug switch turn on.
I still can not make this work, does anyone have an idea of what is missing or what I may have forgotten when I updated from 2.0 to 3.0, because it worked fine in 2.0
Give us some help here. What happens or doesn’t happen? Have you looked in your openhab.log for clues?
The big change in OH3 that’s relevant for time handling rules is that the Java time functions have all changed. For example, “now” still exists, but it’s a different kind of object with different functions.
This looks relevant
For self help, add some logInfo() lines to your rule so that you can see how far it gets and important values along the way e.g.
if (Temperatur_Udebygninger_Carportnord.state instanceof DecimalType) {
logInfo("test", "TempUC " + Temperatur_Udebygninger_Carportnord.state.toString)
Min = (Temperatur_Udebygninger_Carportnord.minimumSince(now.with(LocalTime.MIN), “rrd4j”).state as DecimalType)
logInfo("test", "Min " + Min.toString)