Function node problem with ver 1.2.2

I developed a flow on a raspberry pi using version node-red 1.1.2 and node.js ver 14.6.0 which works fine. It takes in can data from a battery and serial data from a victron mppt 150¦70-tr. The battery and serial data are joined using the join node and some logic compares the charge demand current with the actual battery current to control the charging regime of the solar charger i.e. turn on when demand > actual and off when demand < actual. there is also a requirement to turn of if can bus communication is lost. i set up a new raspi 4 and updated node-red to ver 1.2.2 and node.js to 12.19.0 (raspi noobs set up node-red with ver 1.0.6 and node js as 10.21.0 and I thought the older version was causing my problem)

In the battery input flow I convert the payload using a function node with a statement

msg.payload =[0];
return msg;

the output from ver 1.1.2 was an array which went into the join node but now the output is just a number from byte 0 of an array

Not sure how to paste the json flow here but am quite happy to do so if required.

I would appreciate some help please - thanks in advance

Which node generates this ^

It is possible (since you are installing everything on a newer machine), the version of the node generating that data has different functionally or been bug fixed compared to the version on your old machine.

It is highly unlikely to be an issue with function node or node-red.

To export a flow, press CTRL+E in the flow editor & copy the flow. it is important to surround your code with three backticks
like this

See this post for more details - How to share code or flow json

Hello Steve - thanks
I have nowgot that flow going ok - the payload msg had changed so I replaced the function with
msg.payload = msg.payload and that solved the issue. I will post the flow later on tomorrow with a couple of other issues but at least its working now

A function that sets msg.payload to msg.payload is not doing anything. If that is all the Function is doing, you should remove the Function node from the flow.

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