I am Currently using an MQTT Gateway to receive values from a PLC using modbus. Then sending those values to a raspberry pi, and storing them into a SQLite Database. The Values only send to the Raspberry Pi "On Value Change".
I currently have 15 MQTT devices being joined to KEY/Value Pairs, then running through a function to place the values in a table.
The issue I am having is that when some values change and others do not the function node is throwing a Undefined error.
I am assuming this error is occurring because some values are sending and some are not thus the value is undefined.
My Question is How can I change my Javascript to allow zero to take its place if no value sends through or any suggestions on helping with my problem.
var newMsg = { payload: msg.payload };
newMsg.topic = `INSERT INTO SSreadings (ProgramNumber, NumOfLeaks, FsFlow, MsFlow, Ds1Flow, SpruFlow, Jc1Flow, Jc2Flow, Jc3Flow, Jc4Flow, FacFlow, JcFlow, FacPress, JcPress, Ds2Flow) VALUES (${msg.payload.ProgramNumber.value}, ${msg.payload.NumOfLeaks.value}, ${msg.payload.FsFlow.value}, ${msg.payload.MsFlow.value}, ${msg.payload.Ds1Flow.value}, ${msg.payload.SpruFlow.value}, ${msg.payload.Jc1Flow.value}, ${msg.payload.Jc2Flow.value}, ${msg.payload.Jc3Flow.value}, ${msg.payload.Jc4Flow.value}, ${msg.payload.FacFlow.value}, ${msg.payload.JcFlow.value}, ${msg.payload.FacPress.value}, ${msg.payload.JcPress.value}, ${msg.payload.Ds2Flow.value});`
return newMsg;
I would appreciate any help, I am still very new to Javascript and Nodered