~/blog/posts on  live via 󱄅 impure (blog-env)
cat ha-forecast-v2.md

HA Forecast v2

Exploring forecasts post-2023

I have been lackadaisical with my Home Assistant updates, but when I updated it late December of 2024 I've broken all my forecast automations. I had for a short while swapped to openweathermap, but now that even seems to be broken. With summer heat at an all time peak I would like to get this working again. I've moderate research on this... and it's a nightmare. As of writing my instance is 2025.6.2

Problem #

{{ state_attr("weather.kmop_daynight", "forecast") }} has now been deprecated and now you have to manually call to get the forecast. From the 3-4 threads I have read, this requires a template, with a trigger and an action. The major problem right off the bat was testing anything. The forums described "Developer Tools" and the "Services" tab, I don't have any of that.

Testing #

After plenty of failures, "Services" has now been renamed to "Actions". Going there a simple test is:

  1. Select weather.get_forecasts in the search
  2. Select the KMOP entity
  3. Forecast Type: Twice Daily

This is the YAML for the call

action: weather.get_forecasts
data:
  type: twice_daily
target:
  entity_id: weather.kmop_daynight
response_variable: response

Clicking to preform action outputs it in this format

weather.kmop_daynight:
  forecast:
    - datetime: ""
      precipitation_probability: 0
      is_daytime: false
    - datetime: ""
      # etc

Scrolling down you can click the COPY TO CLIPBOARD (TEMPLATE) button and this data can then be used inside the Template tab. This is also where you see that the response_variable is in fact being set to response

Automating #

This is where the template part comes in. I created a new file templates.yaml and added this line template: !include templates.yaml in my main configuration

I've found this file was specific on action and sensor not having a dash

templates.yaml,
- trigger:
  - platform: time_pattern
    minutes: "/15"
  action:
    - service: weather.get_forecasts
      data:
        type: twice_daily
      target:
        entity_id: weather.kmop_daynight
      response_variable: response
  sensor:
    - name: Weather Forecast
      unique_id: weather_forecast
      state: "{{ now() }}"
      attributes:
        forecast: "{{ response['weather.kmop_daynight'].forecast }}"

After creating this and resetting Home Assistant this new sensor appeared as unknown. I am hoping that it will configure after 15 minutes. Which happened!

Converting #

Now to update the entity created in the previous post

configuration.yaml
sensor:
 - platform: template
   sensors:
      forecast_temperature_template:
        friendly_name: "Next Temperature Forecast"
        unit_of_measurement: '°F'
        value_template: >- 
          {% if states("sensor.weather_forecast") != "unavailable" %}
            {% if now().hour >= 18 -%}
              {{ state_attr("sensor.weather_forecast", "forecast").0.temperature }}
            {%- else -%}
              {{ state_attr("sensor.weather_forecast", "forecast").1.temperature }}
            {%- endif %}
          {% else %}
            unavailable
          {% endif %}

I had added an "unavailable" if to all my templates to avoid error logs

Next #

My current plans is to keep this running for a week or two to check that it's working and then changed the trigger to a time platform. This would lower the amount of requests.

~/blog/posts on  live via 󱄅 impure (blog-env)
_