Question about knowing types of variables

Hi,

Apologies in advance for the very basic question, but I’m trying to learn a bit more about scripting.

I have the following:

  - variables:
      forecast: null
  - action: weather.get_forecasts
    metadata: {}
    data:
      type: daily
    response_variable: forecasts
    target:
      entity_id: weather.openweathermap

If I write forecasts to the log I see:

weather.openweathermap:
        forecast:
          - datetime: '2025-10-11T11:00:00+00:00'

I wanted to loop over the forecasts with:

{% for forecast in forecasts %}

But this doesn’t work.
So I tried e.g. forecasts.weather.openweathermap
But then I get:
Error rendering data template: UndefinedError: 'dict object' has no attribute 'weather'
So I’m actually wondering if this is a string? If so, how can I tell?

Edit: Okay, I realised something and this now works:

{% for forecast in forecasts["weather.openweathermap"].forecast %}
{{forecast}}
{% endfor %}

But my question still stands - how is the best way to debug this without re-running the script over and over again? How can I tell the type of a variable?

Have you reviewed this thread? It has been recently updated.

When you have a null, it’s an issue

For stuff that gives a response like calling for weather forecasts - use the developer tools, actions. And the response will be given underneath the call. So you will see the full dict response.

As for other stuff, use the template editor in developer tools.

If you want to figure out the template to use to access data in something like that call. You would copy the entire response of your actions call into a website like:

Then take the javascript and use the set feature in the developer template editor like this:

{% set j = {
  "weather.dhjm": {
    "forecast": [
      {
        "condition": "partlycloudy",
        "datetime": "2025-10-11T11:00:00+00:00",
        "wind_bearing": 278.6,
        "uv_index": 2,
        "temperature": 15.2,
        "templow": 8.2,
        "wind_speed": 10.31,
        "precipitation": 0,
        "humidity": 75
      },
      {
        "condition": "fog",
        "datetime": "2025-10-12T11:00:00+00:00",
        "wind_bearing": 248.4,
        "uv_index": 1.9,
        "temperature": 13.2,
        "templow": 7.2,
        "wind_speed": 6.03,
        "precipitation": 0,
        "humidity": 97
      },
      {
        "condition": "fog",
        "datetime": "2025-10-13T11:00:00+00:00",
        "wind_bearing": 225.1,
        "uv_index": 1.9,
        "temperature": 14.8,
        "templow": 7.8,
        "wind_speed": 7.15,
        "precipitation": 0,
        "humidity": 90
      },
      {
        "condition": "cloudy",
        "datetime": "2025-10-14T11:00:00+00:00",
        "wind_bearing": 281.4,
        "uv_index": 0,
        "temperature": 12.3,
        "templow": 7.8,
        "wind_speed": 4.23,
        "precipitation": 0,
        "humidity": 79
      },
      {
        "condition": "partlycloudy",
        "datetime": "2025-10-15T11:00:00+00:00",
        "wind_bearing": 196.2,
        "temperature": 10.8,
        "templow": 5.9,
        "wind_speed": 2.67,
        "precipitation": 0,
        "humidity": 83
      },
      {
        "condition": "partlycloudy",
        "datetime": "2025-10-16T11:00:00+00:00",
        "wind_bearing": 231.7,
        "temperature": 10.6,
        "templow": 6,
        "wind_speed": 4.47,
        "precipitation": 0,
        "humidity": 80
      }
    ]
  }
} %}

Then you can access it the same way you did if it was a YAML dict.

{% for forecast in j['weather.dhjm'].forecast %}
{{ forecast }}
{% endfor %}

That’s pretty much it, just remember to change the j back to whatever the response variable is you used, when you are using it outside the template editor.

Amazing! Thank you both.