Hi Phil,
we have a new error after updating to HA 2021.6:
021-05-27 15:11:50 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform sun2
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 585, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 614, in add_to_platform_finish
await self.async_added_to_hass()
File "/config/custom_components/sun2/sensor.py", line 158, in async_added_to_hass
self._setup_fixed_updating()
File "/config/custom_components/sun2/sensor.py", line 130, in _setup_fixed_updating
next_midn = next_midnight(dt_util.now(self._tzinfo))
File "/config/custom_components/sun2/sensor.py", line 43, in next_midnight
return dt.tzinfo.localize(datetime.combine(dt.date() + _ONE_DAY, time()))
AttributeError: 'backports.zoneinfo.ZoneInfo' object has no attribute 'localize'
2021-05-27 15:11:51 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up sun2 platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 257, in _async_setup_platform
await asyncio.gather(*pending)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 585, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 614, in add_to_platform_finish
await self.async_added_to_hass()
File "/config/custom_components/sun2/sensor.py", line 158, in async_added_to_hass
self._setup_fixed_updating()
File "/config/custom_components/sun2/sensor.py", line 130, in _setup_fixed_updating
next_midn = next_midnight(dt_util.now(self._tzinfo))
File "/config/custom_components/sun2/sensor.py", line 43, in next_midnight
return dt.tzinfo.localize(datetime.combine(dt.date() + _ONE_DAY, time()))
AttributeError: 'backports.zoneinfo.ZoneInfo' object has no attribute 'localize'
is this a one time thing, or in need of some adjustment in the code?
causing severe havoc:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 505, in async_render_to_info
render_info._result = self.async_render(variables, strict=strict, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 391, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: TypeError: '<' not supported between instances of 'datetime.datetime' and 'NoneType'
2021-05-27 15:14:12 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('TypeError: '<' not supported between instances of 'datetime.datetime' and 'NoneType'') while processing template 'Template("{% set nw = now() %} {% set sr = state_attr('sensor.astral_sunrise','today') %} {% set ss = state_attr('sensor.astral_sunset','today') %} {% if nw < sr %}
{{((ss - sr).total_seconds()/60)|int}}
{% elif nw < ss %}
{{((ss - nw).total_seconds()/60)|int}}
{% else %}
0
{% endif %}")' for attribute '_state' in entity 'sensor.daylight_remaining_min'
2021-05-27 15:14:12 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template("{% set nw = now().replace(microsecond=0) %} {% set sr = state_attr('sensor.astral_sunrise', 'today') %} {% set ss = state_attr('sensor.astral_sunset', 'today') %} {% if nw < sr %}
{{ ss - sr }}
{% elif nw < ss %}
{{ ss - nw }}
{% else %}
0:00:00
{% endif %}")
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 389, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1358, in _render_with_context
return template.render(**kwargs)
File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 1304, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 925, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 1, in top-level template code
TypeError: '<' not supported between instances of 'datetime.datetime' and 'NoneType'
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 505, in async_render_to_info
render_info._result = self.async_render(variables, strict=strict, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 391, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: TypeError: '<' not supported between instances of 'datetime.datetime' and 'NoneType'
… please have a look?