- Version 1.2 supports Open Weather Map API 3 functionally this version remains the same as version 1.1.
- A new registration is required for version 3, but once configured the API Key remains the same.
- Stay on version 1.1 until you have registered for API 3.
A home assistant sensor that uses the OpenWeatherMap API to return the last 5 days rainfall, snow, min and max temperatures as attributes. The data is in 24 hour time slots, not date based, but data for the preceeding 24hrs.
On the first installation of version 1.2, 120 API calls are made to populate the data. Data is persisted between starts and will require only 'catch up' calls to complete missing periods. The scan_interval is set at 60 minutes as OpenWeatherMap data only refreshes every hour. A 24 hour period will make 24 API calls.
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. You do need to provide a payment method, however, the first 1000 calls are free and you can set an upper limit of calls. Setting this to 1000 will prevent you incurring any costs.
Attributes are returned for:
- daily rainfall - day_0_rainfall ... day_4_rainfall
- daily snow - day_0_snow ... day_4_snow
- daily minimum temperature - day_0_min ... day_4_min
- daily maximum temperature - day_0_max ... day_4_max
HACS installation Adding as a custom repository using HACS is the simplest approach, will be published soon.
Manual Installation
- Copy the openweathermaphistory folder to the ‘config/custom components/’ directory
A minimal configuration. Latitude and Longitude are defaulted to your Home Assistant location
sensor:
- platform: openweathermaphistory
name: 'rainfactor'
api_key: 'open weather map api key'
A fully specified configuration.
sensor:
- platform: openweathermaphistory
name: 'rainfactor'
latitude: -33.8302547
longitude: 151.1516128
api_key: 'open weather map api key'
day0sig: 1
day1sig: 0.5
day2sig: 0.25
day3sig: 0.12
day4sig: 0.06
watertarget: 10
fine_icon: 'mdi:weather-sunny'
lightrain_icon: 'mdi:weather-rainy'
rain_icon: 'mdi:weather-pouring'
Key | Type | Optional | Description | Default |
---|---|---|---|---|
platform | string | Required | the sensor entityopenweathermaphistory | |
name | string | Required | display name for the sensor | 'rainfactor' |
api_key | string | Required | the OpenWeatherMap API key | |
latitude | latitude | Optional | the location to obtain weather information for | home assistant configured Latitude and Longitude |
longitude | longitude | Optional | the location to obtain weather information for | home assistant configured Latitude and Longitude |
num_days | integer | Optional | the number of days to collect data for | 4, 0 will return the lat 24 hours data only |
fine_icon | icon | Optional | the icon to use when the factor = 1 | 'mdi:weather-sunny' |
lightrain_icon | icon | Optional | the icon to use when the factor somewhere between 0 and 1 | 'mdi:weather-rainy' |
rain_icon | icon | Optional | the icon to use when the factor = 0 | 'mdi:weather-pouring' |
day0sig | float | Optional | Significance of the days rainfall | 1 |
day1sig | float | Optional | Significance of the days rainfall | 0.5 |
day2sig | float | Optional | Significance of the days rainfall | 0.25 |
day3sig | float | Optional | Significance of the days rainfall | 0.12 |
day4sig | float | Optional | Significance of the days rainfall | 0.06 |
watertarget | float | Optional | The desired watering to be applied | 10 |
The adjustment factor is calculated based on the the cumulative rainfall for each day.
Each 24 hrs rain has a lower significance as it ages:
- Rain in the last 24 hours has a weighting of 1
- rain for the next 24 hours has a weighting of 0.5
- rain for the next 24 hours has a weighting of 0.25
- rain for the next 24 hours has a weighting of 0.12
- rain for the next 24 hours has a weighting of 0.06
The adjusted total rainfall is compared to a target rainfall:
- if the total adjusted rainfall is 2mm and the target rainfall is 10mm a factor of 0.8 will be returned
- Version 1.2 supports Open Weather Map API 3 functionally this version remains the same as version 1.1
- A new registration is required for version 3, but once configured the API Key remains the same.
- Upgrade only after registering for API version 3
- Implement Pickle to store data to limit api calls when when restarting
- For HACS
- Breaking Change - remove num_days configuration option.
- Breaking Change - Modify the factor to a simpler model
- Optimised API calls
- Handle missing time zone issue for new OpenWeather registrations. Timezone defaults to HomeAssistant configuration value
- Only return five full 24hr periods
- Deprecate unit_system and derive units from HA config.
- Minor bug fix
- present rainfall in inches when imperial unit system selected
- refactor to present data based on the last 24 hours
- Added custom card
- Add unique id
- round factor to 2 decimal places
- Reduce refresh time to 30 minutes
- Remove cumulative rain from the attributes
- 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
- fix remaining bug
- fix refresh issues, reduce API calls
- Initial Release.