Help with what's (not) happening

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?

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

:confused:

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 :man_shrugging:

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

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:

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

And I don't even see that.

So I am really confused/frustrated.

Here's another attempt to show you:

You can see debug is set to 1

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

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

Suggestions?

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

Expanding on what I just said:

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

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

Gone way outfield.

Tried this bit of code:

[{"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?

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

Took a lot of time to find.

But it now seems to be working.

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