Hello Friends, I am new here, and I could not find the answer elsewhere.
So basically, i have a bunch of HIstory Stats sensors to track the “on” state of an entity.
It has worked wonderfully for 2 months, no errors. No I am getting an error that I cant seem to find what the issue is. The sensor in question:
- platform: history_stats
name: Thermoflux Total Time On February
entity_id: switch.thermoflux
state: "on"
type: time
start: "{{ now().replace(year=(now().year)).replace(month=2).replace(day=1).replace(hour=0).replace(minute=0).replace(second=0) }}"
end: "{{ now().replace(year=(now().year)).replace(month=2).replace(day=28).replace(hour=23).replace(minute=59).replace(second=59) }}"
scan_interval: 21600
This particular sensor gives me the following error:
Error parsing template for field start
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 1698, 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 1, in top-level template code
File "/usr/local/lib/python3.9/site-packages/jinja2/sandbox.py", line 393, in call
return __context.call(__obj, *args, **kwargs)
ValueError: day is out of range for month
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/history_stats/sensor.py", line 273, in update_period
start_rendered = self._start.async_render()
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 400, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: ValueError: day is out of range for month
What is weird is, i have the SAME EXACT sensors for other months, and only February gives me this error?
What gives? Is this a leap year bug or something? Any help would be appreciated.
P.S. The sensor worked for 2 months before without issues or errors.