chemelli74 / Shelly-utils

Some utils for the Shelly's world
MIT License
12 stars 4 forks source link

Template loop shelly_current_consumption.yaml #2

Open mihsu81-hacs opened 3 years ago

mihsu81-hacs commented 3 years ago

I've tried adding the current_consumption of 2 localtuya plugs in your current_consumption sensor template but i keep getting "Template Loop" warnings in the logs.

"Logger: homeassistant.components.template.template_entity Source: components/template/template_entity.py:216 Integration: Template (documentation, issues) First occurred: 10:04:05 AM (2 occurrences) Last logged: 10:04:38 AM

Template loop detected while processing event: <Event state_changed[L]: entity_id=sensor.current_consumption_home, old_state=<state sensor.current_consumption_home=275.9; unit_of_measurement=W, friendly_name=Current Consumption, icon=mdi:flash-outline @ 2021-07-22T10:04:03.421334+03:00>, new_state=<state sensor.current_consumption_home=277.3; unit_of_measurement=W, friendly_name=Current Consumption, icon=mdi:flash-outline @ 2021-07-22T10:04:04.331133+03:00>>, skipping template render for Template[{% set ns = namespace(states=[]) %} {% for s in states.sensor %} {% if (s.object_id.startswith('shelly_sh') or s.object_id.startswith('plug')) and s.object_id.endswith('_current_consumption') %} {% set ns.states = ns.states + [ s.state | float ] %} {% endif %} {% endfor %} {{ ns.states | sum | round(2) }}]"

I've tried multiple modifications of the code but didn't manage to get it to work. Any ideas?

or

Thanks in advance.

chemelli74 commented 3 years ago

Thx for reporting, but I would suggest to wait for 2021.8 and use the new Energy dashboard ;-)

Simone