Very new to Node-RED, have some basics working (dashboard with graphs from sensors, switch for relays), but did a decent amount of searching and either cannot find or just cannot grasp how to do this.
I have 2 ESP8266s with some custom/generic MQTT code. First publishes temp/humidity to greenhouse/temperature and greenhouse/humidity. Second is relay control and subs to esp8266/relay1 and esp8266/relay2 (relay1 is a light, relay 2 is a fan).
I am getting sensor data just fine and can switch light and fan just fine. The sensors publish every 10 seconds.
What I need is to calculate a number based on temperature and humidity to decide if fan needs to run (and also based on time, but I believe I can insert LS Filter for this). Ideally would include some hysteresis but not picky right now. This is what I need to calculate:
Tc = (($temperature - 32) x 5/9) - 3
Sv = 610.78 x e^(Tc / (Tc + 237.3) x 17.2694
Vpd = Sv x (1 - $humidity/100)
Then if Vpd is < 0.8, activate esp8266/relay2 (this is where I'd want to use LS Filter to only run during certain hours, and also hysteresis to have a delay of maybe 10 minutes before activating relay since last time).
I know this is probably relatively simple for most, but the majority of my code is just tinkering to function then left alone, so even some other examples I could adapt from would be great.
If it helps anyway, my use case is this: I am what I call a technical greenhouse grower (even have an AA degree in greenhouse production lol), finally got a small but decent sized greenhouse at home for all my veggie starts for home and for sale/donation. I am trying to maintain Vapor Pressure Deficit or VPD that is based on humidity and temperature to give the optimal environment for plant transpiration at night when greenhouse is sealed. My VPD isn't terribly controllable during the day, but at night the VPD can be far too low (right now is calculated at 0.03) which means they will not be able to transpire and also the increased dew point will create condensation causing moisture on the leaves leading to fungal issues. And yes, VPD is also very commonly used in cannabis growers, relatively new within the last 7-8 years to other greenhouse growers, but given my small space it is even more important. Plus it's fun to see how well I can dial things in not having a "proper" production greenhouse like those I've worked in.