# Easy flow but difficult for me

**URL:** <https://discourse.nodered.org/t/easy-flow-but-difficult-for-me/21796>\
**Category:** General\
**Created:** [16 February 2020 14:17 UTC](https://discourse.nodered.org/t/easy-flow-but-difficult-for-me/21796 "2020-02-16T14:17:50Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![atijaja](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@atijaja](https://discourse.nodered.org/u/atijaja)\
**Post date:** [16 February 2020 14:17 UTC](https://discourse.nodered.org/t/easy-flow-but-difficult-for-me/21796/1 "2020-02-16T14:17:50Z")

</div>

i just started with node red.  
I wanted to create a flow but can't get any further.  
I use node red in hassio

the process should be

if the humidity for over 15 minutes is over 65%.  
and the window closed (OFF)  
then turn on the dehumidifier

if the humidity is below 50% then switch off the dehumidifier

```auto
[{"id":"a8c1e633.29ad","type":"function","z":"b09c9f8d.e326a8","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"x":260,"y":600,"wires":[[]]}]

```

what i'm missing is an **AND** node  
And a node that has a condition pending for a certain time

if possible without a function node

i hope it was understandable my english is not good.  
Thank you very much

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 February 2020 14:54 UTC](https://discourse.nodered.org/t/easy-flow-but-difficult-for-me/21796/2 "2020-02-16T14:54:07Z")

</div>

There are boolean nodes (search the node red flows site) but if the values are coming in on different paths then you may need to use a Join node to get them into one message. See [this post](https://cookbook.nodered.org/basic/join-streams) in the cookbooks. Also worth looking through the cookbook to see what is there. Also all the node red docs of course. You can use a Trigger node with a bit of extra logic to do the 15 min bit, have a look at this post earlier today for how to do it for a slightly simpler case. See what you can get going and then come back if still stuck.

> [@Queue or gate or function](https://discourse.nodered.org/t/queue-or-gate-or-function/21774):
>
> Need some advice on the direction that I need to search for. I have a MQTT node with msg.payload ON that stays ON for 3 sec and then goes OFF until MQTT sends out a new message. (Motion sensor) Sometimes when the sun is shining harder the motion sensor is triggered and I get false messages. So I would like to delay or trigger or gate or Queue. I don't know. So only when MQTT sends longer than 5 seconds there has to be an output otherwise the message needs to be skipped. Delay works but does…

---

<div class="post-metadata">

**Author:** ![rgerrans](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@rgerrans](https://discourse.nodered.org/u/rgerrans)\
**Post date:** [16 February 2020 16:45 UTC](https://discourse.nodered.org/t/easy-flow-but-difficult-for-me/21796/3 "2020-02-16T16:45:57Z")

</div>

> [@atijaja](#):
>
> what i'm missing is an **AND** node

To create an AND node, you just put your nodes in series. So for your specific use case, you could use a Trigger node with a 15 minute delay (resetting if humidity \< 65%) that sends your "on" message, followed by a Switch node to check the status of your window (you can use a flow/global context to store the current state of the window).

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 February 2020 17:46 UTC](https://discourse.nodered.org/t/easy-flow-but-difficult-for-me/21796/4 "2020-02-16T17:46:21Z")

</div>

The problem with that is that if the window status becomes valid after the humidity signal triggers then you won't get an event, unless the humidity one keeps sending messages. For situations like this I think it is less confusing to Join the two messages and do the logic, then any time either of them changes the state of the other one is already known.

---

<div class="post-metadata">

**Author:** ![atijaja](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@atijaja](https://discourse.nodered.org/u/atijaja)\
**Post date:** [16 February 2020 17:50 UTC](https://discourse.nodered.org/t/easy-flow-but-difficult-for-me/21796/5 "2020-02-16T17:50:04Z")

</div>

Thank you  
I have solved it now.

```auto
[{"id":"c6613d7b.6862c","type":"api-current-state","z":"b09c9f8d.e326a8","name":"Window","server":"c6b27d15.fbeba","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.fenster_bad","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":520,"y":380,"wires":[["49ce8dd7.ee3284"],["21b97b48.39ac24"]]},{"id":"c6b27d15.fbeba","type":"server","z":"","name":"Home Assistant"}]

```

I'm still not sure if everything is working properly

---

<div class="post-metadata">

**Author:** ![rgerrans](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@rgerrans](https://discourse.nodered.org/u/rgerrans)\
**Post date:** [16 February 2020 18:24 UTC](https://discourse.nodered.org/t/easy-flow-but-difficult-for-me/21796/6 "2020-02-16T18:24:29Z")

</div>

> [@Colin](#):
>
> For situations like this I think it is less confusing to Join the two messages and do the logic

Good call if the use case requires either situation to trigger the "OFF" event, which is not how I read it. Also would allow you to avoid the use of context variables, though you have to go through the extra step of defining the msg.parts. You'd still need to put the various checks post join to trigger down an "ON" or "OFF" path, or you could use - [node-red-contrib-match (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-match) to do a single node to check status of all related messages.

You can also just setup checks for an "OFF" path of either below 50% humidity OR the window opening as "OFF" triggers and avoid the need for Join.

Like everything in Node-Red, lot's of different ways to set things up.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 February 2020 20:13 UTC](https://discourse.nodered.org/t/easy-flow-but-difficult-for-me/21796/7 "2020-02-16T20:13:00Z")

</div>

> [@rgerrans](#):
>
> defining the msg.parts

Not necessary with the Join node in key/value pair mode

---

<div class="post-metadata">

**Author:** ![atijaja](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@atijaja](https://discourse.nodered.org/u/atijaja)\
**Post date:** [16 February 2020 20:35 UTC](https://discourse.nodered.org/t/easy-flow-but-difficult-for-me/21796/8 "2020-02-16T20:35:46Z")

</div>

> [@rgerrans](#):
>
> Good call if the use case requires either situation to trigger the "OFF" event, which is not how I read it.

yes one of the conditions should be sufficient to switch off.

Getting into node red and working with home assistant is not easy for me. I am too old and have no experience with programming so far.  
But i find it very interesting to realize my own ideas.  
many thanks for the help

---

<div class="post-metadata">

**Author:** ![rgerrans](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@rgerrans](https://discourse.nodered.org/u/rgerrans)\
**Post date:** [17 February 2020 01:54 UTC](https://discourse.nodered.org/t/easy-flow-but-difficult-for-me/21796/9 "2020-02-17T01:54:45Z")

</div>

> [@atijaja](#):
>
> Getting into node red and working with home assistant is not easy for me.

Once you get the basics and get a couple of flows working, the logic starts making sense and it gets easier
