Mmh… I’m getting an error and I cannot see why…
- id: notify_on_window_left_open
alias: "Benachrichtigung wenn ein Fenster oder eine Türe zu lange offen ist"
mode: parallel
trigger:
- platform: state
entity_id:
- binary_sensor.window_bathroom_middle
- binary_sensor.window_bathroom_attic
- binary_sensor.window_nele
- binary_sensor.window_niclas
- binary_sensor.window_livingroom
- binary_sensor.window_basement
- binary_sensor.window_bedroom
to: 'on'
for: "00:01:00"
action:
- service: notify.mobile_app_xiaomi_redmi_note_9_pro_daniel
data:
title: "Fenster zu lange geöffnet"
message: >
{{ state_attr(trigger.to_state.entity_id, 'friendly_name') }}
ist noch immer geöffnet. Bitte schliessen.
Here is the exeption from the log, does anyone has an idea?
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 353, in async_render
render_result = compiled.render(kwargs)
File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "/usr/local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "<template>", line 1, in top-level template code
File "/usr/local/lib/python3.8/site-packages/jinja2/sandbox.py", line 407, in getattr
value = getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'trigger' is undefined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 188, in async_prepare_call_from_config
service_data.update(template.render_complex(config[conf], variables))
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 93, in render_complex
return {
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 94, in <dictcomp>
render_complex(key, variables): render_complex(item, variables)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 98, in render_complex
return value.async_render(variables)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 355, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'trigger' is undefined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 250, in _async_step
await getattr(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 429, in _async_call_service_step
domain, service_name, service_data = service.async_prepare_call_from_config(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 190, in async_prepare_call_from_config
raise HomeAssistantError(f"Error rendering data template: {ex}") from ex
homeassistant.exceptions.HomeAssistantError: Error rendering data template: UndefinedError: 'trigger' is undefined