Does anyone know why the following javascript code is triggering the warn alert?
function send(message) {
if (
message.measurement == null || message.measurement == ""
|| message.topic == null || message.topic == ""
|| message.payload == null || message.payload == ""
) {
// node.warn("Invalid measurement: " + message.output + " - " + msg.topic + " / " + message.topic + " / " + message.measurement + " / " + message.payload);
node.warn(message);
return null;
}
node.send(message);
}
if (msg.topic.endsWith("/Status01")) {
// const pumpState = flow.get("pumpState") || "";
const pumpState = msg.payload["5"].value;
const val0 = ((pumpState == "hwc" || pumpState == "off") ? 0 : msg.payload["0"].value);
const val1 = ((pumpState == "hwc" || pumpState == "off") ? 0 : msg.payload["1"].value);
const val3 = ((pumpState == "hwc") ? msg.payload["0"].value : 0);
const val4 = ((pumpState == "hwc") ? msg.payload["1"].value : 0);
send(
{
output: 11,
measurement: "hvac_value",
measurementType: "temperature",
topic: "ebusd_" + ta[1] + "_z1FlowOutletTemp",
payload: val0
}
);
send(
{
output: 12,
measurement: "hvac_value",
measurementType: "temperature",
topic: "ebusd_" + ta[1] + "_z1FlowInletTemp",
payload: val1
}
);
send(
{
output: 13,
measurement: "hvac_value",
measurementType: "temperature",
topic: "ebusd_" + ta[1] + "_HwcFlowOutletTemp",
payload: val3
}
);
send(
{
output: 14,
measurement: "hvac_value",
measurementType: "temperature",
topic: "ebusd_" + ta[1] + "_HwcFlowInletTemp",
payload: val4
}
);
}
It just keeps printing those messages, but I see nothing wrong on them:
{
"output": 11,
"measurement": "hvac_value",
"measurementType": "temperature",
"topic": "ebusd_full_z1FlowOutletTemp",
"payload": 0
}
{
"output": 12,
"measurement": "hvac_value",
"measurementType": "temperature",
"topic": "ebusd_full_z1FlowInletTemp",
"payload": 0
}
{
"output": 13,
"measurement": "hvac_value",
"measurementType": "temperature",
"topic": "ebusd_full_HwcFlowOutletTemp",
"payload": 0
}
{
"output": 14,
"measurement": "hvac_value",
"measurementType": "temperature",
"topic": "ebusd_full_HwcFlowInletTemp",
"payload": 0
}
It started when I added the inline condition on the payloads.