# How to find "who" sent a message?

**URL:** <https://discourse.nodered.org/t/how-to-find-who-sent-a-message/19250>\
**Category:** General\
**Created:** [17 December 2019 07:06 UTC](https://discourse.nodered.org/t/how-to-find-who-sent-a-message/19250 "2019-12-17T07:06:08Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [17 December 2019 07:06 UTC](https://discourse.nodered.org/t/how-to-find-who-sent-a-message/19250/1 "2019-12-17T07:06:08Z")

</div>

I have a flow which has been working quite happily.

I have done a slight edit of the flow and I am noticing that the `bigtimer` node keeps going to MANUAL OFF.

I've put debugging on the input and I am seeing an `OFF` message going in.

But how can I find from where it is coming?

Thanks in advance.

---

<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:** [17 December 2019 08:52 UTC](https://discourse.nodered.org/t/how-to-find-who-sent-a-message/19250/2 "2019-12-17T08:52:06Z")

</div>

How is the message received?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [17 December 2019 08:57 UTC](https://discourse.nodered.org/t/how-to-find-who-sent-a-message/19250/3 "2019-12-17T08:57:39Z")

</div>

Debug node.

As I am only showing `msg.payload` I can't really see much else - in this case.

But other ones I see all the message parts but I can't resolve a _sent from this node_ part.

---

<div class="post-metadata">

**Author:** ![molesworth](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/molesworth/32/11748_2.png) [@molesworth](https://discourse.nodered.org/u/molesworth)\
**Post date:** [17 December 2019 09:01 UTC](https://discourse.nodered.org/t/how-to-find-who-sent-a-message/19250/4 "2019-12-17T09:01:29Z")

</div>

I'd suggest switching to showing the whole message, rather than just the payload. It might give you a few clues as to the origin.

Other than that, it's probably just a matter of moving the debug node, or adding additional ones, back along the path(s) until you find the origin of the message. And have a think about which nodes could and which couldn't generate the message, to narrow down the options.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [17 December 2019 09:02 UTC](https://discourse.nodered.org/t/how-to-find-who-sent-a-message/19250/5 "2019-12-17T09:02:55Z")

</div>

Ok, here's another message from another part of the flow.

```auto
{"_msgid":"ccc347a4.18e4f8","topic":"","payload":"2019-12-17 20:01:32 --> reset","_event":"node:b9f15963.64a1a","ttl":0,"_queuetimestamp":1576573292257,"_queueCount":1}

```

_WHO_ sent the message?  
How can I find the node?

---

<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:** [17 December 2019 09:04 UTC](https://discourse.nodered.org/t/how-to-find-who-sent-a-message/19250/6 "2019-12-17T09:04:28Z")

</div>

You didn't answer my question so let me restate it. you have a node at the start of the flow that receives the message and sends t along. What type of node is this? a sensor, an http-in, mqtt-in?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [17 December 2019 09:08 UTC](https://discourse.nodered.org/t/how-to-find-who-sent-a-message/19250/7 "2019-12-17T09:08:21Z")

</div>

> [@zenofmud](#):
>
> you have a node at the start of the flow that receives the message and sends t along. What type of node is this? a sensor, an http-in, mqtt-in?

I can't answer that.

AFAIK the messages are coming from `bigtimer` - which I only recently updated.

There is a few other nodes along the track but they are controlled by the original message.

But somewhere along the line these "rogue" messages are coming along and messing up the functionality of the flow.

Does that help?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [17 December 2019 09:15 UTC](https://discourse.nodered.org/t/how-to-find-who-sent-a-message/19250/8 "2019-12-17T09:15:58Z")

</div>

This MAY be a problem:

`function` node code:

```auto
switch (msg.next) {
    
    case 1:
        msg.delay = msg.runtime1;
        msg.payload = 1; 
        msg.next = 2;
        break;
    case 2:
        msg.delay = msg.runtime2;
        msg.payload = 2;
        msg.next = 3;
        break;  
    case 3:
        msg.delay = msg.runtime3;
        msg.payload = 3;
        msg.next = 4;
        break; 
        
    case 4:
        msg.delay = msg.runtime4;
        msg.payload = "OFF";
        msg.next = 5;
        break; 
    case 5:
        msg.delay = msg.runtime4;
        msg.payload = 5;
        msg.reset = true;
        //msg.next = 1;
        break; 

}

return msg;

```

`msg.next` increments with each pass and `msg.reset` is set to `true` if `msg.next` is 5.

It used to work fine. Now it is just going nuts sending weird/random messages which is driving the display it goes to crazy with brightness.

This is part of the flow:

```auto
[{"id":"bfb00242.9bfce8","type":"switch","z":"83bf3de4.b9429","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Dawn","vt":"str"},{"t":"eq","v":"Dusk","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":190,"y":1700,"wires":[["24ab3b76.2e1e64","f8d4dc92.4e2ab"],["cc25e9fa.095798","b717b6df.8bcec8"]]},{"id":"b717b6df.8bcec8","type":"trigger","z":"83bf3de4.b9429","op1":"","op2":"1","op1type":"nul","op2type":"num","duration":"30","extend":false,"units":"min","reset":"reset","bytopic":"all","name":"Start","x":350,"y":1710,"wires":[["14b6b1de.cd731e"]]},{"id":"14b6b1de.cd731e","type":"function","z":"83bf3de4.b9429","name":"Initialize","func":"var interval = flow.get('Time_delay') || 10;\n\ninterval = (interval * 60000);\ncontext.set(\"interval\",interval); // for debuging\n//var interval = 30*60000; // (30 minutes)\n// interval = 3000; // Test\n// Define runtime1\nmsg.runtime1 = interval;\n\n// Define runtime2\nmsg.runtime2 = interval;\n\n// Define runtime3\nmsg.runtime3 = interval;\n\n// Define runtime4\nmsg.runtime4 = interval;\n\n// Define runtime5\nmsg.runtime5 = interval;\n\n// Next to be activated is number 1\nmsg.next = 1;\n\nreturn msg;","outputs":1,"noerr":0,"x":360,"y":1750,"wires":[["9e68c7a9.1756d8","39513fbf.c38d1"]]},{"id":"9e68c7a9.1756d8","type":"function","z":"83bf3de4.b9429","name":"Cycle next value","func":"switch (msg.next) {\n \n case 1:\n msg.delay = msg.runtime1;\n msg.payload = 1; \n msg.next = 2;\n break;\n case 2:\n msg.delay = msg.runtime2;\n msg.payload = 2;\n msg.next = 3;\n break; \n case 3:\n msg.delay = msg.runtime3;\n msg.payload = 3;\n msg.next = 4;\n break; \n \n case 4:\n msg.delay = msg.runtime4;\n msg.payload = \"OFF\";\n msg.next = 5;\n break; \n case 5:\n msg.delay = msg.runtime4;\n msg.payload = 5;\n msg.reset = true;\n //msg.next = 1;\n break; \n\n}\n\n return msg;","outputs":1,"noerr":0,"x":540,"y":1750,"wires":[["e7a56f9a.9fcfc"]]},{"id":"e7a56f9a.9fcfc","type":"delay","z":"83bf3de4.b9429","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":520,"y":1790,"wires":[["9e68c7a9.1756d8","48d676f5.1cbf78","ea72f1d.b06ae9"]]}]

```

The `flow` value is set to 15. (15 seconds)  
Originally it was a fixed value of 30 minutes - as you may see in one of the `function` nodes.

---

<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:** [17 December 2019 09:37 UTC](https://discourse.nodered.org/t/how-to-find-who-sent-a-message/19250/9 "2019-12-17T09:37:05Z")

</div>

Is anything connected to the input of the bigtimer node?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [17 December 2019 09:48 UTC](https://discourse.nodered.org/t/how-to-find-who-sent-a-message/19250/10 "2019-12-17T09:48:23Z")

</div>

Just buttons to control its _mode_:

On  
Off  
Auto  
Sync  
Toggle

Though I am/was getting erroneous messages coming through which didn't used to happen.

Yeah, ok. That is probably causing the problem, or at least not helping.

The `initialize` node (in the flow I posted) is possibly the problem.

Walk through:  
A `sunset` message comes through from `bigtimer`.  
That goes through a `trigger` node which "delays" the message 30 minutes.  
It sends out a `1` then.

That goes to the `initialize` node which sets up a message to set up a set of pulses.

That goes into the `cycle next value` node (`function`) which increments the message and sends on messages to a `delay` node which is (I hope) variable.

Just checked. Yes the `override with msg.delay` is set.

That then loops through 5 steps and at the end stops/resets the sequence. Or should/used to.

1, 2, 3, 4, 5 and (I think) "OFF" are sent out.

Those are sent at a 30 minute interval - originally - but that was getting a bit late before the display was turned off.

I thought I would reduce that to 15 minutes. That could be when it all went to pot.

I am seeing a lot of messages `msg.reset = true` being sent.  
(Or were)  
I went back to the original code and it seems to be behaving itself a bit better.

So:

Probably I stuffed up with the new bit of code in the `initialize` node.

The top two lines are swapped to change how it behaves.  
Granted there is a stuff up with the maths done in line 3:  
`interval = (interval * 60000);` because that should be used with line #2 only.

Any other elephants I am missing?

```auto
var interval = 30*60000; // (30 minutes)
//var interval = flow.get('Time_delay') || 10;

interval = (interval * 60000);
context.set("interval",interval); // for debuging
// interval = 3000; // Test
// Define runtime1
msg.runtime1 = interval;

// Define runtime2
msg.runtime2 = interval;

// Define runtime3
msg.runtime3 = interval;

// Define runtime4
msg.runtime4 = interval;

// Define runtime5
msg.runtime5 = interval;

// Next to be activated is number 1
msg.next = 1;

return msg;

```

I've modified the code to this to make it better:

Oh, I `context.set()` so I can see what the node is doing.  
Nothing more.

```auto
var interval = 30*60000; // (30 minutes)
//var interval = flow.get('Time_delay') || 10;
//interval = (interval * 60000);

context.set("interval",interval); // for debuging
// interval = 3000; // Test
// Define runtime1
msg.runtime1 = interval;

// Define runtime2
msg.runtime2 = interval;

// Define runtime3
msg.runtime3 = interval;

// Define runtime4
msg.runtime4 = interval;

// Define runtime5
msg.runtime5 = interval;

// Next to be activated is number 1
msg.next = 1;

return msg;

```
