This blueprint implements a garden misting system that toggles on/off via a physical switch (corresponding to a water valve), and dynamically adjusts cycle duration and frequency based on temperature, relative humidity, and wind speed.
https://gist.github.com/davefx/8c6bdaa124d932cade9acc0df71f1b60
Versions:
- 1.0: Initial release
- 1.1: Added factors to both timers. The cycle timer won’t depend on the wind speed, as wind is very variable.
- 1.2: Changed formula for period between misting. Added two optional helpers to show timers.
Algorithm Description
When the user toggles the valve manually (via the physical or virtual switch), the system enters an “active” state. From then on, it starts a cycle of misting events that repeat periodically until the user disables it by toggling the switch again.
Valve open duration:
Base duration = 10 + (temperature - 25) * 2 - (humidity - 50) * 0.1
Adjusted for wind:
- Wind > 20 km/h → skip misting (duration = 0)
- Wind 10–20 km/h → reduced time:
max(base * 0.5, 3)
- Wind ≤ 10 km/h → full time:
max(base, min_duration_open)
Cycle interval duration:
Base delay = 70 - (temperature - 25) * 2.5 + (humidity * 0.3)
Adjusted for wind:
- Wind > 20 km/h → delay 9999s (effectively stops repeating)
- Wind 10–20 km/h →
max(base * 1.5, 60)
- Wind ≤ 10 km/h →
max(base, 30)