Caught the freezer with the door open

So a few days ago I noticed that some piece of packaging was stuck in the freezer door which prevented it from fully closing. It would usually beep in that case but it was only a tiny bit open.

Just want to share how that looked like, YFMV (your freezer may vary).

I have a Shelly Plug-S on that fridge to measure the energy consumption so I checked the history:

Pretty easy to see when the problem started! So an automation to the rescue which alerts my mobile if that happens again, something like that:

alias: kitchen_fridge_open
description: "Notify if power-consumption is high for too long"
trigger:
  - platform: numeric_state
    entity_id: sensor.kitchen_shelly_plug_fridge_current_consumption
    for:
      hours: 2
      minutes: 0
      seconds: 0
    above: 50
condition: []
action:
  - service: notify.mobile_app_oneplus
    data:
      message: The fridge or freezer in the kitchen is probably open!
mode: single
2 Likes

You should know that the for option, in your automationā€™s Numeric State Trigger, is reset whenever you restart Home Assistant or merely execute Reload Automations (which occurs transparently whenever you click the Automation Editorā€™s ā€˜Saveā€™ button).

Your for option is set to 2 hours. Letā€™s say it has already triggered when the temperature increased above 50 and 1 hour has already elapsed ā€¦ and then Reload Automations is executed. Its countdown will be reset (i.e. the 1 hour that elapsed is lost).

This may change in the future. Thereā€™s a pending improvement that will make Reload Automations only reload new/modified automations, not existing/unmodified automations. Until itā€™s implemented, you should be aware of this potential vulnerability.

Is there any way around this?
It would mostly still be useful as I donā€™t reload the config 24x7 so it would still catch the open door, only a bit later maybe. But itā€™s not very niceā€¦

1 Like

You donā€™t have to ā€œreload the configā€ to make it happen. All you need to do is make one change in an automation with the Automation Editor and click Save. Thatā€™s sufficient to terminate all automations that are in-progress (like a for option that is in the process of counting down the time).

Currently, thereā€™s no simple workaround to protect the for option from this vulnerability other than to minimize the amount of time it counts (if feasible). For example, if you reduced it from 2 hours to 30 minutes, you have reduced its chance of it being terminated by a reload.

Canā€™t the history_stat not be used instead?

Never tried to use that function myself, but I just stumbled on it in the past.

I would use a timer helper with restore set to true. I have a similar automation based on temperature though. I had a conversation within the last week about this scenario(leaving a fridge or freezer open) and an alert is definitely a worthwhile addition. The person I was talking to lost a LOT of food.

I noticed you arenā€™t doing an alert in case it ISNā€™T running for a prolonged period. You may regret that choice if the compressor motor goes out. Consider that as an improvement.

A timer helper could work. But probably with a set of shorter timers: if I set a timer to 2 hrs as soon as the generator starts it might as well have stopped and started again after 2 hrs and give a false alarm. Itā€™s not regular enough.
But I could use multiple steps with e.g. 15 minute timers that increase a counter each time they find the compressor is running. If it hits 8 that would be the trigger to notify. Just a thought, not sure if this would be feasibleā€¦

And thanks for the suggestions to notify on ā€œisnā€™t runningā€. I forgot about that :smiley:

You could also do this automation with a different framework to have it more independent. like appdaemon if you are a bit familiar with python

Probably a good idea. I have a few things implemented as a python-script as it proved too complicated to do in jinja so that shouldnā€™t be a problem. Thx!

I put one of those cheap BLE temperature + humidity sensors in both my freezer and my fridge and set alarms on HA for when the temperature is outside an expected rangeā€¦ I could find a couple of times where the door was left openā€¦
And the Bluetooth signal can go thru the metal walls pretty fine in my case.

Can you post an example of how you are using a timer to detect when an entityā€™s value is above a threshold for X hours?

Create a timer helper and make sure you check ā€œrestoreā€.

Here is an automation that starts the timer if a temperature goes above 0.

alias: Demo Automation
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.temperature_2
    for:
      hours: 0
      minutes: 0
      seconds: 0
    above: 0
condition: []
action:
  - service: timer.start
    data:
      duration: "00:01:00"
    target:
      entity_id: timer.test_timer
mode: single

Now we want to pause the timer if the temperature goes back below 0.

alias: Demo Automation2
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.temperature_2
    for:
      hours: 0
      minutes: 0
      seconds: 0
    below: 0
condition: []
action:
  - service: timer.pause
    data: {}
    target:
      entity_id: timer.test_timer
mode: single

Then of course we want to know about it if the timer finishes.

alias: Demo Automation3
description: ""
trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.test_timer
condition: []
action:
  - service: notify.mobile_app_moto_g_stylus
    data:
      message: Timer finished
mode: single

Those are used frequently by others I know. I believe inkbird and Govee. Some people are even flashing custom firmware on them. I opted for outdoor weather sensors. The important thing is getting a sensor that can handle the cold. Iā€™ve found the ones that use coin cells are far less reliable. I believe the coin cells themselves are the weak point so I only get AAA or AA sensors for freezers.

Iā€™m using Govee sensors. Iā€™ve two different models just because when I bought those I wanna play with the different models, but both are working just fine, with the one purely BLE having a bit more stable connection compared to the one Wi-Fi + BLE.
The freezer and the fridge are side by side, with the freezer in the far side (1m more) compared to my RPi where Home Assistant is running, with a couple of rooms in the between.

1 Like

Iā€™m messing around with power monitoring on ours in addition to temperature monitoring. I was able to catch unusual activity. The freezer was running for much longer then usual even though I didnā€™t get a temperature alert. Possibly a faulty seal.

1 Like

Yeah, monitor the power consumption is a great idea. If the motor compensate the leaking you will never capture with the temperature sensor only.

You didnā€™t get any temperature changes?

Is there any particular reason why you chose to pause instead of cancel the timer?

Looking at the for optionā€™s behavior:
If the temperature were to decrease below 0 it would serve to stop (and reset) the for optionā€™s countdown. It wouldnā€™t pause it because it never resumes its previous countdown.

alias: kitchen_fridge_open
description: "Notify if power-consumption is high for too long"
trigger:
  - id: above
    platform: numeric_state
    entity_id: sensor.kitchen_shelly_plug_fridge_current_consumption
    above: 50
  - id: below
    platform: numeric_state
    entity_id: sensor.kitchen_shelly_plug_fridge_current_consumption
    below: 50
  - id: finished
    platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.kitchen_fridge
condition: []
action:
  - choose:
      - conditions: '{{ trigger.id == 'finished' }}'
        sequence: 
          - service: notify.mobile_app_oneplus
            data:
              message: The fridge or freezer in the kitchen is probably open!
      - conditions: '{{ trigger.id == 'above' }}'
        sequence: 
          - service: timer.start
            target:
              entity_id: timer.kitchen_fridge
            data:
              duration: "02:00:00"
      - conditions: '{{ trigger.id == 'below' }}'
        sequence: 
          - service: timer.cancel
            target:
              entity_id: timer.kitchen_fridge
    default: []
mode: single
timer:
  kitchen_fridge:
    duration: "02:00:00"
    restore: true

NOTE

I believe thereā€™s a pending enhancement to Home Assistant that will ensure a Reload Automations only acts on new/modified automations and not unmodified/in-progress automations. That means an automation with a trigger employing for will not be reset by Reload Automations (but it will continue to be reset by a restart).

EDIT

The PR is implemented in the next release: 2022.11.0. Therefore the for option will be immune to Reload Automations (but not a restart). Use the timer-based example only if you want to also make the automation immune to restarts.

You could also put the temperature sensor near the outside radiator. This way you avoid all the environmental problems and lack of power supply and you are still able to tell very accurately if the compressor is running or not.

1 Like

The freezer was doing a great job keeping the temperature steady but the compressor was running constantly. Iā€™ve been considering the possibility there is a bubble in the coolant. Itā€™s back to normal.