Closed stosoorok closed 3 years ago
Hmmm do you have a definition like the one on the main page, starting with {% if is_state_attr('sensor.althermasensors','Operation Mode', 'Heating') and is_state_attr('sensor.althermasensors','Freeze Protection', 'OFF')
?
What do you mean by the main page?
I only have in the esp_sensors.yaml:
espaltherma_cop:
friendly_name: "COP"
unit_of_measurement: 'COP'
value_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)
}}"
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.
Calculating COP is somehow little bit more complicated because of:
So what to do with COP < 1? It looks like it should be ignored, right? But defrosting (and idling I think) are factors that lowers down the seasonal COP and should be taken into account...
Meh... I think it's really a question of personal appreciation. A COP below 1 is possible if you are heating outside and cooling inside, which is what happens in defrost, and I like to see how inefficient my heating is when defrosting. Besides it never remains long under 1...
But it will be nice to see if you have a difference between the watt consumption we calculate and the one of the sdm630. There is obviously a problem as (mine) shows 0 Amp when in standby whereas the pump and UI etc is running...!
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.
Yes that line was missing, but now the COP is always 0. No errors and the sensor is just zero. Could this be alignment issue? No errors on Visual Studio Code or in Configutaration validation.
Got it working. The problem was in Freeze protection sensor. I just commented it in and made a new sensors and after a restart everything works.
And the Zero Division Error is Back! :(
Logger: homeassistant.components.template.template_entity
Source: components/template/template_entity.py:71
Integration: template (documentation, issues)
First occurred: 2:07:49 PM (9 occurrences)
Last logged: 3:52:34 PM
TemplateError('ZeroDivisionError: float division by zero') while processing template 'Template("{% if is_state_attr('sensor.althermasensors','Operation Mode', 'Heating') and is_state_attr('sensor.althermasensors','Freeze Protection', 'OFF') %} {{ ((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) }} {% else %} 0 {%endif%}")' for attribute '_state' in entity 'sensor.espaltherma_cop'
Stating the obvious 0 div means that Amp and/or Voltage is 0. What is the state 'Operation Mode' and/or 'Freeze Protection' when this occurs?
Operation mode is 'Heating' and Freeze Protection is 'OFF'. I don't use Freezing Protection (disabled from the HP menu), it's always off and I don't use other operation modes other than heating.
Voltage is always about 230V and the current is varying 0....20A. When the current is 0 (HP is in idle mode), then the COP is Unavailable not zero.
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 if
of the formula.
state_attr('sensor.althermasensors','INV primary current (A)') | float != 0
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.
Thank you again @raomin - now it seems to be fixed!
Current is 0, COP is 0 and HA log shows no division errors! Maybe you should add this to COP sensor example.
OK I'll update (and simplify) it.
If anyone wants this to also work while Cooling I use this:
{% if
state_attr('sensor.althermasensors','Operation Mode') in ('Heating', 'Cooling')
and state_attr('sensor.althermasensors','Freeze Protection') == 'OFF'
and state_attr('sensor.althermasensors','INV primary current (A)') | float != 0
%}
{{
(
(
state_attr('sensor.althermasensors','Flow sensor (l/min)') | float
* 0.06
* 1.16
*
(
state_attr('sensor.althermasensors','Outlet Water Heat Exch. Temp. (R1T)') | float
- state_attr('sensor.althermasensors','Inlet water temp.(R4T)') | float
)
)
/
(
state_attr('sensor.althermasensors','INV primary current (A)') | float
* states('sensor.mains_voltage') | float
/ 1000
)
)
| round(2)
| abs
}}
{% else %}
0
{% endif %}
Replace states('sensor.mains_voltage')
with your own or hardcode your country's voltage eg: 230
for most of Europe or 120
for USA. Link with list
Great I'll update the readme. Thanks.
Home Assistant shows 220 erros about COP Sensor template. I think the error came after hass update.
I can't figure out what the home assistant don't like about it any more.