Serialisation of JS?

Can anyone work this one out?

If I send msg1.payload = 10808 on it’s own line it works. If I run the line msg1.payload = 10808 from within the { } then it throws this fault!

Any ideas?

Paul

Missing a ;

Try this to address the output nodes:

return [ {payload: msg1}, {payload: msg2} ];

Sorry. Not sure what you mean.

Continuing the discussion from Serialisation of JS?:

msg1 is defined on the first line as type Object. Not a Number. Your Victron node probably looks for a .payload property.

Try this

var SOC = global.get(“SOC”);
var Target = global.get(“Target”);

SOC = parseInt(SOC);
Target = parseInt(Target);

var mes1 = "SOC = " + SOC + " Target = " + Target;

if (SOC > Target)
{
var msg2= {payload:0};
}

var msg1= {payload:mes1};

return [ msg1,msg2];