A home assistant sensor that uses the OpenWeatherMap API to get the last 5 days rainfall. A call is made for each day so the scan_interval is set at 3600 seconds (1 hour) as the free tier allows only 1000 calls per day.
This information is used to calculate a factor that can be used to reduce the watering time of the Irrigation Program custom component.
A OpenWeatherMap API Key is required see the OpenWeatherMap custom component for more information.
You need an API key, which is free, but requires a registration.
The adjustment factor is calculated based on the the cumulative rainfall for each day. For yesterday the cumulative value is today’s (day 0) rainfall + yesterday’s (day 1) rainfall.
The lowest factor of the up to five days of rainfall is return as the state of the sensor.
factor = 1 - ((cumulative rainfall - daymin)/(daymax - daymin))
If the factor is less than 0 the factor is set to 0.
Attributes are returned for:
- daily rainfall
- daily cumulative rainfall
This is the first iteration of this and any feedback is appreciated.