Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
459 B
2
Indexable
Never
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;
Leave a Comment