Detecting a freezer / appliance failure via a TPLink Smart Switch

I would like to share my config for how I use Home Assistant to detect a possible freezer failure.

I had searched in the forum for “Appliance Failure” with no success but eventually found the config items I was looking for.

We have had two freezers fail in the last 10 years with the loss of a lot of food. We are now growing and storing more food than ever, so we put a TP-Link HS110 switch on the freezer.

Now I want to know if the freezer is consuming power or not and alert me.

Step 1: Extract the day’s energy use from the switch sensor attributes:

sensor:
  - platform: template
    sensors:
      freezer_switch_kwh:
        friendly_name: "Freezer Today kWh"
        value_template: '{{ states.switch.freezer.attributes["today_energy_kwh"] | float }}'
        unit_of_measurement: 'kWh'

Step 2: Add a statistics sensor that covers a one hour period (approx) of freezer data:

sensor:
  - platform: statistics
    entity_id: sensor.freezer_switch_kwh
    name: freezer_energy
    sampling_size: 60
    precision: 3

The “sampling_size” pushes that data window out to about an hour while the “precision” lets me see kWh to 3 decimal places.

Step 3: Extract the “change” attribute in to a new sensor that gives the kWh change from the start of the hour to the current time:

sensor:
  - platform: template
    sensors:
      freezer_energy_change:
        value_template: "{{ state_attr('sensor.freezer_energy', 'change') }}"
        unit_of_measurement: 'kWh'

The three examples above can be joined under a single sensor entry in configuration.yaml:

sensor:
  - platform: template
    sensors:
      freezer_switch_kwh:
        friendly_name: "Freezer Today kWh"
        value_template: '{{ states.switch.freezer.attributes["today_energy_kwh"] | float }}'
        unit_of_measurement: 'kWh'
      freezer_energy_change:
        value_template: "{{ state_attr('sensor.freezer_energy', 'change') }}"
        unit_of_measurement: 'kWh'
  - platform: statistics
    entity_id: sensor.freezer_switch_kwh
    name: freezer_energy
    sampling_size: 60
    precision: 3

Step 4: Set up an alert to notify me during waking hours of a drop in the kWh over that hour in NodeRed:

[{"id":"3df5b2f1.224ace","type":"server-state-changed","z":"f1345c02.d1df8","name":"Freezer Power Consumption","server":"d18c62ac.c142a","version":1,"entityidfilter":"sensor.freezer_energy_change","entityidfiltertype":"exact","outputinitially":true,"state_type":"num","haltifstate":"0.03","halt_if_type":"num","halt_if_compare":"lt","outputs":2,"output_only_on_state_change":true,"x":160,"y":80,"wires":[["1ff7c528.09af4b"],[]]},{"id":"1ff7c528.09af4b","type":"time-range-switch","z":"f1345c02.d1df8","name":"Waking Hours","lat":"-37.1042","lon":"144.1162","startTime":"6:00","endTime":"23:00","startOffset":"0","endOffset":0,"x":400,"y":80,"wires":[["7c08be05.8ac65"],[]]},{"id":"7c08be05.8ac65","type":"api-call-service","z":"f1345c02.d1df8","name":"Alert","server":"d18c62ac.c142a","version":1,"service_domain":"notify","service":"home_assistant","entityId":"","data":"{\"title\":\"Alarm\",\"message\":\"The freezer may have failed.\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":630,"y":80,"wires":[[]]},{"id":"d18c62ac.c142a","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]

My freezer consumes about 0.060 kWh consistently over the day, except for midnight to 1am when the counter resets in the switch.

Therefore the NodeRed config looks for a state drop below 0.03 kWh and sends a notification, but only between 6am and 11pm, which is waking hours and when the freezer might be open. Also, freezers will be Ok overnight if they fail.

This is pretty simple and effective and I hope someone else finds this useful.

5 Likes

Hi.

Nice work!

Regardless this approach doesn’t have the need for any additional hardware and cost apart from the energy monitor, why not using RF/wifi/zigbee thermometers inside the freezer, giving a more accurate and resilient warning for a system failure? Giving that the temperature (directly) is the critical factor for preserving food, not necessarily its energy cost or usage (indirectly).

I had the bad experience of one fridge failure and the energy consumption I believe did not reduce significantly, as the compressor was always working but it lacked the gas to do its cycle properly.

Thanks.

Good points.

I guess I am guarding against previous problems.

And I’m also not paying $250 to $300 for a temperature sensor at this point.

Certainly, adding another sensor would round this out.