The OpenWeatherMap integration can be configured only once and thus limits one to either daily or hourly forecasts.
Since the hourly forecast covers the next 48 hours, I’m trying to create a forecast for “tomorrow” (the only full day to get e.g. a high and low temperature for, so it’s the only one that will make sense).
A somewhat related question has been asked before but didn’t lead to a solution and I can’t find any real examples where the forecast
attribute for the template weather provider is used.
This is the easy part I have:
weather:
- platform: template
name: OpenWeatherMap Daily
condition_template: "{{ states('weather.openweathermap') }}"
temperature_template: "{{ state_attr('weather.openweathermap', 'temperature') | float }}"
humidity_template: "{{ state_attr('weather.openweathermap', 'hunmidity') | float }}"
attribution_template: "{{ state_attr('weather.openweathermap', 'attribution') }}"
pressure_template: "{{ state_attr('weather.openweathermap', 'pressure') | int }}"
wind_speed_template: "{{ state_attr('weather.openweathermap', 'wind_speed') | float }}"
wind_bearing_template: "{{ state_attr('weather.openweathermap', 'wind_bearing') | float }}"
Scope, variables and for loops are tricky in Jinja2 templates. I can use a namespace to access a variable from the outer scope, but it can only be a primitive type. Thus, I can theoretically build up a JSON string that can then later on be converted to a dictionary (the forecast), but I also need to do some kind of group by and I can’t quite see how.
Perhaps there is a much easier alternative.
To summarise: The built-in and default enabled met.no integration automatically provides hourly and daily weather “devices”. I’m trying to achieve the same with OpenWeatherMap. I’ve also experimented with ClimaCell/tomorrow.io (which does provide both hourly and daily values) but the OpenWeatherMap data seems to correlate better with my environment with less guessing, plus I’m just reaching the API limit way too soon (due to how the integration is built, with sensors and requests for all the individual parts when the number of calls could be reduced if you want anything more than only the weather bits).