SOFTWARE SUPPORT / NODE-RED

Create your second flow

Validate a reading, convert its unit and route the result to the correct branch.

255 produces 25.5 °C on the normal branch; 305 produces 30.5 °C on the high branch.Enlarge diagram +
255 produces 25.5 °C on the normal branch; 305 produces 30.5 °C on the high branch.Native Node-RED 3.0.2 editor. Isolated examples use simulated inputs; hardware commissioning is separate.
  1. Validate and scale

    Convert the numeric input, reject blank or non-finite values, then set temperature to raw / 10 and unit to °C.

  2. Choose the branch

    Configure Switch to test msg.payload.temperature: greater than or equal to the number 30, then otherwise.

  3. Observe both outcomes

    Connect the outputs to named High and Normal Debug nodes. Deploy and test 255, then 305.

  4. Test invalid input

    Try the string invalid. Expect the Function node to report an error to Catch and emit no normal or high result.

const raw = Number(msg.payload);
if (String(msg.payload).trim() === "" || !Number.isFinite(raw)) {
  node.error("Invalid raw value", msg);
  return null;
}
msg.payload = { temperature: raw / 10, unit: "°C" };
return msg;

Try the message logic

Browser-only learning example. It does not run a gateway or control field equipment.

WhatsApp