# Fan box delayed switch off

**URL:** <https://discourse.nodered.org/t/fan-box-delayed-switch-off/84114>\
**Category:** General\
**Created:** [29 December 2023 16:07 UTC](https://discourse.nodered.org/t/fan-box-delayed-switch-off/84114 "2023-12-29T16:07:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andries78](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@Andries78](https://discourse.nodered.org/u/Andries78)\
**Post date:** [29 December 2023 16:07 UTC](https://discourse.nodered.org/t/fan-box-delayed-switch-off/84114/1 "2023-12-29T16:07:10Z")

</div>

Good afternoon All,

(Apologies in advance for my English, which is not very good).

I am new with Node-Red and by following several tutorials I am trying to gain some knowledge of how Node-Red works.

However, I am now stuck with what I think is a very simple issue.

Who can help me on my way?

**First the situation sketch:**  
In the toilet I have a ventilation box that is on 24 hours a day.

- I would like to turn it off between 23:00 and 07:00.
- And furthermore only on if the toilet switch is on for longer than 1 minute.
- Does the switch turn off after 1 minute? Then turn it off after 10 minutes.

I tried to make one and other in Node-Red but it does not function how I thought it would.  
If the switch is on for more than 1 minute it works.  
But if the switch is on again immediately after 1 minute then the fan box turns off before that.  
What am I doing wrong?

With ESPHome, I use the following configuration:

```auto
esphome:
  name: ventilatiebox
  friendly_name: Ventilatiebox

switch:
  - platform: gpio
    name: "Ventilatiebox_light"
    pin: D4
    inverted: yes

binary_sensor:
  - platform: gpio
    pin:
      number: D3
      inverted: yes
      mode:
        input: true
        pullup: true
    name: "Toilet_Schakelaar"

```

And my Node-Red

 ![toilet-Ventilator](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/5/85dce9a2aab749bab363959a0db82988d13823aa.png)

Thank you in advance.  
Andries.

---

<div class="post-metadata">

**Author:** ![Andries78](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@Andries78](https://discourse.nodered.org/u/Andries78)\
**Post date:** [6 January 2024 22:00 UTC](https://discourse.nodered.org/t/fan-box-delayed-switch-off/84114/2 "2024-01-06T22:00:41Z")

</div>

Is there no one who recognizes this problem?

In short: If a switch is on for more than 1 minute, how can I run a fan for 10 minutes?(after switching off the switch)

Thank you in advance.  
Andries.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [7 January 2024 08:24 UTC](https://discourse.nodered.org/t/fan-box-delayed-switch-off/84114/3 "2024-01-07T08:24:48Z")

</div>

Not a HA user as with most people on this forum.

Here is a simple example of waiting 1min before sending `on`, and then waiting 10 mins before sending `off`. You will need to work out how to integrate with HA nodes.

```auto
[{"id":"6f8e56acbc13b7d0","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":110,"y":3100,"wires":[["d5d799af1498169b"]]},{"id":"6fc09fc714e6810d","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":110,"y":3180,"wires":[["d5d799af1498169b"]]},{"id":"db4d2eb55ff4b2bd","type":"debug","z":"d1395164b4eec73e","name":"debug 2463","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":3140,"wires":[]},{"id":"d5d799af1498169b","type":"trigger","z":"d1395164b4eec73e","name":"","op1":"","op2":"1","op1type":"nul","op2type":"num","duration":"1","extend":false,"overrideDelay":false,"units":"min","reset":"0","bytopic":"all","topic":"topic","outputs":1,"x":350,"y":3140,"wires":[["f354408d829c881e"]]},{"id":"f354408d829c881e","type":"trigger","z":"d1395164b4eec73e","name":"","op1":"on","op2":"off","op1type":"str","op2type":"str","duration":"10","extend":false,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":470,"y":3080,"wires":[["db4d2eb55ff4b2bd"]]}]

```

---

<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:** [7 March 2024 08:25 UTC](https://discourse.nodered.org/t/fan-box-delayed-switch-off/84114/4 "2024-03-07T08:25:25Z")

</div>

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