Hey,
I have been having this issue for a while, but cant seem to find a solution. Sensor itself works well, but error message appears quite often in core log:
2020-11-07 16:26:00 WARNING (MainThread) [homeassistant.components.template.template_entity] Template loop detected while processing event: <Event state_changed[L]: entity_id=sensor.current_consumption, old_state=<state sensor.current_consumption=236.0; unit_of_measurement=W, friendly_name=Current Power, icon=mdi:transmission-tower @ 2020-11-07T16:25:58.361623+01:00>, new_state=<state sensor.current_consumption=237.0; unit_of_measurement=W, friendly_name=Current Power, icon=mdi:transmission-tower @ 2020-11-07T16:25:59.364586+01:00>>, skipping template render for Template[{% set ns = namespace(states=[]) %} {% for s in states.sensor %}
{% if s.entity_id.startswith('sensor.') and s.object_id.endswith('_power') and s.state not in ['unavailable', 'unknown' ] %}
{% set ns.states = ns.states + [ s.state | float ] %}
{% endif %}
{% endfor %} {{ ns.states | sum | round(2) }}]
Full sensor configuration:
- platform: template
sensors:
current_consumption:
friendly_name: Current Power
unit_of_measurement: W
icon_template: mdi:transmission-tower
value_template: >
{% set ns = namespace(states=[]) %}
{% for s in states.sensor %}
{% if s.entity_id.startswith('sensor.') and s.object_id.endswith('_power') and s.state not in ['unavailable', 'unknown' ] %}
{% set ns.states = ns.states + [ s.state | float ] %}
{% endif %}
{% endfor %}
{{ ns.states | sum | round(2) }}
It is based on configuration I found in several places here.
Interesting is, that I have kWh sensor which is almost identical, but that one never shows any errors.
I dont see how it can loop, since it is not self-referencing for sure.
Any idea what could be causing this message?