mak-gitdev / HA_enoceanmqtt

Home Assistant wrapper for enocean-mqtt (https://github.com/embyt/enocean-mqtt)
GNU General Public License v3.0
54 stars 14 forks source link

Issue with A5-20-01 RCU Temperature #112

Open williz23 opened 7 months ago

williz23 commented 7 months ago

The problem

Hi, I'm currently testing my EnOcean devices with this AddOn. I've got a lot of EnOcean devices (mostly Eltakos) controlled by FHEM. I want to change to HA in the long run but the EnOcean support has been quiet poor until know. With this module the situation seems to improve, great work so far! Anyway, here is the problem: I am using Kieback&Peter MD15-FTL-HE actuators for my radiators which supports the EEP A5-20-01. Almost everything works perfectly but there is a problem with an RCU temperature provided to the actuator. This value is scaled twice before sent, resulting in unusable raw values. I analysed the issue and found the problem in the mapping.yaml file (lines 3666 and 3667): {% elif entity is search('config_t_RCU$',ignorecase=True) %} {% set ns.TMP = ((states(entity)|int(default=0))*255/40)|int %}

Here the temperature value of the RCU is scaled to the raw value which is supposed to be used by the actuator. However, since this data is used for an outgoing payload, the scaling will be done in the EnOcean library with the help of the EEP.xml file. The library takes the calculated raw value and scales it once again because it expects the temperature value and not the raw value. The correction to the problem is to do no scaling at all in line 3667: {% set ns.TMP = (states(entity)|float(default=0)) %}

I also changed the type of the entity to "float" because the temperature is a floating point number, otherwise using "int" would truncate it losing some accuracy during a calculation (e.g. 19.75 would be changed into 19, which is a significant difference). The same applies to line 3665, the temperature value type should be "float" and only the result is an "int".

What type of installation are you running?

Standalone

What version of HA_enoceanmqtt has the issue?

0.1.28-1

What was the last working version of HA_enoceanmqtt?

No response

What type of Home Assitant installation are you running?

Home Assistant OS

Anything in the logs that might be useful to solve the issue? (Strongly recommended if applicable)

Here is the debug output and the sent message with the original mapping file. The RCU temperature of 21.0 °C ist scaled to a raw value of 121 (TMP). This value is once again scaled to 252 (i.e. about 0.4 °C) before being sent:

2023-12-26 15:27:58.273 DEBUG (MainThread) [homeassistant.components.mqtt.models] Rendering outgoing payload with variables {'value': 'PRESS', 'entity_id': 'button.e2m_hobbykeller_heizung_set_config', 'name': 'set_config', 'this': <template TemplateStateFromEntityId(button.e2m_hobbykeller_heizung_set_config)>} and Template<template=({% set ns = namespace() %} {% for entity in device_entities(device_id(entity_id)) %}
  {% if entity is search('config_valve_position$',ignorecase=True) %}
    {% set ns.valve_position = (states(entity)|int(default=0)) %}
  {% elif entity is search('config_t_setpoint$',ignorecase=True) %}
    {% set ns.temperature_setpoint = ((states(entity)|int(default=0))*255/40)|int %}
  {% elif entity is search('config_t_RCU$',ignorecase=True) %}
    {% set ns.TMP = ((states(entity)|int(default=0))*255/40)|int %}
  {% elif entity is search('config_RIN$',ignorecase=True) %}
    {% set ns.RIN = iif(is_state(entity, "on"), 1, 0) %}
  {% elif entity is search('config_LFS$',ignorecase=True) %}
    {% set ns.LFS = iif(is_state(entity, "on"), 1, 0) %}
  {% elif entity is search('config_VO$',ignorecase=True) %}
    {% set ns.VO = iif(is_state(entity, "on"), 1, 0) %}
  {% elif entity is search('config_VC$',ignorecase=True) %}
    {% set ns.VC = iif(is_state(entity, "on"), 1, 0) %}
  {% elif entity is search('config_SB$',ignorecase=True) %}
    {% set ns.SB = iif(is_state(entity, "on"), 1, 0) %}
  {% elif entity is search('config_SPS$',ignorecase=True) %}
    {% set ns.SPS = iif(is_state(entity, "on"), 1, 0) %}
  {% elif entity is search('config_SPN$',ignorecase=True) %}
    {% set ns.SPN = iif(is_state(entity, "on"), 1, 0) %}
  {% elif entity is search('config_RCU$',ignorecase=True) %}
    {% set ns.RCU = iif(is_state(entity, "on"), 1, 0) %}
  {% endif %}
{% endfor %} {% set ns.SP = iif((ns.SPS == 1), ns.temperature_setpoint, ns.valve_position) %} {"SP":{{ns.SP}},"TMP":{{ns.TMP}},"RIN":{{ns.RIN}},"LFS":{{ns.LFS}},"VO":{{ns.VO}},"VC":{{ns.VC}},"SB":{{ns.SB}},"SPS":{{ns.SPS}},"SPN":{{ns.SPN}},"RCU":{{ns.RCU}}}) renders=74>
2023-12-26 15:27:58.296 DEBUG (MainThread) [homeassistant.components.mqtt.client] Transmitting message on enoceanmqtt/Hobbykeller/Heizung/req: '{"SP":127,"TMP":121,"RIN":0,"LFS":0,"VO":0,"VC":0,"SB":0,"SPS":1,"SPN":0,"RCU":0}', mid: 157, qos: 0

2023-12-26 15:32:23,423 INFO: sending: FF:A3:39:00->01:85:88:03 (-255 dBm): 
0x01 ['0xa5', '0x7f', '0xfc', '0x4', '0x8', '0xff', '0xa3', '0x39', '0x0', '0x0'] ['0x3', '0x1', '0x85', '0x88', '0x3', '0xff', '0x0'] 
OrderedDict([('SP', {'description': 'Valve Position or Temperature Setpoint', 'unit': '%', 'value': 127.0, 'raw_value': 127}), ('TMP', {'description': 'Temperature from RCU', 'unit': '°C', 'value': 0.47058823529411764, 'raw_value': 252}), ('RIN', {'description': 'Run init sequence', 'unit': '', 'value': 'false', 'raw_value': 0}), ('LFS', {'description': 'Lift set', 'unit': '', 'value': 'false', 'raw_value': 0}), ('VO', {'description': 'Valve open / maintenance', 'unit': '', 'value': 'false', 'raw_value': 0}), ('VC', {'description': 'Valve closed', 'unit': '', 'value': 'false', 'raw_value': 0}), ('SB', {'description': 'Summer bit, Reduction of energy consumption', 'unit': '', 'value': 'false', 'raw_value': 0}), ('SPS', {'description': 'Set point selection', 'unit': '', 'value': 'Temperature set point', 'raw_value': 1}), ('SPN', {'description': 'Set point inverse', 'unit': '', 'value': 'false', 'raw_value': 0}), ('RCU', {'description': 'Select function', 'unit': '', 'value': 'RCU', 'raw_value': 0})])

This is the output with the corrected mapping file, now the temperature is only scaled once, TMP is set to 21.0 (float) and this value is scaled to the correct value of 121 which is sent to the actuator:

2023-12-26 19:02:39.505 DEBUG (MainThread) [homeassistant.components.mqtt.models] Rendering outgoing payload with variables {'value': 'PRESS', 'entity_id': 'button.e2m_hobbykeller_heizung_set_config', 'name': 'set_config', 'this': <template TemplateStateFromEntityId(button.e2m_hobbykeller_heizung_set_config)>} and Template<template=({% set ns = namespace() %} {% for entity in device_entities(device_id(entity_id)) %}
  {% if entity is search('config_valve_position$',ignorecase=True) %}
    {% set ns.valve_position = (states(entity)|int(default=0)) %}
  {% elif entity is search('config_t_setpoint$',ignorecase=True) %}
    {% set ns.temperature_setpoint = ((states(entity)|float(default=0))*255/40)|int %}
  {% elif entity is search('config_t_RCU$',ignorecase=True) %}
    {% set ns.TMP = (states(entity)|float(default=0)) %}
  {% elif entity is search('config_RIN$',ignorecase=True) %}
    {% set ns.RIN = iif(is_state(entity, "on"), 1, 0) %}
  {% elif entity is search('config_LFS$',ignorecase=True) %}
    {% set ns.LFS = iif(is_state(entity, "on"), 1, 0) %}
  {% elif entity is search('config_VO$',ignorecase=True) %}
    {% set ns.VO = iif(is_state(entity, "on"), 1, 0) %}
  {% elif entity is search('config_VC$',ignorecase=True) %}
    {% set ns.VC = iif(is_state(entity, "on"), 1, 0) %}
  {% elif entity is search('config_SB$',ignorecase=True) %}
    {% set ns.SB = iif(is_state(entity, "on"), 1, 0) %}
  {% elif entity is search('config_SPS$',ignorecase=True) %}
    {% set ns.SPS = iif(is_state(entity, "on"), 1, 0) %}
  {% elif entity is search('config_SPN$',ignorecase=True) %}
    {% set ns.SPN = iif(is_state(entity, "on"), 1, 0) %}
  {% elif entity is search('config_RCU$',ignorecase=True) %}
    {% set ns.RCU = iif(is_state(entity, "on"), 1, 0) %}
  {% endif %}
{% endfor %} {% set ns.SP = iif((ns.SPS == 1), ns.temperature_setpoint, ns.valve_position) %} {"SP":{{ns.SP}},"TMP":{{ns.TMP}},"RIN":{{ns.RIN}},"LFS":{{ns.LFS}},"VO":{{ns.VO}},"VC":{{ns.VC}},"SB":{{ns.SB}},"SPS":{{ns.SPS}},"SPN":{{ns.SPN}},"RCU":{{ns.RCU}}}) renders=0>
2023-12-26 19:02:39.523 DEBUG (MainThread) [homeassistant.components.mqtt.client] Transmitting message on enoceanmqtt/Hobbykeller/Heizung/req: '{"SP":129,"TMP":21.0,"RIN":0,"LFS":0,"VO":0,"VC":0,"SB":0,"SPS":1,"SPN":0,"RCU":0}', mid: 6, qos: 0

2023-12-26 19:05:39,365 INFO: sending: FF:A3:39:00->01:85:88:03 (-255 dBm): 0x01 ['0xa5', '0x81', '0x79', '0x4', '0x8', '0xff', '0xa3', '0x39', '0x0', '0x0'] ['0x3', '0x1', '0x85', '0x88', '0x3', '0xff', '0x0'] OrderedDict([('SP', {'description': 'Valve Position or Temperature Setpoint', 'unit': '%', 'value': 129.0, 'raw_value': 129}), ('TMP', {'description': 'Temperature from RCU', 'unit': '°C', 'value': 21.019607843137255, 'raw_value': 121}), ('RIN', {'description': 'Run init sequence', 'unit': '', 'value': 'false', 'raw_value': 0}), ('LFS', {'description': 'Lift set', 'unit': '', 'value': 'false', 'raw_value': 0}), ('VO', {'description': 'Valve open / maintenance', 'unit': '', 'value': 'false', 'raw_value': 0}), ('VC', {'description': 'Valve closed', 'unit': '', 'value': 'false', 'raw_value': 0}), ('SB', {'description': 'Summer bit, Reduction of energy consumption', 'unit': '', 'value': 'false', 'raw_value': 0}), ('SPS', {'description': 'Set point selection', 'unit': '', 'value': 'Temperature set point', 'raw_value': 1}), ('SPN', {'description': 'Set point inverse', 'unit': '', 'value': 'false', 'raw_value': 0}), ('RCU', {'description': 'Select function', 'unit': '', 'value': 'RCU', 'raw_value': 0})])

Additional information

No response

mak-gitdev commented 7 months ago

Hi @williz23,

Thank you very much for this detailed issue. I will apply your solution. Apart from that, do you have any other problems with your A5-20-01 or is it working OK ?

williz23 commented 7 months ago

Hi @mak-gitdev , So far this is the only issue I found with my A5-20-01, everything else is working OK.