# Detect if fridge door (contcat sensor) stays open

**URL:** https://discourse.nodered.org/t/detect-if-fridge-door-contcat-sensor-stays-open/27835
**Category:** General
**Created:** [5 June 2020 14:02 UTC](https://discourse.nodered.org/t/detect-if-fridge-door-contcat-sensor-stays-open/27835 "2020-06-05T14:02:56Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![P4W3L](https://avatars.discourse-cdn.com/v4/letter/p/958977/32.png) [@P4W3L](https://discourse.nodered.org/u/P4W3L)
#### Post date: [5 June 2020 14:02 UTC](https://discourse.nodered.org/t/detect-if-fridge-door-contcat-sensor-stays-open/27835/1 "2020-06-05T14:02:56Z")

</div>

Hi,

typical problem (at least for me 🙂): The fridge door stays open to long or is not properly closed.

My idea: Adding a contact sensor to the fridge door and create a simple flow which detects it and sends a warning to our google home.

I don't have the sensors yet, but already wanted to play around with a flow.

My first idea was super simple:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/0/e06dce2a74e7ddc89bf2aa475ec3d9a700f2e7d6.png)

The problem with this flow is, if the door is closed and opened while the delay is still active and stays open for a second after the delay is done, there will be a false alarm.

Another idea was this:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/0/a0f693504e572fb9ccb00547f2d136ed950bdee3.png)

This also doesn't work if multiple "CLOSE" and "OPEN" are send.

Does someone has an idea how I can implement such a behaviour?

---

<div class="post-metadata">

### Author: ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)
#### Post date: [5 June 2020 14:09 UTC](https://discourse.nodered.org/t/detect-if-fridge-door-contcat-sensor-stays-open/27835/2 "2020-06-05T14:09:40Z")

</div>

I think "CLOSE" should always reset the timer and an "OPEN" should start a new timer from scratch so to say

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/5/f5d89cccaff04fbdfc6035e904c988eaaf7d148b.png)

---

<div class="post-metadata">

### Author: ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)
#### Post date: [5 June 2020 14:13 UTC](https://discourse.nodered.org/t/detect-if-fridge-door-contcat-sensor-stays-open/27835/3 "2020-06-05T14:13:40Z")

</div>

Would this work using trigger node? (tested only quickly but does was @krambriw suggested above)

```auto
[{"id":"a9682048.d1fef","type":"inject","z":"bf210454.b85538","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"open","payloadType":"str","x":90,"y":140,"wires":[["6664e7b7.ccf068"]]},{"id":"7319e2e7.1324bc","type":"debug","z":"bf210454.b85538","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":410,"y":180,"wires":[]},{"id":"575223cd.9cecfc","type":"inject","z":"bf210454.b85538","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"close","payloadType":"str","x":90,"y":220,"wires":[["6664e7b7.ccf068"]]},{"id":"6664e7b7.ccf068","type":"trigger","z":"bf210454.b85538","name":"","op1":"","op2":"DOOR ALARM","op1type":"str","op2type":"str","duration":"5","extend":false,"units":"s","reset":"close","bytopic":"all","topic":"topic","outputs":2,"x":240,"y":180,"wires":[[],["7319e2e7.1324bc"]]}]

```

I've setup the same thing for our freezer as my girlfriend often fails to close it properly. A Pushover message is then sent to both of our phones. 😄

---

<div class="post-metadata">

### Author: ![P4W3L](https://avatars.discourse-cdn.com/v4/letter/p/958977/32.png) [@P4W3L](https://discourse.nodered.org/u/P4W3L)
#### Post date: [5 June 2020 14:23 UTC](https://discourse.nodered.org/t/detect-if-fridge-door-contcat-sensor-stays-open/27835/4 "2020-06-05T14:23:01Z")

</div>

I tested this solution, but unfortunately this doesn't as expected.  
If I send multiple "open", "close", "open", "close", I also receive multiple of them.

---

<div class="post-metadata">

### Author: ![P4W3L](https://avatars.discourse-cdn.com/v4/letter/p/958977/32.png) [@P4W3L](https://discourse.nodered.org/u/P4W3L)
#### Post date: [5 June 2020 14:23 UTC](https://discourse.nodered.org/t/detect-if-fridge-door-contcat-sensor-stays-open/27835/5 "2020-06-05T14:23:32Z")

</div>

This works perfect for me. Thank you very much.

---

<div class="post-metadata">

### Author: ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)
#### Post date: [5 June 2020 14:29 UTC](https://discourse.nodered.org/t/detect-if-fridge-door-contcat-sensor-stays-open/27835/6 "2020-06-05T14:29:27Z")

</div>

Great! Please mark the question solved so others don't need to check if there's still an open question. 🙂

Edit: it was already handled.

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [5 June 2020 15:00 UTC](https://discourse.nodered.org/t/detect-if-fridge-door-contcat-sensor-stays-open/27835/7 "2020-06-05T15:00:49Z")

</div>

Glad to see that your problem is solved. I can recommend the **GS-WDS07** door sensors, they give an "open" and "closed" signal, not all door sensors do. They are 433 Mhz sensors.

---

<div class="post-metadata">

### Author: ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)
#### Post date: [5 June 2020 15:07 UTC](https://discourse.nodered.org/t/detect-if-fridge-door-contcat-sensor-stays-open/27835/8 "2020-06-05T15:07:05Z")

</div>

Good to hear more endorsement for them as I have 5 of them on their (presently slow) way from China! The only door sensors that I have in use are two prohibitively expensive Z-wave ones from the beginning of my automation hobby. Besides them I have one of those frustrating single way only triggering sensors from Sonoff (useless).

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [5 June 2020 15:14 UTC](https://discourse.nodered.org/t/detect-if-fridge-door-contcat-sensor-stays-open/27835/9 "2020-06-05T15:14:29Z")

</div>

Mine came from there too! 🙂 I was pleasantly surprised by how well they work.

---

<div class="post-metadata">

### Author: ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)
#### Post date: [10 June 2020 15:21 UTC](https://discourse.nodered.org/t/detect-if-fridge-door-contcat-sensor-stays-open/27835/10 "2020-06-10T15:21:15Z")

</div>

This is more or less off topic, sorry!

@ghayne I received the door sensors today. My plan is to listen them using a Sonoff RF Bridge (flashed with Espurna).

I noticed the sensors send a rolling code but the last 6 digits seemed to be fixed for each event. Is this how you're interpreting the sensor/event or is there a fancier way?

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [10 June 2020 16:02 UTC](https://discourse.nodered.org/t/detect-if-fridge-door-contcat-sensor-stays-open/27835/11 "2020-06-10T16:02:31Z")

</div>

I am using a RF Bridge flashed with Tasmota and get this in the console:

```auto
16:52:56 MQT: tele/rfbridge1/RESULT = {"Time":"2020-06-10T16:52:56","RfReceived":{"Sync":14080,"Low":490,"High":1350,"Data":"E07A0E","RfKey":"None"}}
16:52:59 MQT: tele/rfbridge1/RESULT = {"Time":"2020-06-10T16:52:59","RfReceived":{"Sync":14000,"Low":500,"High":1400,"Data":"E07A0A","RfKey":"None"}}

```

E07A0E is closed  
E07A0A is opened

I use this change node attached to a MQTT in node subscribed to

```auto
tele/rfbridge1/RESULT

```

```auto
[{"id":"98294a1e.113d88","type":"change","z":"bfe6a9c4.a758a8","name":"","rules":[{"t":"move","p":"payload.RfReceived.Data","pt":"msg","to":"payload","tot":"msg"},{"t":"change","p":"payload","pt":"msg","from":"E6C60E","fromt":"str","to":"Front door is closed","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"E6C60A","fromt":"str","to":"Front door is open","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"E2CE0E","fromt":"str","to":"Back door is closed","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"E2CE0A","fromt":"str","to":"Back door is open","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":100,"wires":[["28a8d473.3f7e6c","ff568651.21b848"]]}]

```

---

<div class="post-metadata">

### Author: ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)
#### Post date: [10 June 2020 16:16 UTC](https://discourse.nodered.org/t/detect-if-fridge-door-contcat-sensor-stays-open/27835/12 "2020-06-10T16:16:27Z")

</div>

Thanks! It seems Tasmota is smarter and can interpret the data. I believe E07A0x is the last part of the message. Espurna sends all the data as a single string like 36C401D60546E4050A. xxxxxE4050A is open, xxxxxE4050E is closed in the case of one of the sensors. I'll just create a switch with a "string contains" evaluation like I had to do with Sonoff PIR sensors. 👍

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [24 June 2020 16:16 UTC](https://discourse.nodered.org/t/detect-if-fridge-door-contcat-sensor-stays-open/27835/13 "2020-06-24T16:16:30Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
