HowTo: Node Red - Fridge Door Monitoring Using Energy Consumption

In recent weeks, I have often had the problem that my freezer door did not close properly. As a result, at least one night the refrigerator door was not closed properly for almost seven hours.

When this happened to me again a few days later, I decided to do something about it. It would be enough for me to be informed if I left the refrigerator door open for too long again.

After a bit of experimentation I came up with the NodeRed code described below. With this (and a wifi enabled socket that is also able to measure the energy used) you can tell if the fridge door is closed or open by the energy consumption of the fridge.

The NodeCode continuously measures the power consumption (with the help of the socket) and detects when it is too high. This is typically the case when the refrigerator door is left open for too long, causing the temperature inside to rise, which in turn causes the refrigerator's refrigeration compressor to start more often or not to turn off at all.

More details and what you need to consider to build your own refrigerator monitoring is described in the following article.


Safety instructions

I know the following notes are always kind of annoying and seem unnecessary. Unfortunately, many people who knew "better" have lost eyes, fingers or other things due to carelessness or injured themselves. Data loss is almost negligible in comparison, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Because even the coolest project is not worth injury or other trouble.
https://www.nerdiy.de/sicherheitshinweise/

Affiliate links/advertising links

The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and make a purchase via this link, Nerdiy.de will receive a commission from the relevant online shop or provider. The price does not change for you. If you make your purchases via these links, you support Nerdiy.de in being able to offer other useful projects in the future. 🙂 


Requirements

Helpful articles:
So that you can install new nodes, NodeRed should of course already be installed.
How to prepare a RaspberryPi and then install NodeRed on it is described in the following articles.

The following three articles describe what needs to be done to prepare the RaspberryPi:
RaspberryPi – setup for nerdiys!
RaspberryPi – The first configuration!
RaspberryPi – Control the RaspberryPi via SSH

NodeRed – Installing NodeRed on the RaspberryPi
NodeRed – Install new nodes
NodeRed - import and export node code

Required tool:
-no-

Required material:

In the following list you will find all the parts you need to implement this article.


Install required nodes

No special nodes are actually needed for this flow. Most of them belong to the standard nodes of NodeRed. Only the dashboard node is needed to visualize the collected data. You can find more information about this in the article NodeRed - Create a user interface with dashboard nodes.


The function

First of all, this NodeCode is not yet perfect, but it has been working quite reliably for my refrigerator for a few weeks now.

The function is best explained with the help of the pictures below and a little explanation of how a refrigerator works.

A refrigerator cools the air inside with the help of a refrigeration compressor. This refrigeration compressor is automatically switched on and off via a thermostat when the air inside the refrigerator becomes/is too warm. This leads (for example in my refrigerator) to the fact that the refrigeration compressor is only about 30 minutes per hour really switched on. The rest of the time, the temperature inside the refrigerator is maintained due to the good thermal insulation of a refrigerator. Of course, these values can be different for other refrigerators. For example, if a refrigerator is better insulated, the refrigeration compressor does not need to start as often.

In any case, you can take advantage of the running time of the refrigeration compressor. Because if it is permanently too warm in the refrigerator (for example, due to an open door), the refrigeration compressor also remains switched on longer. If the temperature inside the refrigerator does not drop, this can even cause the refrigeration compressor to stay on permanently.

In turn, a switched-on refrigeration compressor can be recognized by the power consumption of the refrigerator. My refrigerator (for example) consumes about 80 to 100W when the refrigeration compressor is on. However, since it is only switched on for about 30 minutes per hour, this corresponds to a consumption of 40 to 50W per hour.

You may already realize that if you know what consumption is normally expected per hour and suddenly realize that the refrigerator's current consumption is higher, you can be pretty sure that it's due to a refrigeration compressor that has been running too long and thus an open refrigerator door.

The problem:

The detection over the past average consumption is very slow.

In the area marked in red with a 1, you can see the consumption of my refrigerator with the door open. You can see that the consumption is almost consistently around 80 to 100W.

In the same area there is also a slightly darker blue line, which represents the average energy consumption in this period.

As you can see there, the average energy consumption is increasing. But unfortunately very slowly. Reliable detection would therefore either be very late or not very reliable.

The solution

After a few more experiments, I found a better way to detect the refrigeration compressor duty cycle. If you scan the energy consumption for possible edges you can find out quite reliably when the refrigeration compressor is switched on and off. Once you have these two times, you also know the running time of the refrigeration compressor.

Now you can monitor the duty cycle according to a similar principle as before the energy consumption: If the refrigeration compressor is switched on significantly longer than the average duty cycle, you can assume that this is due to an open refrigerator door.

This method does not detect an open refrigerator door "immediately" but (in my refrigerator) at least within 30 to 45 minutes. This is enough to save at least a few items of food from defrosting.


The socket

In order to measure the energy consumption of your refrigerator at all, you need a socket or an adapter that sends the current energy consumption of your refrigerator to your smartHome. I used a WiFi adapter with energy measurement, which I also flashed with the Tasmota firmware. The NodeRed code receives the data later via MQTT.

How you can flash an adapter with the Tasmota firmware and configure it a bit better is partly described in the article Tasmota - Flash firmware with TuyaConvert described.


Dashboard displays

When you import the NodeCode below into your NodeRed configuration, the following views will also be added to your dashboard.

In this view, you will see a text field at the top of the screen that indicates whether there are already enough readings to detect an abnormal consumption value based on the average consumption.

In the middle area, the past and average energy consumption of your refrigerator is displayed.

In the lower area, the switch-on phases of the refrigeration compressor determined from the energy consumption can be seen. The duration is entered in seconds. The current, previous and average duty cycle is entered in each case.

In addition to the history data above, you will also see the data on the left.

At the top you can see the past average consumption of your refrigerator

In the middle the current consumption of your refrigerator

The last determined duty cycle of your refrigeration compressor is displayed at the bottom.


Insert Node Code

The NodeCode below contains everything necessary to evaluate the energy consumption of your refrigerator according to the scheme described above and to send you a notification via Pushbullet if necessary. How to add NodeCode to your NodeRed configuration is described in the article NodeRed - import and export node code described.

Of course, in order for Pushbullet to forward the notification to you, you need to configure the Pushbullet Node accordingly. You can find tips on how to do this in the article NodeRed - Send pushbullet messages on events

Some more info:
The pushbullet message is triggered when the current duty cycle is 1.8 times the average duty cycle. This means that the abnormal duty cycle will only be detected after 1.8 times the average refrigeration compressor duty cycle of your refrigerator has elapsed. With an average duty cycle of 30 minutes, you would only receive an indication of an abnormal duty cycle after 54 minutes.

You can of course also reduce this value. The only disadvantage is that it can lead to a "false alarm". If you want, just try out different values. This detection is implemented in the "checkForAbnormalValues" function node.

You can find the NodeCode in the Nerdiy-Git under the following link:

https://github.com/Nerdiyde/NodeRedSnippets/blob/master/snippets/fridge_door_monitoring_by_energy_consumption.json


Have fun with the project

I hope everything worked as described for you. If not or you have questions or suggestions please let me know in the comments. I will then add this to the article if necessary.
Ideas for new projects are always welcome. 🙂

PS Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you think it's cool that I share the information with you, I would be happy about a small donation to the coffee fund. 🙂

Buy Me a Coffee at ko-fi.com       

4 comments

  1. Wouldn't a magnetic contact on the door have done the trick, which then triggers Pushbullet?

    But still a nice flow….

    1. Yep, you're absolutely right. The whole thing was born out of the "necessity" that I already had the socket at home so I didn't have to buy any new hardware 🙂
      Thank you 🙂

  2. Hello!
    I'm just getting started with NodeRed. So probably a few simple stupid questions. I think Smooth comes in via the node-red-node-smooth palette. Then all values come in one after the other as a string via the Tasmota sensor:
    ——————-
    "{"Time": "2021-01-25T11:44:20″, "ENERGY":{"TotalStartTime": "2020-12-11T17:29:39″, "Total":15.316, "Yesterday":0.288, "Today":0.103, "Period":0, "Power":0, "ApparentPower":0, "ReactivePower":0, "Factor":0.00, "Voltage":0, "Current":0.000}}"
    —————————-
    Where do you take the thong apart? Unfortunately I haven't figured that out yet.

    Stefan

    1. Hey Stefan,
      oh that's not a stupid question. I think this is quite typical when you need/want to understand what someone else wrote/built. It's the same with programming 🙂
      I hope I have understood you correctly. Firstly, I rebuild the messages in the node called "Change: 2rules" in the image. The information from the message msg.payload.ENERGY.Today is copied to the message msg.Energy. In addition, the content of msg.payload.ENERGY.Power is copied to msg.payload. A large part of the processing is then implemented in the "checkValue" node. I hope this helps you. Otherwise feel free to ask. 🙂
      Best regards
      Fabian

Kommentar hinterlassen

Your email address will not be published. Erforderliche Felder sind mit * markiert

This site uses Akismet to reduce spam. Learn how your comment data is processed.