Temperature monitoring: warn when the fridge is too cold / warm

One time our fridge door wasn’t closed properly overnight, and it ruined almost everything inside the fridge. Replacing all the food inside the fridge was not cheap!

Using a door sensor may work, but I prefer using a thermometer to monitor the actual temperature inside the fridge.

I use a Xiaomi Aqara Thermometer sensor (a battery powered Zigbee device) + zigbee2mqtt. This sensor seems to happily live inside my fridge. I happen to have a Zigbee router within 5 metres from the fridge, so that might help with the signal level inside the fridge.

Sometimes (rarely in my case) the fridge may be empty and become too cold - it’s an analog thermostat with a dial, not the fancy digital control, so I’m interested in monitoring its temperature making sure nothing is frozen or spoils.

So here is a simple rule written in JRuby to issue a voice warning via Amazon Echo TTS.

It can be adjusted to use Google TTS, sending an email, blinking a light or whatever you may fancy. My Google TTS hasn’t been working since Openhab 3.2M5, and since I have amazon echo devices, and it’s easy to use and seemingly more reliable, that’s what I’m using.

require 'openhab'

rule 'Fridge Temperature' do
  description 'Warn when the fridge temperature is abnormal for more than 5 mins'
  changed Fridge_Temperature
  triggered do |item|
    if item.between?('2 °C', '6 °C') # the acceptable range depends on the placement of the thermometer
      timers[item]&.each(&:cancel)
      next
    end

    next if timers[item] # do not reschedule the timer

    after(5.minutes, id: item) do |timer|
      message = "Warning, the #{item.id} is not within normal parameters. "
      message << "The #{item.id} is currently #{item.state.format('%.1f %unit%')}"
      gEchoTTS << message
      timer.reschedule unless timer.cancelled?
    end
  end
end
1 Like