# Notification from node red

**URL:** <https://discourse.nodered.org/t/notification-from-node-red/44057>\
**Category:** General\
**Created:** [12 April 2021 18:08 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057 "2021-04-12T18:08:38Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Alex95](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@Alex95](https://discourse.nodered.org/u/Alex95)\
**Post date:** [14 April 2021 16:42 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057/21 "2021-04-14T16:42:58Z")

</div>

So the debug of COM5 is following:

 ![debugcom5](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/7/775a4001fcbac03aeca4f835831bdcbe6fd9b1a0.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [14 April 2021 16:49 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057/22 "2021-04-14T16:49:30Z")

</div>

So that’s the third different message coming out of the coms node. Are there any more types?

---

<div class="post-metadata">

**Author:** ![Alex95](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@Alex95](https://discourse.nodered.org/u/Alex95)\
**Post date:** [14 April 2021 16:52 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057/23 "2021-04-14T16:52:52Z")

</div>

No there aren't , always the same types. Actually only msgid change every time but i don't know if it's important.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [14 April 2021 17:07 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057/24 "2021-04-14T17:07:49Z")

</div>

In your "function email" `function` just before the line:  
`msg.payload="time" + d + message + msg.payload;`  
insert the following  
`node.warn(msg.payload)`  
and run the flow - (note you can make it easier to debug by disconnecting the `serial in` node and adding an inject that puts '55,22,0` in the msg.payload.)

Then run the flow and tell me what you see

---

<div class="post-metadata">

**Author:** ![Alex95](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@Alex95](https://discourse.nodered.org/u/Alex95)\
**Post date:** [14 April 2021 17:48 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057/25 "2021-04-14T17:48:23Z")

</div>

So, i did the change and i have gollowing result:

 ![debug with change](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/4/142f87a6374060924f81184df73f254007a92095.png)

Unfortunately the message is still "water level normal" altough the mmwaterValue is 9mm.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [14 April 2021 19:25 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057/26 "2021-04-14T19:25:17Z")

</div>

Please make a copy of your "Trigger Alarm" `function` node so you have a back up. Then edit the one in the flow and use this (I've just added a couple `node.warn()` statements)

Attach an `inject` node to the "Function LoRa" `function` node with a payload of "54,22,0" and deploy and press the `inject` node's button.

Examine the debug output and tell me what you see happening and why.

---

<div class="post-metadata">

**Author:** ![Alex95](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@Alex95](https://discourse.nodered.org/u/Alex95)\
**Post date:** [14 April 2021 19:54 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057/27 "2021-04-14T19:54:22Z")

</div>

i did that but maybe i shoud change the code of function because i ave the following error:

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

Lora function has this code:

![lora function](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/c/1c8532e6cb2288c5364b89f5750d2249dee49d3c.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [14 April 2021 20:01 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057/28 "2021-04-14T20:01:15Z")

</div>

> [@zenofmud](#):
>
> Attach an `inject` node to the "Function LoRa" `function` node with a payload of "54,22,0"

Why did you create three `inject` nodes each with one of the values???

---

<div class="post-metadata">

**Author:** ![Alex95](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@Alex95](https://discourse.nodered.org/u/Alex95)\
**Post date:** [14 April 2021 20:15 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057/29 "2021-04-14T20:15:38Z")

</div>

for some reason it's wrong to put 1 inject with 3 numbers:

![55,22,0](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/2/42bc8171d49685ea38adecac5759dfb5c6f97427.png)  
 ![inject 55](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/7/e7903c0612c102eb8a35a7ac13695730e9937bc7.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [14 April 2021 20:19 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057/30 "2021-04-14T20:19:48Z")

</div>

> [@zenofmud](#):
>
> a payload of "54,22,0"

You see the quotes around the three numbers?? That tells you it is a string not a number so you should use the a/z option not the 1/9 option

---

<div class="post-metadata">

**Author:** ![Alex95](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@Alex95](https://discourse.nodered.org/u/Alex95)\
**Post date:** [14 April 2021 20:25 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057/31 "2021-04-14T20:25:01Z")

</div>

O yes you're right. So i did that and i have no any result:

 ![success](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/4/5429cc92e3b7f18eaed0e6cb6e717e6774a14dea.png)

By the way i didn't change anything in the code of Lora function.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [14 April 2021 20:50 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057/32 "2021-04-14T20:50:25Z")

</div>

I apologize, I neglected to give you the "Trigger Alarm" node with the changes

```auto
[{"id":"eb603aed.51e128","type":"function","z":"41cc7a8d.3919e4","name":"Trigger Alarm","func":"var mmwaterValue=msg.payload;\nvar alarm_flag=context.get(\"alarm_flag\");\n\nif (typeof alarm_flag==\"undefined\")\nalarm_flag=false;\nnode.warn(\"debug1\");\n\nif (mmwaterValue>3 && !alarm_flag)\n{\n node.warn(\"debug2\");\n alarm_flag=true;\n msg.alarm=1;\n context.set(\"alarm_flag\",alarm_flag);\n return msg;\n}\nif (mmwaterValue<=3 && alarm_flag)\n{\n node.warn(\"debug3\");\n alarm_flag=false;\n msg.alarm=0;\n context.set(\"alarm_flag\",alarm_flag);\n return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":540,"y":320,"wires":[["372cfca1.f56a74","3d0a15e4.331e6a"]]}]

```

---

<div class="post-metadata">

**Author:** ![Alex95](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@Alex95](https://discourse.nodered.org/u/Alex95)\
**Post date:** [14 April 2021 21:14 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057/33 "2021-04-14T21:14:41Z")

</div>

It's ok don't worry. So, now my result is this:

 ![new result](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/e/8eda1d233fdd48ce1a84af2d46cd2b7f468d41cf.png)

Is almost the same with the previous ( i put the trigger alarm with your changes).

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [14 April 2021 21:49 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057/34 "2021-04-14T21:49:16Z")

</div>

So have you looked at the debug statements and looked where they came from in your code?  
Can you tell me why some of the node.warn() statements worked and some didn’t?

Look at your code!

---

<div class="post-metadata">

**Author:** ![Alex95](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@Alex95](https://discourse.nodered.org/u/Alex95)\
**Post date:** [14 April 2021 22:14 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057/35 "2021-04-14T22:14:47Z")

</div>

Yes i can see that. Debug 2 and debug 3 are not worked but i don't know why. Actually when i put my water sensor 1 mm ,then had to have debug 3 as a resault but i don't. Unfortunately i don't know why happen this. It's very strange.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [15 April 2021 00:24 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057/36 "2021-04-15T00:24:40Z")

</div>

It's not strange at all. The program is working exactly the way you 'told' it to work, just not the way you 'want' it to work, But now you have an inside as to what is gong on.

What needs to happen to get eithor 'debug 2' or 'debug 3' to show up?  
Maybe you want to use a `node.warn()` to display a variable or maybe two node.warn() to display a second variable.

If you read the documentation about functions ([Writing Functions : Node-RED](https://nodered.org/docs/user-guide/writing-functions)) it will show you how to do it.

---

<div class="post-metadata">

**Author:** ![Alex95](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@Alex95](https://discourse.nodered.org/u/Alex95)\
**Post date:** [15 April 2021 12:36 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057/37 "2021-04-15T12:36:46Z")

</div>

Hmm ok i understand! I will read whore documentation about functios and maybe i will send you again. By the way thank you very much!

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [15 April 2021 14:39 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057/38 "2021-04-15T14:39:39Z")

</div>

Do you know how to draw a truth table? If so, draw one for your two IF statements and look at the results.

---

<div class="post-metadata">

**Author:** ![Alex95](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@Alex95](https://discourse.nodered.org/u/Alex95)\
**Post date:** [15 April 2021 15:34 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057/39 "2021-04-15T15:34:46Z")

</div>

Unfortunately no because i am new in Node-red. But i can search this, it's seems good idea!!

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [15 April 2021 15:47 UTC](https://discourse.nodered.org/t/notification-from-node-red/44057/40 "2021-04-15T15:47:13Z")

</div>

a truth table i a table you write out, If you have two switces that can be off and on it would be

```auto
SW1 | SW2
off | off
off | on
on | off
on | on

```

using that you can test conditions in an IF statement so if you had an if statement with an `or` condition:  
`if ( (sw1 == "on") || (sw2 = "on") )`  
then evaluating using the truth table would look like this

```auto
SW1 | SW2 | LIGHT
off | off | OFF
off | on | ON
on | off | ON
on | on | ON

```

With an IF statement with an `and` condition  
`if ( (sw1 == "on") && (sw2 = "on") )`  
then evaluating using the truth table would look like this

```auto
SW1 | SW2 | LIGHT
off | off | OFF
off | on | OFF
on | off | OFF
on | on | ON

```

It is a another way to look at your code when trying to see what is going on.

[Previous page](https://discourse.nodered.org/t/notification-from-node-red/44057.md?page=1)

[Next page](https://discourse.nodered.org/t/notification-from-node-red/44057.md?page=3)
