I have a following rule what worked perfectly on OH1.x, but since I updated to OH2, the rule doesn’t working.
This rule calculate the heating time and format it to: eg. 25.3 min (19:27)
rule “Heater Stopped” // Calculate heating time
Item STAT5 changed to OFF
var SimpleDateFormat datf = new SimpleDateFormat( “HH:mm” )
var long nowMsec = now.millis
var long wsMsec = whenStarted.millis
var long timeSinceStart = nowMsec - wsMsec
var double minutesSinceStart = (timeSinceStart/1000.0/60.0).doubleValue
tempr = (Math::round(minutesSinceStart.floatValue*10.0)/10.0) + " min (" + datf.format(HeatingTime.lastUpdate(“mysql”)) + ")"
Error message: Rule ‘Heater Stopped’: Cannot format given Object as a Date
I think it’s wrong with the “datf.format(…)”, but I do not know how to fix it.
Many thnaks for help.