Script returning empty response variable

Hi all, I could use some help here. This script is returning nothing in the response variable. I tested the template and it runs fine. But when I run the script I get nothing in the response.

alias: Generate Hourly Forecast
mode: single
variables:
  hourly: |
    {% set hours = state_attr('sensor.weather_forecast_hourly', 'hourly') %}
    {% set ns = namespace(result=[]) %}
    {% for h in hours[:12] %}
      {% set ns.result = ns.result + [{
        "time": (h.timestamp | as_timestamp | timestamp_custom('%H:%M')),
        "temperature": h.temperature,
        "condition": h.condition,
        "pop": h.precip_probability,
        "wind": h.wind_speed ~ ' km/h ' ~ h.wind_direction,
        "windchill": h.windchill
      }] %}
    {% endfor %}
    {{ ns.result }}
sequence:
  - stop: All Done
    response_variable: hourly

Where is it getting the data from? Maybe that has stopped working?

The response variable has to be a dictionary. Yours is a list.

You could change the line

{{ ns.result }}

to

{{ {"value": ns.result} }}
1 Like

You are a saint! Thank you so much. That totally fixed.