Custom Component to retrieve five days of rain history from OpenWeatherMap


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.

Version 1.0.2 released resolving update problems and improvements to API call efficiency.

1 Like

Version 1.04 -

  • Refactored the logic into a class
  • Fixed issue with daily refresh - changed to UTC time
  • Expanded attributes to include min and max temperature
  • Unit system (metric, imperial) config option
  • Reduce refresh time to 30 minutes
  • remove cumulative rain from the attributes

Version 1.0.5

  • Added unique id
  • limited factor to two decimals


thank you very much for the integration. Unfortunately, I cannot understand the value of the factor when I recalculate it with the precipitation that actually occurred.

I would like to use the integration to know the actual precipitation for the last 24 hrs. Is it possible to output the precipitation retrieved via the API as an attribute for the last days?

The rainfall and min/max temperature are available as attributes. Day 0 is the last 24 hours and so on.

Dear petergridge,

thank you for your answer. :slight_smile:
Are the attributes the precipitation in mm? I thought these would be the calculated factors.

By default it is metric, but you can configure the unit system if required