Hi at all,
I would like to read out the weather forecast for the current day with daily maximum temperature, condition, and date into a sensor.
I use the Met.No integration for this
Unfortunately, this does not work. The sensor always displays “unknown” under Attributes.
configure.yaml:
template:
- trigger:
- platform: time_pattern
hours: /1
- action:
- service: weather.get_forecasts
target:
entity_id:
- weather.forecast_home
data:
type: daily
response_variable: tagesvorhersage
- sensor:
# Hier ein Template-Sensor, der verschieden Daten der Täglichen Vorhersage als Attribute gespeichert hat
- name: Wetter-Vorhersage des heutigen Tages
unique_id: forecast_today
state: "{{ now().isoformat() }}"
icon: mdi:hours-24
attributes:
condition: "{{ tagesvorhersage['weather.forecast_haus_home'].forecast[0].condition }}"
temperature: "{{ tagesvorhersage['weather.forecast_haus_home'].forecast[0].temperature }}"
datetime: "{{ tagesvorhersage['weather.forecast_haus_home'].forecast[0].datetime }}"
Error-protocoll 1:
Logger: homeassistant.components.template.template_entity
Quelle: components/template/template_entity.py:203
Integration: Template (Dokumentation, Probleme)
Erstmals aufgetreten: 19. Februar 2025 um 15:34:19 (16 Vorkommnisse)
Zuletzt protokolliert: 19. Februar 2025 um 15:40:34
TemplateError('UndefinedError: 'tagesvorhersage' is undefined') while processing template 'Template<template=({{ tagesvorhersage['weather.forecast_haus_home'].forecast[0].condition }}) renders=4>' for attribute 'condition' in entity 'sensor.wetter_vorhersage_des_heutigen_tages'
TemplateError('UndefinedError: 'tagesvorhersage' is undefined') while processing template 'Template<template=({{ tagesvorhersage['weather.forecast_haus_home'].forecast[0].cloud_coverage }}) renders=4>' for attribute 'cloud_coverage' in entity 'sensor.wetter_vorhersage_des_heutigen_tages'
TemplateError('UndefinedError: 'tagesvorhersage' is undefined') while processing template 'Template<template=({{ tagesvorhersage['weather.forecast_haus_home'].forecast[0].temperature }}) renders=4>' for attribute 'temperature' in entity 'sensor.wetter_vorhersage_des_heutigen_tages'
TemplateError('UndefinedError: 'tagesvorhersage' is undefined') while processing template 'Template<template=({{ tagesvorhersage['weather.forecast_haus_home'].forecast[0].datetime }}) renders=4>' for attribute 'datetime' in entity 'sensor.wetter_vorhersage_des_heutigen_tages'
Error-protocoll2:
Logger: homeassistant.helpers.event
Quelle: helpers/template.py:645
Erstmals aufgetreten: 19. Februar 2025 um 15:34:19 (16 Vorkommnisse)
Zuletzt protokolliert: 19. Februar 2025 um 15:40:34
Error while processing template: Template<template=({{ tagesvorhersage['weather.forecast_haus_home'].forecast[0].condition }}) renders=2>
Error while processing template: Template<template=({{ tagesvorhersage['weather.forecast_haus_home'].forecast[0].cloud_coverage }}) renders=2>
Error while processing template: Template<template=({{ tagesvorhersage['weather.forecast_haus_home'].forecast[0].temperature }}) renders=2>
Error while processing template: Template<template=({{ tagesvorhersage['weather.forecast_haus_home'].forecast[0].datetime }}) renders=2>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 643, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2756, in _render_with_context
return template.render(**kwargs)
~~~~~~~~~~~~~~~^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/jinja2/environment.py", line 1295, in render
self.environment.handle_exception()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.13/site-packages/jinja2/environment.py", line 942, 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 293, in getitem
return obj[argument]
~~~^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'tagesvorhersage' 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 760, 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 645, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'tagesvorhersage' is undefined
Picture Sensor:
Please help me!