I’ve been following this thread for quite a while and learned a lot. Like may of you, I’m trying to find a way to accurately determine when and how much to water my garden plants. After some reading (including this forum), it seems like the best approach involves somehow determining your evapotranspiration (basically, how much water is lost from your soil due to either evaporation directly into the air or transpiration through the plants and into the air) and then determining how much water you need to add based on a combination of irrigation and rainfall.
Many of you appear to have also landed on this solution. There is then some work to be done to determine the main parameters:
- What is your evaotranspiration? (specific to your location, soil type, plan type, and weather)
- How much rainfall has there been?
- How much water should be added through irrigation?
@hhaim posted some really impressive code to calculate the evapotranspiration and pulled the rainfall data from OpenWeatherMap. His coding skills are far more advanced than mine, but there are a couple of reasons why I’m going a slightly different direction here (I think).
I have been looking for a solution that avoids OpenWeatherMap, mainly because for the last 5 years I’ve had a home-brew irrigation controller running off data that used to be supplied by WUnderground, which suddenly decided they wanted everyone to pay for the data and it wasn’t cheap! Anyway, I prefer to avoid services that might end up being put behind a paywall one day.
Also, the idea of calculating the evapotransiration was a bit above my pay grade (so to speak), so I searched to see if there wasn’t a source that supplied this calculation data already (preferably one that is based on some dataset that isn’t proprietary).
I found the following: https://irrisat-cloud.appspot.com/api#user-account-services. There’s not a lot of detail about this site, but in clicking on the “contact us” link, the two contacts both come from the .edu world, so I am making an assumption that this data is probably non-commercial. Anyway, they don’t require any kind of registration so at least for now it’s free and seems likely to stay that way.
The irrisat API allows you to determine not only today’s evapotranspiration (ET), but also has an ET forecast for the next 8 days. This may be useful because, for example, the historical ET data may indicate a need to irrigate, but a combination of rainfall and lower ET rates in the next few days might mean you don’t need to irrigate, or could irrigate less. At least having the current days ET figure without the need to calculate it (and based on the more accurate Penman–Monteith equation https://en.wikipedia.org/wiki/Penman–Monteith_equation) is something even my limited coding skills can handle. So I made a simple REST sensor in HA for today’s ET figure.
Next, I needed to know about rainfall. You would think this would be easy, but as many of you have figured out getting accumulated rainfall data really takes some sleuthing. OpenWeatherMap will probably do the trick (it is the approach taken by @hhaim, so I assume it works, but I have not tried it) , but as I said I have reservations about building a system on this.
If you are in the USA, however (as I am), it turns out that the government has precipitation data based on a multi-sensor data fusion type model. It’s called the "US National Stage IV& QPE
(Quantitative Precipitation Estimate). There are several versions of the API that I found, but the most useful one (at least for me) is here: https://cida.usgs.gov/thredds/ncss/stageiv_combined/dataset.html
Using this API, I was able to write a simple Python program to pull the previous day’s 1-hour rainfall totals and add them up, giving me the total rainfall yesterday.
That’s where I am at for now. I have the ET sensor set up in HA. Next step is to work on a customer senor to bring in the accumulated rainfall total.
I have never written a custom sensor before, but I’m planning to study @hhaim’s code and see if I can adapt it, combining it with my Python code for the rainfall accumulator. If I can’t figure it out, I’ll be posting somewhere here on the forum for some help on that.
Sorry for the really long post, but I wanted to provide some “bread crumbs” for others to follow who might be looking for some of the online resources I found. Once I have more of this integrated into HA, I’ll hopefully be able to post some code that works to put all of this together.