Timer ERROR [ERROR] [ntime.internal.engine.RuleEngineImpl]

Hi all,

try actually a temperature rule that my freezer send an push if its too hot in it. but get following error on log:

2020-04-20 09:18:23.865 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Temperature Freezer': cannot invoke method public abstract boolean org.eclipse.smarthome.model.script.actions.Timer.cancel() on null

// Variables for Timer
var Timer   tTTemp = null       // Gefrierschrank

rule "Temperature Gefrierschrank"
when
    Item Temperatur_Gefriere changed
then
    if(Temperatur_Gefriere.state instanceof Number) {
        if((Temperatur_Gefriere.state as Number) >= -17) {
            if(tTTemp === null)
                tTTemp = createTimer (now, [|
                    logInfo("RULE", "--> Temperaturalarm: Tiefkühler >= -17°C / A_Temperature")
                     pushover("XXXX", "XXXX", "Gefrierschrank zu warm !!")
                    tTTemp.reschedule(now.plusMinutes(15))
               ])
        } else if((Temperatur_Gefriere.state as Number) < -17.2) {
            tTTemp.cancel()      
            tTTemp = null
        }
    }
end

Can anybody help me here out ?

Additional pushover message does not work - got following error :slight_smile:
2020-04-20 10:28:24.032 [WARN ] [ab.action.pushover.internal.Pushover] - Fatal transport error. api.pushover.net

That’s weird; the rule you have shown us is called
rule "Temperature Gefrierschrank"
but I expect there’s some auto-translate in play.

There is a path through your rule when temp < -17.2 to call tTTemp.cancel() when there is no timer and tTTemp is already null.
You cannot cancel null, hence the error message.

You could test for null before attempting to cancel, but there is a handy shortcut trick for this
tTTemp?.cancel()