Hi experts,
I really spend a lot of time with this. I want to use the temperature of tomorrow in an automation. I created the trigger and template sensor. Everything seems correct but I always get:
The action works correctly:
If I use the template editor. The parsing of the value looks also good:
My template config
- trigger:
- trigger: time_pattern
minutes: "/5"
- trigger: homeassistant
event: start
action:
- action: weather.get_forecasts
data:
type: daily
target:
entity_id: weather.sandfeld13
response_variable: daily_forecast
- sensor:
- name: Temperature forecast next day
unique_id: temperature_forecast_next_day
state: >
{{daily_forecast['weather.sandfeld13'].forcast[1].templow}}
The action should at least be triggered on HA start but I always get:
TemplateError('UndefinedError: 'daily_forecast' is undefined') while processing template 'Template<template=({{daily_forecast['weather.sandfeld13'].forcast[1].templow}}) renders=4>' for attribute '_attr_native_value' in entity 'sensor.temperature_forecast_next_day'
Logger: homeassistant.helpers.event
Source: helpers/template.py:633
First occurred: 15:00:17 (1 occurrences)
Last logged: 15:00:17
Error while processing template: Template<template=({{daily_forecast['weather.sandfeld13'].forcast[1].templow}}) renders=2>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 631, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2733, in _render_with_context
return template.render(**kwargs)
~~~~~~~~~~~~~~~^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/jinja2/environment.py", line 1304, in render
self.environment.handle_exception()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.13/site-packages/jinja2/environment.py", line 939, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 1, in top-level template code
File "/usr/local/lib/python3.13/site-packages/jinja2/sandbox.py", line 304, in getitem
return obj[argument]
~~~^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'daily_forecast' is undefined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 748, in async_render_to_info
render_info._result = self.async_render( # noqa: SLF001
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
variables, strict=strict, log_fn=log_fn, **kwargs
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 633, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'daily_forecast' is undefined
Any idea? Im using HA version 2024.12.3
Thanks in advance!
Kind regards,
Marco