Untitled
unknown
plain_text
a month ago
742 B
3
Indexable
Never
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;
Leave a Comment