ledgardener / HomeAssistantYT

18 stars 9 forks source link

Update humidifier-flow #3

Open viper33802 opened 3 years ago

viper33802 commented 3 years ago

Converted msg.payload objects to variables in the function. Created 2 new variables for the Humidity on and off percent. Updated the function to output the new values to a third function output everytime the function is ran. Using the third output to report these on/off values back to Home Assistant into an Input_number helper.

var humisensor = msg.payload["sensor.ruuvi_humidity_4x4"];
var humitarget = msg.payload["input_number.humidity_target"];
var humitol = msg.payload["input_number.humidity_tolerance"];
var humion = (humitarget - humitol);
var humioff = (humitarget + humitol);

msg.data.humi = {"humidifier_on":humion, "humidifier_off":humion};

if (humisensor < humion) {
    var msg1={on};
}

else if (humisensor > humioff) {
    var msg2={off};
}
var msg3={};
msg3.payload = msg.data.humi;
return [msg1, msg2, msg3]

image

hellresistor commented 3 years ago

friend. You have error here no ?

if (humidity < humion)

should be

if (humisensor < humion)

viper33802 commented 3 years ago

friend. You have error here no ?

if (humidity < humion)

should be

if (humisensor < humion)

you were correct. I updated the code in my comment above.

hellresistor commented 3 years ago

If u wanna take a look ;) all free https://github.com/hellresistor/FIFU-Project

hellresistor commented 3 years ago

https://github.com/hellresistor/FIFU-Project/issues/2#issuecomment-790966119