# Help with what's (not) happening

**URL:** <https://discourse.nodered.org/t/help-with-whats-not-happening/91177>\
**Category:** General\
**Created:** [21 September 2024 23:06 UTC](https://discourse.nodered.org/t/help-with-whats-not-happening/91177 "2024-09-21T23:06:35Z")\
**Posts on this page:** 8\
**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:** [21 September 2024 23:06 UTC](https://discourse.nodered.org/t/help-with-whats-not-happening/91177/1 "2024-09-21T23:06:35Z")

</div>

Seems I am really asking for trouble just now.

I am trying to get some stuff working - which I thought was.

So, quickly:  
If I send a DEBUG message it sets a bit and so when messages arrive I get `node.warn()` stuff.

So what's going on here?

 ![Screenshot from 2024-09-22 09-01-48](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/e/ce591a5388beb690e5dd23b15a0834f097f97645.png)

 ![Screenshot from 2024-09-22 08-49-55](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/2/92bd9a39ff05389efacbcda92cfeb8bb8bdd3b54.png)

 ![Screenshot from 2024-09-22 09-01-42](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/7/87aec7cf9c0904e4f49272510cf138a464a38658.png)

I am not seeing/getting the `node.warn( )` stuff.

😕

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [21 September 2024 23:19 UTC](https://discourse.nodered.org/t/help-with-whats-not-happening/91177/2 "2024-09-21T23:19:46Z")

</div>

Impossible to say. Did you send a msg with payload == "DEBUG" and msg.onoff containing `1`? Line 26 or line 38 could have returned & stopped execution before the `node.warn` 🤷‍♂️

Add more node warns to be 100% sure of what is happening.

---

<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:** [21 September 2024 23:27 UTC](https://discourse.nodered.org/t/help-with-whats-not-happening/91177/3 "2024-09-21T23:27:15Z")

</div>

The `DEBUG` message contains a property that turns it on/off.  
(And sets the context.)

With that done, it `return` out.

Subsequent messages pass through.

Line 26 is if a `WIPE` message is received.  
(which is also done in the `on start` tab.  
So I thought/believe that that tab is _delivered_ to the node as a message when it is initially deployed.

So when the _normal_ messages arrive - like:  
`{"Who":"TimePi","router":"offline","pip":"online","modem":"online","internet":"online"}`

The names are read from the message and then `if (debug == 1)` should be shown.

That line doesn't happen.

Yet if I go to the `context` tab, select that node and refresh, it says `debug` is `1`.  
So it is doing my head in why it is not happening.

I also went to the extreme of putting a very simple:

```auto
if (debug == 1)
{
    node.warn("Debugging turned on")
}

```

And I don't even see that.

So I am really confused/frustrated.

---

<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:** [21 September 2024 23:36 UTC](https://discourse.nodered.org/t/help-with-whats-not-happening/91177/4 "2024-09-21T23:36:03Z")

</div>

Here's another attempt to show you:

You can see `debug` is set to `1`

 ![Screenshot from 2024-09-22 09-28-10](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/d/adc6de2a69f861a1e921c9d325adcf2e7f275f16.png)

Here is the code and `debug` window.  
You can see the `if` bits grouped.

 ![Screenshot from 2024-09-22 09-30-18](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd09afbdc4a75319a07ab25bcf0af6b0fc86195a.png)

Then I inject a message.  
You can see the _structure_ of it and so it should get past all those `if`s.  
Yet I am not seeing a `node.warn( )` output.

 ![Screenshot from 2024-09-22 09-31-53](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/b/5b91399d21f993daf20ac9820ced8cc5baa1b1de.png)

Suggestions?

I will try putting in `node.warn( )` earlier and outside the `debug` parameters.

---

<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:** [21 September 2024 23:46 UTC](https://discourse.nodered.org/t/help-with-whats-not-happening/91177/5 "2024-09-21T23:46:05Z")

</div>

Expanding on what I just said:

Added some extra code.  
You can see that the context is set.

 ![Screenshot from 2024-09-22 09-42-40](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/e/eeb8a6bf37b3c38710f0c22383efaa1d234740f9.png)

So what is happening here?  
Why is the `context.get("debug) || 0` giving me `0` when it is set to `1`?

 ![Screenshot from 2024-09-22 09-42-45](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/4/04d8d8134793cdd96951cbb3896ca83dd19305c5.png)

---

<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:** [21 September 2024 23:55 UTC](https://discourse.nodered.org/t/help-with-whats-not-happening/91177/6 "2024-09-21T23:55:01Z")

</div>

Gone way outfield.

Tried this bit of code:

```auto
[{"id":"d88386033f218b26","type":"function","z":"ed217a75.2f6d9","name":"function 178","func":"if (msg.payload == \"DEBUG\") {\n context.set(\"debug\", msg.onoff);\n if (msg.onoff == 0) {\n node.status({});\n // return;\n } else {\n node.status({ fill: \"blue\", text: \"DEBUG ON\" });\n // return;\n }\n return;\n}\n\nlet debug = context.get(\"debug\") || 0\nnode.warn(\"debug set to \" + debug)\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2880,"y":1280,"wires":[[]]},{"id":"10e9e13bf14c419f","type":"inject","z":"ed217a75.2f6d9","name":"Debug off","props":[{"p":"payload"},{"p":"onoff","v":"0","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"DEBUG","payloadType":"str","x":2690,"y":1340,"wires":[["d88386033f218b26"]]},{"id":"ed0494b408ae66dc","type":"inject","z":"ed217a75.2f6d9","name":"Debug on","props":[{"p":"payload"},{"p":"onoff","v":"1","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"DEBUG","payloadType":"str","x":2690,"y":1380,"wires":[["d88386033f218b26"]]},{"id":"b49fd575a08a3eeb","type":"inject","z":"ed217a75.2f6d9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":2690,"y":1280,"wires":[["d88386033f218b26"]]}]

```

Guess what!

It works.

So why doesn't it in the other part?

---

<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:** [22 September 2024 01:52 UTC](https://discourse.nodered.org/t/help-with-whats-not-happening/91177/7 "2024-09-22T01:52:07Z")

</div>

Yeah, ok. I can't type/spell all that good.

Took a lot of time to find.

But it now seems to be working.

---

<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:** [6 October 2024 01:52 UTC](https://discourse.nodered.org/t/help-with-whats-not-happening/91177/8 "2024-10-06T01:52:15Z")

</div>

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