Rules problem after migration to 2.1

Hi there

I had several problems with my rules.
After some time I got things reworking.
But still 2 problems are there and I don’t find the error.

First one I droped for the moment. This lines will stop the rules file from loading.

/* https://github.com/openhab/openhab/wiki/Samples-Rules#fire-detection */
rule “Fire_detection"
when
Item gTemperatureSensor received update
then
if (gTemperatureSensor.members.filter(s | s.state > 45).size > 0) {
if (AlarmFire.state == “-”) {
val results = executeCommandLine(”/etc/openhab2/scripts/sendSMS.sh Feu!!! 0660041043",15000)
logInfo(“ossy”, “Fire alarm tripped by temperature sensor!”)
val VarDT = now.toDateTime.toString(“dd/MM/yyyy HH:mm”)
sendCommand(AlarmFire, VarDT)
sendCommand(AlarmMotion, VarDT)
sendBroadcastNotification(“The fire alarm has been activated!!! - someone call the fire dept!!!” + VarDT + “!!!”)
}
}
end

The second one is giving me an error:

rule “Update_Temperature_Min_and_Max_values"
when
Item Temperature_GF_Kitchen received update
then
var Number Min
var Number Max
var String tmp
var SimpleDateFormat df = new SimpleDateFormat( “HH:mm” )
if (Temperature_GF_Kitchen.state instanceof DecimalType) {
Min = (Temperature_GF_Kitchen.minimumSince(now.toDateTimeAtStartOfDay, “jdbc”).state as DecimalType)
tmp = (Math::round(Min.floatValue10.0)/10.0) + " °C (" + df.format(Temperature_GF_Kitchen.minimumSince(now.toDateTimeAtStartOfDay, “jdbc”).timestamp) + " )"
postUpdate(Weather_Temperature_Min_Formatted, tmp)
Max = Temperature_GF_Kitchen.maximumSince(now.toDateTimeAtStartOfDay, “jdbc”).state as DecimalType
tmp = (Math::round(Max.floatValue
10.0)/10.0) + " °C (” + df.format(Temperature_GF_Kitchen.maximumSince(now.toDateTimeAtStartOfDay, “jdbc”).timestamp) + ")"
postUpdate(Weather_Temperature_Max_Formatted, tmp)
}
end

And here the error:
2017-08-12 20:05:44.465 [ERROR] [.script.engine.ScriptExecutionThread] - Rule ‘Update_Temperature_Min_and_Max_values’: An error occurred during the script execution: The name ‘.toDateTimeAtStartOfDay’ cannot be resolved to an item or type.

Thanks in adavance for any help.

Best regards

Ossy

Please try now.withTimeAtStartOfDay

Thanks a lot, this works for the first problem.

++
Ossy

First Rule: please take a look at the very first line

rule “Fire_detection"

These are the wrong quotation marks. This error is in the whole rule. Please try

rule "Fire_detection"
when
    Item gTemperatureSensor received update
then
    if (gTemperatureSensor.members.filter(s | s.state > 45).size > 0) {
        if (AlarmFire.state == "-") {
            val results = executeCommandLine("/etc/openhab2/scripts/sendSMS.sh Feu!!! 0660041043",15000)
            logInfo("ossy", "Fire alarm tripped by temperature sensor!")
            val VarDT = now.toDateTime.toString("dd/MM/yyyy HH:mm")
            sendCommand(AlarmFire, VarDT)
            sendCommand(AlarmMotion, VarDT)
            sendBroadcastNotification("The fire alarm has been activated!!! - someone call the fire dept!!!" + VarDT + "!!!")
        }
    }
end

Thanks Udo
I retyped the script new and now it works.

Best regards
Ossy