Node-Red function node not working properly

Topics about the Software of Revolution Pi
bertf
Posts: 7
Joined: 05 May 2020, 12:14

Node-Red function node not working properly

Post by bertf »

Hi Kunbus Team,

I'm testing with a RevPi 3+ and Node-Red. For installation I followed the notes on your site: https://revolution.kunbus.com/tutorials ... the-revpi/ Node-Red. This link installs Node-Red V1.0.6 on the RevPi. Node-Red V1.0.6 works without problems (including function-node), but to be able to access RevPi DIO's I have to install node-red-contrib-revpi-nodes. These nodes won't work without the noderedrevpinodes-server. When I install the noderedrevpinodes-server, Node-Red is being downgraded to V0.20.7. This makes the DIO's in the RevPi-nodes being recognized (work properly), but the function-node inside Node-Red stops working. Even the simplest function (inject timestamp in empty function-node) gives a function : (error) "TypeError: done is not a function".
I tried to install Node-Red on several ways. I also removed the complete installation and started by installing the noderedrevpinodes-server. Then the package nodered V0.20.7 is also installed. The function-node doesn't work either.

Any ideas what might be the problem?

Kind regards
Bert
bcsander
Posts: 6
Joined: 25 Apr 2017, 20:59

Re: Node-Red function node not working properly

Post by bcsander »

Hi Bert,
I am currently running in same trap and not yet finished but
my solution for the first step was to inject a dummy meta package of nodered so the package manager
believes that nodered is already installed.
First I have done the install via script from the nodered site:

Code: Select all

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
Then I used equivs-build to set up a META-Package.
https://blog.sleeplessbeastie.eu/2018/1 ... -checking/

Code: Select all

equivs-control nodered
equivs-build nodered
sudo dpkg -i nodered_1.0+local_all.deb 
The first command generates a file "nodered" you have to edit.
I used this today (not perfect , but my first encounter with "equivs"):

Code: Select all

### Commented entries have reasonable defaults.
### Uncomment to edit them.
# Source: <source package name; defaults to package name>
Section: misc
Priority: optional
# Homepage: <enter URL here; no default>
Standards-Version: 3.9.2

Package: nodered
Version: 1.0+local
Maintainer: BCS
# Pre-Depends: <comma-separated list of packages>
# Depends: <comma-separated list of packages>
# Recommends: <comma-separated list of packages>
# Suggests: <comma-separated list of packages>
# Provides: nodejs,nodered
# Replaces: <comma-separated list of packages>
Architecture: all
# Multi-Arch: <one of: foreign|same|allowed>
# Copyright: <copyright file; defaults to GPL2>
# Changelog: <changelog file; defaults to a generic changelog>
# Readme: <README.Debian file; defaults to a generic one>
# Extra-Files: <comma-separated list of additional files for the doc directory>
# Files: <pair of space-separated paths; First is file to include, second is destination>
#  <more pairs, if there's more than one file to include. Notice the starting space>
Description: <Dummy nodered> 
 Nodered is installed manually 
After this the system shows nodered as installed and the local 1.0.x is still running
pi@RevPi1058:~$ apt search nodered
Sortierung... Fertig
Volltextsuche... Fertig
nodered/now 1.0+local all [Installiert,lokal]
<Dummy nodered>

noderedrevpinodes-server/stretch,now 1.0.1 all [installiert]
Server backend for the RevPi-NodeRed-Nodes
But nodered seems not to connect to to the noderedrevpinodes-server although it is running on
localhost:8000.

nodered-consolelog:
Connection to WS Server established!
Get Command: getpin#[""]
Try to reconnect - Attempt: 1
Connecting to WS Server ws://127.0.0.1:8000
Closed connection to WS Server!

If anybody finds an error in this approach, please let me know as I became a simple user after Kernel2.4

Best regards,
Bernd
jgerlach-erminas
Official 3rd Party Support Erminas
Posts: 38
Joined: 22 Jan 2020, 14:31

Re: Node-Red function node not working properly

Post by jgerlach-erminas »

Hi all,

ok there seem to be two separate problems here:

1. function node not working in node-red v0.20.7

Could you add additonal information here? I can't reproduce the bug here. This is the flow I used for testing:

Code: Select all

[{"id":"2b71c045.050b8","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"a0d5c38a.d22c","type":"inject","z":"2b71c045.050b8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":269.00001525878906,"y":200.99998474121094,"wires":[["178552cc.40985d"]]},{"id":"178552cc.40985d","type":"function","z":"2b71c045.050b8","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"x":455,"y":200.59999084472656,"wires":[["b2b56df1.b2da68"]]},{"id":"b2b56df1.b2da68","type":"debug","z":"2b71c045.050b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":662,"y":200.40000915527344,"wires":[]}]
Others have also reported a similar issue on Raspberry Pi Buster. What is your nodejs version?

Code: Select all

$ node --version
v10.15.3
2. incompability between node-red v1.0.6 and noderedrevpinodes-server

I will try to reproduce your steps and look into the installation and connetion problems. Thanks for reporting.
bcsander
Posts: 6
Joined: 25 Apr 2017, 20:59

Re: Node-Red function node not working properly

Post by bcsander »

Hi Jonas, Hi Bert

I unpacked new Revpi3 and have done some testing:
I could not reproduce the original problem of nodered 0.20.3

I have done:
sudo apt install noderedrevpinodes-server
and have now a nodejs v11.15.0 nodered 0.20.3 and noderedrevpinodes-server 1.0.1

A simple "true/false"-injection triggers my outputs without any errors.

Code: Select all

[{"id":"9a70eca7.e5dac","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"a3296ad1.f50aa","type":"revpi-output","z":"9a70eca7.e5dac","server":"1f324306.0ea655","outputpin":"O_1","overwritevalue":false,"outputvalue":"","x":550,"y":1100,"wires":[]},{"id":"f3255787.46aba","type":"inject","z":"9a70eca7.e5dac","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":330,"y":1040,"wires":[["a3296ad1.f50aa"]]},{"id":"1866a9f9.95394e","type":"inject","z":"9a70eca7.e5dac","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":330,"y":1140,"wires":[["a3296ad1.f50aa"]]},{"id":"1f324306.0ea655","type":"revpi-server","z":"","host":"localhost","port":"8000"}]
Next step: change to nodered 1.0.6.... we will see.

Bernd
bcsander
Posts: 6
Joined: 25 Apr 2017, 20:59

Re: Node-Red function node not working properly

Post by bcsander »

@Jonas

Stop searching for incompatibilities between nodered 1.06 and the noderedrevpinodes-server 1.0.1.
They are working flawlessly on all my RevpiCore3.
I will continue searching for the problems on my RevPiCore1 *gumpf*.

@Bert
installing nodered according the https://nodered.org/docs/getting-started/raspberrypi
and then building/ installing the dummy package of nodered for the packagemanager and install noderedrevpinodes-server will do the job.
bertf
Posts: 7
Joined: 05 May 2020, 12:14

Re: Node-Red function node not working properly

Post by bertf »

Hi all,
Thanks for all your fast responses. Indeed two seperate problems.
To start with a clean sheet I put back the image with the factory settings and installed nodered again according https://nodered.org/docs/getting-started/raspberrypi (= nodered v1.0.6). For accessing the DIO I then tried @prescient-devices/node-red-contrib-revpi-dio instead of node-red-contrib-revpi-nodes. Within nodered v1.0.6 these nodes work without a problem; I can access the DIO's and also use the function node as supposed. For now nodered (v1.0.6) is running fine but without node-red-contrib-revpi-nodes.

@jgerlach-erminas
I used the same flow as you do for testing with an without the debug node. In both cases I got the function : (error) "TypeError: done is not a function".
Installed version of nodejs is v12.16.3.

Thanks!
bertf
Posts: 7
Joined: 05 May 2020, 12:14

Re: Node-Red function node not working properly

Post by bertf »

bcsander wrote: 07 May 2020, 16:17 @Bert
installing nodered according the https://nodered.org/docs/getting-started/raspberrypi
and then building/ installing the dummy package of nodered for the packagemanager and install noderedrevpinodes-server will do the job.
That did the job! After building the dummy package the noderedrevpinodes-server installs without any problems. Node-red-contrib-revpi-nodes is now running on nodered v1.0.6. Function-node keeps working.
@Bernd, thanks!
David_GT
Posts: 12
Joined: 02 May 2019, 09:11

Re: Node-Red function node not working properly

Post by David_GT »

Same problem here!

I try to add these "new" node to my actual configuration without success. When I install the package, I can not start node-red as susual. I'have to re-install node-red following the instructions for RasPi. Doing a "dummy" installation is not acceptable for me.

We hope it solve in future versions!
rp-gill
Posts: 7
Joined: 07 May 2020, 17:14

Re: Node-Red function node not working properly

Post by rp-gill »

Hello Team KunBus,

is the solution posted by "bcsander » 06 Mai 2020, 16:10", the only solution at the moment ?
I am at the same point now with my installation that the Function Node gives an Error "TypeError: done is not a function" after installing "sudo apt-get install noderedrevpinodes-serversudo".

Br,
Gill
Pac_8
Posts: 2
Joined: 27 May 2020, 10:01

Re: Node-Red function node not working properly

Post by Pac_8 »

@bertf
could you possibly post a sample nodered flow of how you programmed the dio nodes you got running on node red with rev pi and config of nodes if possible. Having the same issues and cannot get these nodes running correctly.
Many thanks
Pac_8
Post Reply