This is a big update, if you find an issue raise an issue on Github, If you like it give it a star.
A big thanks to @tsbernar for the work put into this release.
A home assistant sensor that uses the OpenWeatherMap API to return:
Any number of sensors can be created using templates.
While HA recommends using individual sensors, you can assign additional attributes to a sensor.
The data is in 24 hour time slots, not date based, but data for the preceeding 24hrs.
Two API calls are used each hour, one to collect the new history data and another to collect the forecast and current observations.
When a new locations is created:
You can configure the retention of the data so while you may choose to backload 5 days you can keep up to 30 days of data. This will be accumulated until the limit is reached.
This integration was initially built to support the Irrigation Program custom component and can be used to:
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.
Note If you have an existing key you will still need to subscribe to the One Call 3.0 API, follow the instructions above.
HACS installation Adding as a custom repository using HACS is the simplest approach, will be published soon.
Manual Installation
Key | Type | Optional | Description | Default |
---|---|---|---|---|
Location Name | string | Required | Instance identifier, cannot be modified | Home Assistant configured name |
API Key | string | Required | OpenWeatherMap API key | |
Location | location | Required | Select from the map, cannot be within 1000m of an already configured location | Home Assistant configure location |
Days to keep data | integer | Required | Retention period of the captured data. Can be longer than initial download. Data will accumulate as collected until the limit is reached. Will default to backload days it is defined with a value less thant the backload days | 5 days |
Days to backload | integer | Required | Days for initial population, can be increased after the initial load, a new backload will commence | 5 days |
Max API calls per day | integer | Required | The daily API limit, the count is for one integration, if you have two instances with 500 then each can use 500 api calls | 500 |
Key | Type | Optional | Description | Default |
---|---|---|---|---|
Sensor name | string | Required | Sensor name, modify using HA once created | |
Jinja2 Template | template | Required | A valid template that will define the sensor | |
Attributes to expose | string | Optional | A comma seperated list of valid variables to add as attributes to the sensor | |
Sensor Type | string | Optional | Select the type to define unit of measure. A template that returns a text value must be set to None | None |
All data is captured in metric measurements.
To ensure that you see the information in your local unit of measure:
WARNING (Recorder) [homeassistant.components.sensor.recorder] The unit of sensor.current_temp (°C) cannot be converted ...
Go to https://my.home-assistant.io/redirect/developer_statistics to fix this
Unit of measure is not applied to attributes only to the sensor state. Attribute values are supplied as metric values
Two files are created in the config directory:
day0rain, day1rain, day2rain, day3rain, day4rain, day0max, day1max, day2max, day3max, day4max, day0min, day1min, day2min, day3min, day4min
Calculations are performed in the native unit of measure, so all calculations are in mm, mm/hr, °C, hPa, %.
Determine the watering frequency based on temperature
{% set avgtemp = (forecast1max + forecast2max + forecast3max)/3 -%}
{% if avgtemp < 10 -%}
Off
{% elif avgtemp < 20 -%}
Mon, Fri
{% else -%}
Mon, Thu, Sat
{% endif -%}
Display current temperature
{{current_temp}}
Version 1 factor, verifying to an expected 10mm rainfall
{{
[(10
- day0rain
- day1rain*0.5
- day2rain*0.25
- day3rain*0.12
- day4rain*0.06)/10
,0]|max
}}
Factor utilising forecast rain and probability of precipitation
{{
[(10
- day0rain
- day1rain*0.5
- day2rain*0.25
- forecast1rain*forecast1pop*0.5
- forecast2rain*forecast2pop*0.25)/10
,0]|max
}}
A common usecase is to show daily/monthly rainfall. Using the cumulative data elements this can be achieved with the Utility Meter sensor
Variable | example | Description |
---|---|---|
day{i}rain | day0rain | Rainfall in the 24 hour period |
day{i}snow | day1snow | Snow in the 25-48 hour period |
day{i}max | Maximum temperature in the 24 hour period | |
day{i}min | Minimum temperature in the 24 hour period |
Variable | example | Description |
---|---|---|
forecast{i}pop | forecast0pop | Probobility of precipitation in the 24 hour period |
forecast{i}rain | forecast1rain | Forecast rain in the 25-48 hour period |
forecast{i}snow | Forecast snow in the 24 hour period | |
forecast{i}humidity | Average humidity | |
forecast{i}max | Maximum temperature in the 24 hour period | |
forecast{i}min | Minimum temperature in the 24 hour period |
Variable | Description |
---|---|
current_rain | Current hours rainfall |
current_snow | Current hours snow |
current_humidity | Current hours humidity |
current_temp | Current hours temperature |
current_pressure | Current hours pressure |
Variable | Description |
---|---|
cumulative_rain | Continually increasing total of all rainfall recorded |
cumulative_snow | Continually increasing total of all snowfall recorded |
Variable | Description |
---|---|
remaining_backlog | Hours of data remaining to be gathered |
daily_count | Number of API calls for all instances of the integration, resets midnight GMT. This will not always match between instance of the integration due to the update frequency |
Tristan created a german video about this integration: https://youtu.be/cXtVMJZU_ho