Untitled
unknown
plain_text
a year ago
742 B
11
Indexable
var weight = msg.payload; // Weight in kgs
var temperature = Math.floor(Math.random() * (42 - 34 + 1)) + 34; // Random temperature between 34 and 42
if (weight > 20) {
if (temperature >= 34 && temperature <= 42) {
msg.payload = {
occupied: true,
weight: weight,
temperature: temperature,
fanStatus: "ON"
};
} else {
msg.payload = {
occupied: false,
weight: weight,
temperature: temperature,
fanStatus: "OFF"
};
}
} else {
msg.payload = {
occupied: false,
weight: weight,
temperature: temperature,
fanStatus: "OFF"
};
}
return msg;
Editor is loading...
Leave a Comment