I have two variables declared in configuration.yaml:
input_datetime:
nextcooldperiod:
name: “Prochaine periode froide”
has_date: true
has_time: true
coldperiodeduration:
name: “Duree periode froide”
has_date: false
has_time: true
I see the variable coldperiodduration in the developpement tool.
My script is:
alias: "cold_period"
trigger:
platform: time
at: input_datetime.nextcooldperiod
action:
- service: notify.email
data:
title: "Home assistant warning"
message: "Evenement periode froide Hydro Quebec"
- service: input_boolean.turn_on
data:
entity_id: input_boolean.over_heating
# - delay: '00:55:00'
- delay: '00:00:10'
- service: notify.email
data:
title: "Home assistant warning"
message: "will turn off over heating "
- service: input_boolean.turn_off
data:
entity_id: input_boolean.over_heating
- service: notify.email
data:
title: "Home assistant warning"
message: "Will tunr on save electricity"
- service: input_boolean.turn_on
data:
entity_id: input_boolean.save_electricity
- service: notify.email
data:
title: "Home assistant warning"
message: "Duration of the cold period: {{input_datetime.coldperiodeduration}} "
- delay: input_datetime.coldperiodeduration
- service: input_boolean.turn_off
data:
entity_id: input_boolean.save_electricity
- service: notify.email
data:
title: "Home assistant warning"
message: "Fin de la periode froide Hydro Quebec"
And, I have followings error in logs:
Logger: homeassistant.components.automation.cold_period
Source: helpers/service.py:140
Integration: Automatisation (documentation, issues)
First occurred: 10:45:01 (2 occurrences)
Last logged: 10:45:01
cold_period: Error executing script. Unexpected error for call_service at pos 8: Error rendering data template: UndefinedError: 'input_datetime' is undefined
While executing automation automation.cold_period
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 421, 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: 'input_datetime' 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 138, in async_prepare_call_from_config
service_data.update(template.render_complex(config[conf], variables))
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 99, in render_complex
return {
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 100, in <dictcomp>
render_complex(key, variables): render_complex(item, variables)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 104, in render_complex
return value.async_render(variables)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 423, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'input_datetime' 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 253, in _async_step
await getattr(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 432, in _async_call_service_step
domain, service, service_data = async_prepare_call_from_config(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 140, in async_prepare_call_from_config
raise HomeAssistantError(f"Error rendering data template: {ex}") from ex
homeassistant.exceptions.HomeAssistantError: Error rendering data template: UndefinedError: 'input_datetime' is undefined
What’s wrong ?
Thanks for your help !