Hello,
since I updated HA from version 2024.1.6 to version 2024.2.1 I have problems with an automation triggered by a change of state; completely randomly after a few hours it starts generating AssertionErrors hundreds of times per second, when I noticed it I had almost 5GB of log files.
The automation in question is the following:
alias: Media players - Event - Backup volume_level
mode: queued
max: 25
trigger:
- platform: event
event_type: state_changed
condition:
- condition: template
value_template: >-
{{ trigger.event.data.entity_id.startswith('media_player.') }}
- condition: template
value_template: "{{ 'volume_level' in trigger.event.data.new_state.attributes }}"
variables:
entity_id: "{{ trigger.event.data.entity_id }}"
action:
- variables:
volume_level: >-
{{ trigger.event.data.new_state.attributes['volume_level'] | float(0.5)
| round(2, default=2) }}
- service: saver.set_variable
data:
name: "{{ entity_id }}.volume_level"
value: "{{ volume_level }}"
The error log is as follows:
Logger: homeassistant
Source: helpers/template.py:686
First occurred: 20:00:03 (1252 occurrences)
Last logged: 20:00:27
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 637, in async_trigger
and not self._cond_func(variables)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 1009, in if_action
if check(hass, variables) is False:
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/condition.py", line 179, in wrapper
result = condition(hass, variables)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/condition.py", line 787, in template_if
return async_template(hass, value_template, variables)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/condition.py", line 767, in async_template
info = value_template.async_render_to_info(variables, parse_result=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 686, in async_render_to_info
assert self.hass and _render_info.get() is None
AssertionError
The line that generates the error is the following:
{{ trigger.event.data.entity_id.startswith('media_player.') }}
I don’t understand why it completely randomly starts to cause problems at a certain point.
I’ve been using that automation for over a year and it has never given me any problems.
Has anyone else encountered the same problem as me?