Template Tool weather.get_forecasts UndefinedError: 'hourly' is undefined

I am using WeatherFlow.
I am trying to build a template to get my forecast info: The template trigger below gives me an “UndefinedError: ‘hourly’ is undefined” message in the Template Tool using the weather.get_forecasts service. The template fails, but when I look in the Services Tool I can put in the service weather.get_forecasts and choose the “daily” or hourly" option I get a full rendering of the forecasts. See Below:


template:
  - trigger:
      - platform: time_pattern
        hours: /1
    action:
      - service: weather.get_forecasts
        data:
          type: hourly
        target:
          entity_id: weather.forecast_mysticweather
        response_variable: hourly
    sensor:
      - name: Weather Forecast Hourly
        unique_id: weather_forecast_hourly
        state: "{{ now().isoformat() }}"
        attributes:
          forecast: "{{ hourly['weather.forecast_mysticweather'].forecast }}"

From Services: choice of “daily”

weather.forecast_mysticweather:
forecast:
- condition: lightning
datetime: “2024-07-09T04:00:00+00:00”
precipitation_probability: 60
wind_bearing: 186
temperature: 90
templow: 75
wind_gust_speed: 17.9
wind_speed: 10.29
precipitation: 0.01
- condition: lightning-rainy
datetime: “2024-07-10T04:00:00+00:00”
precipitation_probability: 20
wind_bearing: 183
temperature: 86
templow: 79
wind_gust_speed: 24.61
wind_speed: 11.56
precipitation: 0.01
- condition: lightning
datetime: “2024-07-11T04:00:00+00:00”
precipitation_probability: 80
wind_bearing: 177
temperature: 84
templow: 81
wind_gust_speed: 20.13
wind_speed: 10.35
precipitation: 0.56
- condition: lightning
datetime: “2024-07-12T04:00:00+00:00”
precipitation_probability: 90
wind_bearing: 163
temperature: 81
templow: 79
wind_gust_speed: 22.37
wind_speed: 10.81
precipitation: 0.9
- condition: lightning
datetime: “2024-07-13T04:00:00+00:00”
precipitation_probability: 80
wind_bearing: 203
temperature: 81
templow: 77
wind_gust_speed: 15.66
wind_speed: 8.3
precipitation: 0.65
- condition: lightning
datetime: “2024-07-14T04:00:00+00:00”
precipitation_probability: 50
wind_bearing: 221
temperature: 86
templow: 77
wind_gust_speed: 13.42
wind_speed: 6.15
precipitation: 0.28
- condition: lightning-rainy
datetime: “2024-07-15T04:00:00+00:00”
precipitation_probability: 30
wind_bearing: 217
temperature: 88
templow: 77
wind_gust_speed: 15.66
wind_speed: 7.74
precipitation: 0.09
- condition: lightning-rainy
datetime: “2024-07-16T04:00:00+00:00”
precipitation_probability: 20
wind_bearing: 212
temperature: 88
templow: 79
wind_gust_speed: 17.9
wind_speed: 9.97
precipitation: 0.07
- condition: lightning-rainy
datetime: “2024-07-17T04:00:00+00:00”
precipitation_probability: 30
wind_bearing: 208
temperature: 88
templow: 79
wind_gust_speed: 20.13
wind_speed: 10.72
precipitation: 0.12
- condition: lightning-rainy
datetime: “2024-07-18T04:00:00+00:00”
precipitation_probability: 40
wind_bearing: 205
temperature: 84
templow: 81
wind_gust_speed: 17.9
wind_speed: 10.53
precipitation: 0.3

The template editor does not run services, it just renders Jinja templates. The code you’ve posted is YAML config, not a Jinja template — with the exception of the two {{ }} bits. Because it does not run the service, hourly is not populated and the error is generated.

I realise it starts with template:, but it isn’t one.

What you have experienced is expected behaviour.

You need to include that YAML config in configuration.yaml.

Thank you…
All the forum post I saw were saying to test in the template editor, and I was just using the Jinja. What threw me off was that I needed to call a service first. You put me on the right track. Appreciate it.