Weather - how to grap the forecast from tomorrow

Hi all,

I am trying to get the forecast from my homelocation. I get the data, if I use weather.get_forecast and I see the result for the next 6 days. But how can I use the data in Homeassitant? If I try to read them, I get only NULL

any ideas?

What are you trying to do, and how are you trying to read it?

Here’s how I pull in the three different types of forecast for my area (this is under template: in my configuration.yaml):

- triggers:
    - trigger: time_pattern
      hours: /1
    - trigger: event
      event_type: automation_reloaded
  actions:
    - action: weather.get_forecasts
      data:
        type: hourly
      target:
        entity_id: weather.met_office_home
      response_variable: hourly
    - action: weather.get_forecasts
      data:
        type: twice_daily
      target:
        entity_id: weather.met_office_home
      response_variable: twice_daily
    - action: weather.get_forecasts
      data:
        type: daily
      target:
        entity_id: weather.met_office_home
      response_variable: daily
  sensor:
    - name: Met Office Home hourly
      unique_id: 2a9d4266-cf8c-42b8-9d4d-b94ffc2cd49c
      state: "{{ now().isoformat() }}"
      attributes:
        forecast: "{{ hourly['weather.met_office_home'].forecast }}"

    - name: Met Office Home twice daily
      unique_id: 275eea48-af44-4d00-a260-5cd856d4291f
      state: "{{ now().isoformat() }}"
      attributes:
        forecast: "{{ twice_daily['weather.met_office_home'].forecast }}"

    - name: Met Office Home daily
      unique_id: ba11fc7f-d333-4da0-bb05-de21e60deccb
      state: "{{ now().isoformat() }}"
      attributes:
        forecast: "{{ daily['weather.met_office_home'].forecast }}"

That puts the forecasts in accessible attributes in those three sensors. You can then do what you want with it — if you need more help, ask a more specific question.

…yes, tries the same, but doesn´t work:

    alias: "Forecast abrufen alle 1h"
    trigger:
      - platform: time_pattern
        minutes: /1
    action:
      - service: weather.get_forecasts
        data:
          entity_id: weather.forecast_home
          type: daily
  sensor:
      - name: "Tiefsttemperatur morgen"
        unique_id: "templow_tomorrow"
        state: "{{ daily['weather.forecast_home'].forecast[1].templow }}"
        unit_of_measurement: °C
      - name: "Höchsttemperatur heute"
        unique_id: "temphigh_today"
        state: "{{ daily['weather.forecast_home'].forecast[0].temperature }}"
        unit_of_measurement: °C
      - name: "Vorhersageliste"
        unique_id: "forecast_list"
        state: "{{ now() }}"
        attributes:
          forecast: "{{ daily['weather.forecast_home'].forecast }}"

Sensor Data are always “unavailable”

but I get the data, if I use the “Entwicklungsumgebung → Aktion”

weather.forecast_home:
  forecast:
    - condition: sunny
      datetime: "2025-07-15T10:00:00+00:00"
      wind_bearing: 266.7
      uv_index: 6.4
      temperature: 22.1
      templow: 15.5
      wind_speed: 20.9
      precipitation: 0
      humidity: 44
    - condition: rainy
      datetime: "2025-07-16T10:00:00+00:00"
      wind_bearing: 269.6
      uv_index: 6.1
      temperature: 18.9
      templow: 14.1
      wind_speed: 20.9
      precipitation: 12.3
      humidity: 71
    - condition: cloudy
      datetime: "2025-07-17T10:00:00+00:00"
      wind_bearing: 292.8
      uv_index: 6.7
      temperature: 21.4
      templow: 13.6
      wind_speed: 14.4
      precipitation: 0.4
      humidity: 61
    - condition: cloudy
      datetime: "2025-07-18T10:00:00+00:00"
      wind_bearing: 310.7
      uv_index: 0
      temperature: 23.9
      templow: 15.1
      wind_speed: 6.8
      precipitation: 0
      humidity: 53
    - condition: cloudy
      datetime: "2025-07-19T10:00:00+00:00"
      wind_bearing: 134.1
      temperature: 27.9
      templow: 16
      wind_speed: 9.4
      precipitation: 0.2
      humidity: 41
    - condition: rainy
      datetime: "2025-07-20T10:00:00+00:00"
      wind_bearing: 221.2
      temperature: 26
      templow: 20.3
      wind_speed: 12.6
      precipitation: 1.8
      humidity: 52

That’s not the same. You have an automation that runs get_forecasts but discards the response. I have a trigger-based template sensor (not an automation, despite having triggers) that runs the action and stores the result in the sensors.

Your weather entity does not store the forecast data for you: it just fetches it.

ok! and the template triggers itself? Let me check! And is there an option to trigger it manually, or do I have to wait for an hour?

Thanks!

That’s why I put the reload-automations trigger in. Although it isn’t an automation, you can trigger it by reloading them (Developer Tools / YAML).

You’ll then need to update your sensors to refer to the forecast in your new template sensor(s); although Vorhersageliste is just a duplicate of them.

I never worked with template triggers before.

  triggers:
    - trigger: time_pattern
      hours: /1
    - trigger: event
      event_type: automation_reloaded
  actions:
    - action: weather.get_forecasts
      data:
        type: hourly
      target:
        entity_id: weather.forecast_home
      response_variable: hourly
    - action: weather.get_forecasts
      data:
        type: daily
      target:
        entity_id: weather.forecast_home
      response_variable: daily
  sensor:
    - name: stĂĽndlich
      alias: stuedlich
      unique_id: hourly
      state: "{{ now().isoformat() }}"
      attributes:
        forecast: "{{ hourly['weather.forecast_home'].forecast }}"

    - name: täglich
      alias: taeglich
      unique_id: daily
      state: "{{ now().isoformat() }}"
      attributes:
        forecast: "{{ daily['weather.forecast_home'].forecast }}"

I tried a small example, but I did not understood, who to trigger manually. Sorry for that.

I have now copied this 1:1 into my configuration.yaml. The states of the sensors remain “unavailable”. I have no idea why that is.

template:
- triggers:
    - trigger: time_pattern
      minutes: /1
    - trigger: event
      event_type: automation_reloaded
  actions:
    - action: weather.get_forecasts
      data:
        type: hourly
      target:
        entity_id: weather.forecast_home
      response_variable: hourly
    - action: weather.get_forecasts
      data:
        type: twice_daily
      target:
        entity_id: weather.forecast_home
      response_variable: twice_daily
    - action: weather.get_forecasts
      data:
        type: daily
      target:
        entity_id: weather.forecast_home
      response_variable: daily
  sensor:
    - name: Met Office Home hourly
      unique_id: 2a9d4266-cf8c-42b8-9d4d-b94ffc2cd49c
      state: "{{ now().isoformat() }}"
      attributes:
        forecast: "{{ hourly['weather.forecast_home'].forecast }}"

    - name: Met Office Home twice daily
      unique_id: 275eea48-af44-4d00-a260-5cd856d4291f
      state: "{{ now().isoformat() }}"
      attributes:
        forecast: "{{ twice_daily['weather.forecast_home'].forecast }}"

    - name: Met Office Home daily
      unique_id: ba11fc7f-d333-4da0-bb05-de21e60deccb
      state: "{{ now().isoformat() }}"
      attributes:
        forecast: "{{ daily['weather.forecast_home'].forecast }}"

You’re requesting the forecast every minute which your provider might not like. Make sure your weather entity is actually called weather.forecast_home, and that it provides daily, twice daily and hourly forecasts.

You should probably have an extra indentation below template:, so:

template:
  - triggers:

then everything else indented in two spaces.

Do you only have one template: heading in your configuration.yaml? If this is the first time you’ve included template: in your config, you’ll need to do a full restart.

Note that your new sensors will be called e.g. sensor.met_office_home_hourly, as you’ve copied from my config. The Met(eorological) Office is the UK state weather provider.

The unique_ids in my config are just random identifiers from this tool.

My configuration.yaml is empty because I’ve outsourced everything into separate files. That makes testing configurations easier…and yes it is the only template in my configuration.yaml

I also think, that the trigger is not performed. So how is the template triggered? And what do I have to reload if I need a manual trigger? I am frustrated !

I changed to hourly now, but no trigger is performed. My expectation is, that the timestamp of the sensors will change, but this doesn´t happen.

Developer Tools / YAML, reload Automations.

Have you done a full restart? And you don’t have a split-out template file, with something like:

template: !include templates.yaml

?

Perhaps only include the daily trigger and sensor for now?

ok.

I did a full restart.

I can see a timestamp now, but no data:

I have included templates like this:
configuration.yaml:
packages: !include_dir_named integrations

Folder integrations:
template_trigger.yaml
template: !include_dir_list ../entities/template/template_trigger
it works always, once I have tested it in the configuration.yalm, I move it into the respective folder In this case it is:

and there is also annother template_trigger (I found it now :slight_smile:

it works.

I can remove the “include” of the template_trigger-folder but I do not think, that this is the issue!

funny,

it looks like, that the sensors will not get the data when you start HA. I reloaded the configuration now, and the data are there…I did not change anything but now the data are there!

can you give me a hint, how I can get the data for tomorrow?

{% set tomorrow = (now()+timedelta(days=1)).date()|string %}
{{ state_attr('sensor.met_office_home_hourly','forecast')
   |selectattr('datetime','match',tomorrow)
   |list }}

That’ll give you a list of the forecast entries for tomorrow.

cool, that means all information are now in the two sensors and I can select this with the offset!
very nice solution!
Thanks for your help.

one thing left!

template:
- triggers:
    - trigger: time_pattern
      hours: /1
    - trigger: event
      event_type: automation_reloaded
  actions:
    - action: weather.get_forecasts

if I move this to an extra file in my folder “template_trigger” I get an syntax issue:

- triggers:
    - trigger: time_pattern
      hours: /1
    - trigger: event
      event_type: automation_reloaded
  actions:
    - action: weather.get_forecasts
Logger: homeassistant.config
Quelle: config.py:357
Erstmals aufgetreten: 18:51:17 (1 Vorkommnis)
Zuletzt protokolliert: 18:51:17

Invalid config for 'template' at entities/template/template_trigger/wettervorhersage.yaml, line 1: expected a dictionary '', got [{'triggers': [{'trigger': 'time_pattern', 'hours': '/1'}, {'trigger': 'event', 'event_type': 'automation_reloaded'}], 'actions': [{'action': 'weather.get_forecasts', 'data': {'type': 'hourly'}, 'target': {'entity_id': 'weather.forecast_home'}, 'response_variable': 'hourly'}, {'action': 'weather.get_forecasts', 'data': {'type': 'daily'}, 'target': {'entity_id': 'weather.forecast_home'}, 'response_variable': 'daily'}], 'sensor': [{'name': 'Met Office Home hourly', 'unique_id': 'forecast_hourly...

I think it has something todo with
- triggers

but if I remove the “-” it does also not work. I do not really get this solved.

I’m not familiar with package-based setups: you just need to work out how to include templates in them.

…it works!
this is the solution with the separate file:

  triggers:
    - trigger: time_pattern
      hours: /1
    - trigger: event
      event_type: automation_reloaded
  actions:
    - action: weather.get_forecasts
      data:
        type: hourly
      target:
        entity_id: weather.forecast_home
      response_variable: hourly
    - action: weather.get_forecasts
      data:
        type: daily
      target:
        entity_id: weather.forecast_home
      response_variable: daily
  
  sensor:
    - name: Met Office Home hourly
      unique_id: forecast_hourly
      state: "{{ now().isoformat() }}"
      attributes:
        forecast: "{{ hourly['weather.forecast_home'].forecast }}"
    - name: Met Office Home daily
      unique_id: forecast_daily
      state: "{{ now().isoformat() }}"
      attributes:
        forecast: "{{ daily['weather.forecast_home'].forecast }}"
1 Like