Node-RED 3.0 issues

I updated the Node-RED addon to the new 3.0 version (yes, I made a backup to fall back to beforehand). Noticed 2 issues pretty quickly after updating.

  1. I have dark mode enabled, and the new text box editor (like for function nodes) is not being shown in dark mode.

  2. getting odd errors about every function node that has variables used, even though the function nodes still work as expected. Seeing an error in the editor about not being able to find a variable name. It even throws up the little orange triangle on the node and gives a warning when deploying, and then proceeds to work exactly as I expect it to. A quick and dirty example of it is:

[{"id":"c5d03ee60a8749e3","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"81354314d6b7fe2b","type":"inject","z":"c5d03ee60a8749e3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"testing","payload":"test","payloadType":"str","x":160,"y":200,"wires":[["5198fd1a96addeab"]]},{"id":"e26cdef981f99e88","type":"debug","z":"c5d03ee60a8749e3","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":640,"y":160,"wires":[]},{"id":"5198fd1a96addeab","type":"function","z":"c5d03ee60a8749e3","name":"function 1","func":"a = msg.payload\nb = msg.topic\nmsg.payload = b\nmsg.topic = a\nreturn msg;","outputs":1,"noerr":4,"initialize":"","finalize":"","libs":[],"x":420,"y":200,"wires":[["e26cdef981f99e88"]]}]

You’re luckier than me: my render template editor just disappeared and I’ve got no way to edit.

I read on the notice that there is a new ‘Monaco Text Editor’ that needs to be selected somewhere in settings but I have no idea where. At the moment I am stuck: no templates any more!

Same issue with the render template node here.

looks like they are already working on it

Try declaring the variables:

var a = msg.payload;
1 Like

how? where?

My reply was for lightmaster’s function problem not your template one

Tried putting “var” in front of the variable names on line 1, 2, 3, and 4. Still throws an error message, except now the function box doesn’t work. Removed “var” from those lines and it’s back to the faux error message but at least it does function as intended.

Only lines 1 and 2. There you are creating new variables. The msg variable is already defined

A fancy new editor with several nice new features - including better error checking for undeclared variables.

Your post prompted me to have a look at my function nodes, and I have the same situation with an undefined array that I later fill with objects. However, there is a way to stop the checker…

Going to the ‘error’, click on the nice light bulb on the left, option to ignore error or to disable checking.

Bit of a blunt tool, but that added the line
// @ts-nocheck
at the top of the code, and bingo, no checking, no errors, no red triangle.

Or you could just fix the error. I’ve declared all my variables and got no errors.

Just understand the progression of how things are depreciated. First it’s a warning, then an error, then it halts the system.

I’ll be looking forward to nr 4.0 broke all my function nodes post. Those who want to avoid problems don’t be lazy and fix the problem don’t ignore it.

Great. It’s amazing that people get to work on this stuff so quickly.

I will note that the render template nodes still appear to be working…I just can’t edit them.

Oooh, ok. So when you are creating new variables you have to add “var” in front of them, but not when calling existing variables. I had started using variables like how you do in python, and it worked without any issue. Didn’t realize that was just Node-RED error correcting my code.

You don’t declare in python but just assign variables:

x = foo

In JavaScript you have to declare them with either var, let or const

For more info look here: Stack Overflow

var x = foo;

Picked up the variable issue in the functions quite quickly and declaring them worked no issues.

Another issue I have, and wondering if anyone has the same is that I have a complex flow which ultimately turns on and later turns off a single relay at a time to control a valve - The relays are connected to an MCP23017 and that in turn is connected to an ESP32 board running ESPHome.

It seems that after the update, the switch.turn_on (or off) turns ALL relays/switches on (or off) instead of just the one that’s specified. Initially I thought it was just an issue with turning on and perhaps a change to how the mustache templates work, but even when explicitly specifying the switch/relay to turn on, all of them activate.

Below is a screenshot of the call service node as well as the debug of the node as well as of the output of the function preceding the call service node.


Debug

Turning switches/relays on/off manually via my dashboard in HA work without any issues.

Apologies in advance if my terminology is out anywhere - Still quite new to all this.

Did you solved the problem with function node editor?

yes, the problem was fixed within a week (I believe the first right one was Home Assistant’s add-on version 13.1.0)

Ended up rolling back both HA and Nodered (Unfortunately I can’t recall version numbers) That sorted it all out. Have updated everything since and all has been working as expected again.