I compared your template from your error log:
{%- for item in states.sensor if (
not is_state_attr(item.entity_id, 'hidden', true)
and (
is_state_attr(item.entity_id, 'device_class', 'battery')
or 'battery' in item.attributes.icon | lower
or (item.entity_id | lower).endswith('_bat')
or (item.name | lower).endswith('_bat')
) or (
(
'battery' in item.entity_id | lower
or 'battery' in item.name | lower
) and (
item.attributes.icon is not defined
) and (
not is_state_attr(item.entity_id, 'battery_alert_disabled', true)
) and (
not is_state_attr(item.entity_id, 'restored', true)
)
)
)
-%}
with mine and they are different.
Mine tests if item.attributes.icon is defined before checking if item.attributes.icon is battery
:
(item.attributes.icon is defined and 'battery' in item.attributes.icon | lower)
Not sure how old your code is. There were lots of changes along the evolution of the package and it’s no longer actively maintained from what I can tell. I no longer use “the package” and have separated the package sections and put them into my config the way you normally would so I have code in my customize.yaml and normal automations and scripts that I can edit from HA UI if I ever need to. I grew tired of having to dig through the package, tweak it and then have to restart HA.
In that piece of code the only thing I can remember tweaking is I added an exclusion for my battery consumption
entities.
You should be able to edit your package and replace
{%- for item in states.sensor if (
not is_state_attr(item.entity_id, 'hidden', true)
and (
is_state_attr(item.entity_id, 'device_class', 'battery')
or 'battery' in item.attributes.icon | lower
or (item.entity_id | lower).endswith('_bat')
or (item.name | lower).endswith('_bat')
) or (
(
'battery' in item.entity_id | lower
or 'battery' in item.name | lower
) and (
item.attributes.icon is not defined
) and (
not is_state_attr(item.entity_id, 'battery_alert_disabled', true)
) and (
not is_state_attr(item.entity_id, 'restored', true)
)
)
)
-%}
with
{%- for item in states.sensor if (
not is_state_attr(item.entity_id, 'hidden', true)
and not 'hidden' in item.entity_id | lower
and not is_state_attr(item.entity_id, 'battery_alert_disabled', true)
and (
is_state_attr(item.entity_id, 'device_class', 'battery')
or (item.attributes.icon is defined and 'battery' in item.attributes.icon | lower)
or (item.entity_id | lower).endswith('_bat')
or (item.name | lower).endswith('_bat')
) or (
(
'battery' in item.entity_id | lower
or 'battery' in item.name | lower
) and (
item.attributes.icon is not defined
) and (
not is_state_attr(item.entity_id, 'battery_alert_disabled', true)
) and (
not is_state_attr(item.entity_id, 'restored', true)
) and (
not 'consumption' in item.entity_id | lower)
)
)
-%}
and be good to go.
BTW, if you paste your template into Dev Tools, Template you should trigger the same error message that’s been filling your logs.
If you want to see all entities in your system that do not have the icon attribute defined:
{%- for item in states.sensor if (item.attributes.icon is not defined) %}
{{ item.entity_id }}
{%- endfor -%}
Another variation which shows all battery entities where the icon attribute is NOT defined:
{%- for item in states.sensor if (
not is_state_attr(item.entity_id, 'hidden', true)
and (
is_state_attr(item.entity_id, 'device_class', 'battery')
and item.attributes.icon is not defined
) or (
(
'battery' in item.entity_id | lower
or 'battery' in item.name | lower
) and (
item.attributes.icon is not defined
) and (
not is_state_attr(item.entity_id, 'battery_alert_disabled', true)
) and (
not is_state_attr(item.entity_id, 'restored', true)
)
)
)
%}
{{ item.entity_id }}
{%- endfor -%}
PS Don’t leave these templates in Dev Tools for too long as it initiates an internal continual watch on ALL sensor
changes and significantly slows the system!!
Hope that helps!