I was able to find a huge solution to one of my problems yesterday using this forum, I'm hoping to get one last piece of advice to figure out the one remaining issue with this code.
if (typeof msg.payload.ProgramNumber === "undefined") msg.payload.ProgramNumber = {"value":0};
if (typeof msg.payload.NumOfLeaks === "undefined") msg.payload.NumOfLeaks = {"value":0};
if (typeof msg.payload.FsFlow === "undefined") msg.payload.FsFlow = {"value":0};
if (typeof msg.payload.MsFlow === "undefined") msg.payload.MsFlow = {"value":0};
if (typeof msg.payload.Ds1Flow === "undefined") msg.payload.Ds1Flow = {"value":0};
if (typeof msg.payload.SpruFlow === "undefined") msg.payload.SpruFlow = {"value":0};
if (typeof msg.payload.Jc1Flow === "undefined") msg.payload.Jc1Flow = {"value":0};
if (typeof msg.payload.Jc2Flow === "undefined") msg.payload.Jc2Flow = {"value":0};
if (typeof msg.payload.Jc3Flow === "undefined") msg.payload.Jc3Flow = {"value":0};
if (typeof msg.payload.Jc4Flow === "undefined") msg.payload.Jc4Flow = {"value":0};
if (typeof msg.payload.FacFlow === "undefined") msg.payload.FacFlow = {"value":0};
if (typeof msg.payload.JcFlow === "undefined") msg.payload.JcFlow = {"value":0};
if (typeof msg.payload.FacPress === "undefined") msg.payload.FacPress = {"value":0};
if (typeof msg.payload.JcPress === "undefined") msg.payload.JcPress = {"value":0};
if (typeof msg.payload.Ds2Flow === "undefined") msg.payload.Ds2Flow = {"value":0};
msg.topic = `INSERT INTO SSreadings (ProgramNumber, Date, Time, NumOfLeaks, FsFlow, MsFlow, Ds1Flow, SpruFlow, Jc1Flow, Jc2Flow, Jc3Flow, Jc4Flow, FacFlow, JcFlow, FacPress, JcPress, Ds2Flow) VALUES (${msg.payload.ProgramNumber.value}, date('now'), time('now','localtime'), ${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 msg;
My question is there a way to return the last value inputted in the table if undefined only for the ProgramNumber and NumOfLeaks part of the message.
if (typeof msg.payload.ProgramNumber === "undefined") msg.payload.ProgramNumber = {"value":0};
if (typeof msg.payload.NumOfLeaks === "undefined") msg.payload.NumOfLeaks = {"value":0};
Thanks again for yesterdays help!