small addition:
- platform: event
event_type: event_template_reloaded
is just that bit cleaner
btw Petro, cant we use your new datetime_today() or today_at() function here yet?
for full startup error debugging:
Logger: homeassistant.helpers.event
Source: helpers/template.py:400
First occurred: November 2, 2021, 17:58:11 (1 occurrences)
Last logged: November 2, 2021, 17:58:11
Error while processing template: Template("{%- macro hms(t) %} {%- set h, m, s = (t.dst() | string).split(':') | map('int') %} {{- h * 60 * 60 + m * 60 + s }} {%- endmacro %} {%- macro phrase(seconds, name, divisor, mod=None) %} {%- set value = ((seconds | abs // divisor) % (mod if mod else divisor)) | int %} {%- set end = 's' if value > 1 else '' %} {{- '{} {}{}'.format(value, name, end) if value > 0 else '' }} {%- endmacro %} {%- macro total(seconds) %} {%- set values = [ phrase(seconds, 'hour', 60*60, 60*60*24), phrase(seconds, 'minute', 60, 60), ] | select('!=','') | list %} {{- values[:-1] | join(', ') ~ ' and ' ~ values[-1] if values | length > 1 else values | first }} {%- endmacro %} {%- set next = states('sensor.daylight_savings_next') | as_datetime | as_local %} {%- if next is not none %} {%- set ns = hms(next) | int %} {%- set ps = hms(next - timedelta(days=1)) | int %} {% if ns %} lose {{ total(ns) }} {% else %} gain {{ total(ps) }} {% endif %} {%- endif %}")
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 398, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1695, in _render_with_context
return template.render(**kwargs)
File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 1304, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 925, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 12, in top-level template code
File "/usr/src/homeassistant/homeassistant/util/dt.py", line 96, in as_local
if dattim.tzinfo == DEFAULT_TIME_ZONE:
AttributeError: 'NoneType' object has no attribute 'tzinfo'
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 514, in async_render_to_info
render_info._result = self.async_render(variables, strict=strict, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 400, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: AttributeError: 'NoneType' object has no attribute 'tzinfo'