ESPAltherma: COP sensor template error (config/logs)
Home Assistant shows 220 erros about COP Sensor template. I think the error came after hass update.
Logger: homeassistant.components.template.template_entity
Source: components/template/template_entity.py:71
Integration: template (documentation, issues)
First occurred: March 18, 2021, 10:46:59 AM (220 occurrences)
Last logged: 11:22:45 AM
TemplateError('ZeroDivisionError: float division by zero') while processing template 'Template("{{ ((state_attr('sensor.althermasensors','Flow sensor (l/min)')| float * 0.06 * 1.16 * (state_attr('sensor.althermasensors','Leaving water temp. before BUH (R1T)') | float - state_attr('sensor.althermasensors','Inlet water temp.(R4T)')|float) ) / (state_attr('sensor.althermasensors','INV primary current (A)') | float * state_attr('sensor.althermasensors','Voltage (N-phase) (V)')|float / 1000)) |round(2) }}")' for attribute '_state' in entity 'sensor.espaltherma_cop'
I can’t figure out what the home assistant don’t like about it any more.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (8 by maintainers)
Ok, I know understand that you have occasional ‘division by 0’ error. To avoid them completely, I would suggest to add the following condition in the
ifof the formula.that would make something like:
{% if is_state_attr('sensor.althermasensors','Operation Mode', 'Heating') and is_state_attr('sensor.althermasensors','Freeze Protection', 'OFF') and state_attr('sensor.althermasensors','INV primary current (A)') | float != 0 %}etc.Great I’ll update the readme. Thanks.
Have a look here: https://github.com/raomin/ESPAltherma#calculating-cop The formula will only calculate the COP if the heat pump is running, avoiding the division of by zero.