Untitled
unknown
plain_text
a year ago
459 B
11
Indexable
var weight = msg.payload.weight;
var temperature = msg.payload.temperature;
// Check if weight is greater than 20 kg
var occupied = weight > 20;
// Check if temperature is between 34 and 42°C
var validTemp = temperature >= 34 && temperature <= 42;
// Determine fan status
var fanStatus = (occupied && validTemp) ? "ON" : "OFF";
msg.payload = {
weight: weight,
temperature: temperature,
fanStatus: fanStatus
};
return msg;
Editor is loading...
Leave a Comment