From 6947e09a6eddfa64b1b0f3d8433f31cebfbba3b9 Mon Sep 17 00:00:00 2001 From: mak-gitdev Date: Sun, 4 Jun 2023 18:04:33 +0200 Subject: [PATCH] Version 0.1.26 - Latest enocean-mqtt version which fixes status bits setting (see mak-gitdev/HA_enoceanmqtt#65 and embyt/enocean-mqtt#41 for more details) - From now, use mak-gitdev/enocean as Python EnOcean Library which fixes "list index out of range error" thanks to @kridgo patch (see kipe/enocean#134 and kipe/enocean#138 for more details). - Add virtual A5-10-06 (mak-gitdev/HA_enoceanmqtt#46) - Add '%' as unit of measurement for A5-20-01 current value field (mak-gitdev/HA_enoceanmqtt#53) - Update F6-02-[01-02] mapping to send status bits thanks to @LarsKoeppel. --- enoceanmqtt/communicator.py | 3 ++ .../overlays/homeassistant/mapping.yaml | 53 ++++++++++++++++--- standalone/install.sh | 13 ++++- 3 files changed, 61 insertions(+), 8 deletions(-) diff --git a/enoceanmqtt/communicator.py b/enoceanmqtt/communicator.py index e0b5f25..87cd832 100644 --- a/enoceanmqtt/communicator.py +++ b/enoceanmqtt/communicator.py @@ -458,7 +458,10 @@ def _send_packet(self, sensor, destination, command=None, if 'data' in sensor: # override with specific data settings logging.debug("sensor data: %s", sensor['data']) + # Set packet data payload packet.set_eep(sensor['data']) + # Set packet status bits + packet.data[-1] = packet.status packet.parse_eep() # ensure that the logging output of packet is updated else: # what to do if we have no data to send yet? diff --git a/enoceanmqtt/overlays/homeassistant/mapping.yaml b/enoceanmqtt/overlays/homeassistant/mapping.yaml index 53633fb..64d38cf 100644 --- a/enoceanmqtt/overlays/homeassistant/mapping.yaml +++ b/enoceanmqtt/overlays/homeassistant/mapping.yaml @@ -2108,6 +2108,46 @@ state_topic: "" value_template: >- {% if value_json.SLSW == 1 %}OFF{% else %}ON{% endif %} + virtual: + - component: "number" + name: "setpoint" + config: + command_topic: "__trash" + min: "0" + max: "255" + step: "1" + mode: "box" + - component: "number" + name: "temperature" + config: + command_topic: "__trash" + min: "0" + max: "40" + step: "0.1" + mode: "box" + unit_of_measurement: "°C" + icon: "mdi:thermometer" + - component: "switch" + name: "slide_switch" + config: + command_topic: "__trash" + - component: "button" + name: "send" + config: + command_topic: "req" + command_template: >- + {% set ns = namespace() %} + {% for entity in device_entities(device_id(entity_id)) %} + {% if entity is search('_slide_switch$',ignorecase=True) %} + {% if is_state(entity, "on") %}{% set ns.SLSW = 1 %}{% else %}{% set ns.SLSW = 0 %}{% endif %} + {% elif entity is search('_setpoint$',ignorecase=True) %} + {% set ns.SP = (states(entity)|int)|int(default=128) %} + {% elif entity is search('_temperature$',ignorecase=True) %} + {% set ns.TMP = (40-(states(entity)|float(default=20))*255/40)|int %} + {% endif %} + {% endfor %} + {"SP":"{{ns.SP}}","TMP":"{{ns.TMP}}","SLSW":"{{ns.SLSW}}","send":"clear"} + icon: "mdi:send" 0x10: device_config: command: "" @@ -2568,6 +2608,7 @@ state_topic: "" value_template: "{{ value_json.CV }}" device_class: "power_factor" + unit_of_measurement: "%" icon: "mdi:valve" - component: "binary_sensor" name: "SO" @@ -2885,12 +2926,12 @@ - "BI + AI" command_topic: "req" command_template: >- - {% set R1, EB, R2, SA = 0, 0, 0, 0 %} + {% set R1, EB, R2, SA, T21, NU = 0, 0, 0, 0, 1, 0 %} {% set id = {"AI":"0","AO":"1","BI":"2","BO":"3"} %} {% set action = value.split(" + ") %} - {% if value is not search('None') %}{% set EB, R1 = 1, id[action[0]] %}{% endif %} + {% if value is not search('None') %}{% set EB, NU, R1 = 1, 1, id[action[0]] %}{% endif %} {% if action|length==2 %}{% set SA, R2 = 1, id[action[1]] %}{% endif %} - {"R1":{{R1}},"EB":{{EB}},"R2":{{R2}},"SA":{{SA}},"send":"clear"} + {"R1":{{R1}},"EB":{{EB}},"R2":{{R2}},"SA":{{SA}},"T21":{{T21}},"NU":{{NU}},"send":"clear"} 0x02: device_config: command: "" @@ -2958,12 +2999,12 @@ - "BI + AI" command_topic: "req" command_template: >- - {% set R1, EB, R2, SA = 0, 0, 0, 0 %} + {% set R1, EB, R2, SA, T21, NU = 0, 0, 0, 0, 1, 0 %} {% set id = {"AI":"0","AO":"1","BI":"2","BO":"3"} %} {% set action = value.split(" + ") %} - {% if value is not search('None') %}{% set EB, R1 = 1, id[action[0]] %}{% endif %} + {% if value is not search('None') %}{% set EB, NU, R1 = 1, 1, id[action[0]] %}{% endif %} {% if action|length==2 %}{% set SA, R2 = 1, id[action[1]] %}{% endif %} - {"R1":{{R1}},"EB":{{EB}},"R2":{{R2}},"SA":{{SA}},"send":"clear"} + {"R1":{{R1}},"EB":{{EB}},"R2":{{R2}},"SA":{{SA}},"T21":{{T21}},"NU":{{NU}},"send":"clear"} 0x05: 0x02: device_config: diff --git a/standalone/install.sh b/standalone/install.sh index 7ec62c9..aff45c4 100644 --- a/standalone/install.sh +++ b/standalone/install.sh @@ -16,7 +16,9 @@ usage () package_install() { - printf "\nCheck if %s is installed ... " $1 + printf "\nInstall %s\n" $1 + printf "==================================================\n\n" + printf "\nCheck if %s is already installed ... " $1 pip3 show $1 > /dev/null 2>&1 if [ $? -eq 1 ]; then printf "NO\n" @@ -31,6 +33,7 @@ package_install() if [ $# -eq 0 ]; then usage + exit 0 fi CALL_DIR=$(pwd) @@ -52,9 +55,16 @@ cd ${INSTALL_DIR} package_install pyyaml package_install tinydb +package_install pip-autoremove + +printf "\nInstall Python EnOcean Library\n" +printf "==================================================\n\n" +pip-autoremove enocean -y +pip3 install --user git+https://github.com/mak-gitdev/enocean.git printf "\nClone enocean-mqtt\n" printf "==================================================\n\n" +rm -rf enocean-mqtt git clone https://github.com/embyt/enocean-mqtt.git printf "\nInstall enocean-mqtt\n" @@ -71,7 +81,6 @@ else git clone -b master --single-branch --depth 1 https://github.com/mak-gitdev/HA_enoceanmqtt.git fi cp -rf HA_enoceanmqtt/enoceanmqtt enocean-mqtt -cp -rf HA_enoceanmqtt/enocean/protocol/EEP.xml $(find / -path ./HA_enoceanmqtt -prune -o -name "EEP.xml" -print -quit 2>/dev/null) rm -rf HA_enoceanmqtt cd ${CALL_DIR}