Freezer warning rule

hi all,i am trying to create a warning rule for my freezer.My goal is if the freezer temperature is over -10 C to warn me and check again in 30 mins.

var Timer sfreezer_timer = null
rule "small_freezer"
when
    Item SmallFreezer_Temperature changed
then
    if (SmallFreezer_Temperature.state > -10) {
	    deskhall.sendCommand(ON)
	    say("the big freezer temperature is"+SmallFreezer_Temperature.state.format("%.1f")+"degrees , something is wrong")
		val mailActions = getActions("mail","mail:smtp:mailserver")
        mailActions.sendMail("xxxxxxxxxx@gmail.com, xxxxxxxxx@yahoo.co.uk", "Small Freezer", "check the small freezer,the temperature is over -10C")
		sfreezer_timer = createTimer(now.plusMinutes(30)) [|
		    if (SmallFreezer_Temperature.state > -10) {
			    say("the big freezer temperature is"+SmallFreezer_Temperature.state.format("%.1f")+"degrees , something is wrong")
		        val mailActions = getActions("mail","mail:smtp:mailserver")
                mailActions.sendMail("costascontis@gmail.com, oxlagogi@yahoo.co.uk", "Small Freezer", "check the small freezer,the temperature is over -10C")
				sfreezer_timer.reschedule(now.plusMinutes(30))
			}
			else {
                if (sfreezer_timer !== null) {
	             sfreezer_timer.cancel
		         sfreezer_timer = null				 
                }
            }
		]	
	}
end

after 2 hours i cant make it work…my temp sensor is reporting temps as a Number for example:

2021-04-22 10:44:49.937 [vent.ItemStateChangedEvent] - SmallFreezer_Temperature changed from -19.42 °C to -19.6 °C

but i thing the problem is at the

if (SmallFreezer_Temperature.state > -10)

tried to reverce the > symbol ,but nothing works…Any idea?

It’s got units.

That hasn’t got units. Is -19°C more than -10°F, or 10 bananas, or?
You need to compare like with like.

The rule ha other problems, it runs every time the temperature changes and creates a new timer, as well as any existing.

1 Like

thanx i solved it :slight_smile: you re right…the quarantine has make me slow !!!

just one question,i am trying to make my Google home say the current freezer temperature.It does but only the number and the unit ignoring the minus (-) symbol at the begining.

say("the small freezer temperature is"+SmallFreezer_Temperature.state+"something is wrong")

it just says for example “16 °C” but not “-16 °C”

Add an if statement to add the word minus ?

found the solution here https://community.openhab.org/t/solved-text-to-speech-tts-output-of-negative-numbers-in-german/116727

1 Like

I suspect it was being skipped due to its many ises

hyphen - ignored or a slight pause
negative
minus

Perhaps others in our imprecise language.