From 5b0281b11d675941b381d0b71d56e70820167424 Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Thu, 21 May 2020 20:39:36 +0200 Subject: [PATCH 01/20] Initial Commit Signed-off-by: Paul Frank --- CODEOWNERS | 1 + bom/openhab-addons/pom.xml | 5 + .../.classpath | 49 ++ .../.project | 23 + .../NOTICE | 13 + .../README.md | 207 +++++ .../pom.xml | 32 + .../src/main/feature/feature.xml | 11 + .../StiebelEltronBindingConstants.java | 73 ++ .../internal/StiebelEltronConfiguration.java | 47 ++ .../internal/StiebelEltronHandlerFactory.java | 77 ++ .../internal/dto/EnergyBlock.java | 36 + .../internal/dto/SystemInformationBlock.java | 35 + .../internal/dto/SystemParameterBlock.java | 28 + .../internal/dto/SystemStateBlock.java | 24 + .../handler/StiebelEltronHandler.java | 736 ++++++++++++++++++ .../internal/parser/AbstractBaseParser.java | 128 +++ .../internal/parser/EnergyBlockParser.java | 46 ++ .../parser/SystemInfromationBlockParser.java | 45 ++ .../parser/SystemParameterBlockParser.java | 38 + .../parser/SystemStateBlockParser.java | 34 + .../ESH-INF/config/config-descriptions.xml | 25 + .../modbus.stiebeleltron_xx_XX.properties | 17 + .../ESH-INF/thing/heatpump-channel-groups.xml | 60 ++ .../ESH-INF/thing/heatpump-channel-types.xml | 171 ++++ .../ESH-INF/thing/heatpump-types.xml | 27 + bundles/pom.xml | 481 +++++++++++- 27 files changed, 2458 insertions(+), 11 deletions(-) create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/.classpath create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/.project create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/NOTICE create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/README.md create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/pom.xml create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/feature/feature.xml create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronBindingConstants.java create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronConfiguration.java create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronHandlerFactory.java create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/EnergyBlock.java create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemInformationBlock.java create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemParameterBlock.java create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemStateBlock.java create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/AbstractBaseParser.java create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/EnergyBlockParser.java create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/SystemInfromationBlockParser.java create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/SystemParameterBlockParser.java create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/SystemStateBlockParser.java create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/config/config-descriptions.xml create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/i18n/modbus.stiebeleltron_xx_XX.properties create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-groups.xml create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-types.xml create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-types.xml diff --git a/CODEOWNERS b/CODEOWNERS index d4e47dd271368..8f9b08a9e2c31 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -128,6 +128,7 @@ /bundles/org.openhab.binding.minecraft/ @ibaton /bundles/org.openhab.binding.modbus/ @ssalonen /bundles/org.openhab.binding.modbus.sunspec/ @mrbig +/bundles/org.openhab.binding.modbus.stiebeleltron/ @pail23 /bundles/org.openhab.binding.mqtt/ @davidgraeff /bundles/org.openhab.binding.mqtt.generic/ @davidgraeff /bundles/org.openhab.binding.mqtt.homeassistant/ @davidgraeff diff --git a/bom/openhab-addons/pom.xml b/bom/openhab-addons/pom.xml index d3641115fc4a5..d6fad3c96e7c1 100644 --- a/bom/openhab-addons/pom.xml +++ b/bom/openhab-addons/pom.xml @@ -629,6 +629,11 @@ org.openhab.binding.modbus ${project.version} + + org.openhab.addons.bundles + org.openhab.binding.modbus.stiebeleltron + ${project.version} + org.openhab.addons.bundles org.openhab.binding.mqtt diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/.classpath b/bundles/org.openhab.binding.modbus.stiebeleltron/.classpath new file mode 100644 index 0000000000000..39abf1c5e9102 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/.classpath @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/.project b/bundles/org.openhab.binding.modbus.stiebeleltron/.project new file mode 100644 index 0000000000000..b285157a2c7f4 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/.project @@ -0,0 +1,23 @@ + + + org.openhab.binding.modbus.stiebeleltron + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/NOTICE b/bundles/org.openhab.binding.modbus.stiebeleltron/NOTICE new file mode 100644 index 0000000000000..38d625e349232 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/NOTICE @@ -0,0 +1,13 @@ +This content is produced and maintained by the openHAB project. + +* Project home: https://www.openhab.org + +== Declared Project Licenses + +This program and the accompanying materials are made available under the terms +of the Eclipse Public License 2.0 which is available at +https://www.eclipse.org/legal/epl-2.0/. + +== Source Code + +https://github.com/openhab/openhab-addons diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/README.md b/bundles/org.openhab.binding.modbus.stiebeleltron/README.md new file mode 100644 index 0000000000000..decac47abbdb3 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/README.md @@ -0,0 +1,207 @@ +# Stiebel Eltron ISG Binding + +This extension adds support for the Stiebel Eltron modbus protocol. + +A Internet Service Gateway (ISG) with an installed modbus extension is required in order to run this binding. In case the modbus extension is not yet installed on the ISG, the ISG Updater Tool for the update can be found here: https://www.stiebel-eltron.de/de/home/produkte-loesungen/erneuerbare_energien/regelung_energiemanagement/internet_servicegateway/isg_web/downloads.html + + + + +## Supported Things + +This bundle adds the following thing types to the Modbus binding. +Note, that the things will show up under the Modbus binding. + +| Thing | Description | +| ------------------------ | -------------------------------------------------- | +| Stiebel Eltron ISG | A stiebel eltron heat pump connected through a ISG | + +## Discovery + +This extension does not support autodiscovery. The things need to be added manually. + +A typical bridge configuration would look like this: + +``` +Bridge modbus:tcp:bridge [ host="10.0.0.2", port=502, id=1 ] +``` + + +## Thing Configuration + +You need first to set up either a TCP Modbus bridge according to the Modbus documentation. +Things in this extension will use the selected bridge to connect to the device. + +The following parameters are valid for all thing types: + +| Parameter | Type | Required | Default if omitted | Description | +| --------- | ------- | -------- | ------------------ | -------------------------------------------------------------------------- | +| refresh | integer | no | 5 | Poll interval in seconds. Increase this if you encounter connection errors | +| maxTries | integer | no | 3 | Number of retries when before giving up reading from this thing. | + +## Channels + +Channels are grouped into channel groups. + +### System State Group + +This group contains general operational information about the heat pump. + +| Channel ID | Item Type | Read only | Description | +| ---------------- | --------- | --------- | ------------------------------------------------------------- | +| is-heating | Contact | true | OPEN in case the heat pump is currently in heating mode | +| is-heating-water | Contact | true | OPEN in case the heat pump is currently in heating water mode | +| is-cooling | Contact | true | OPEN in case the heat pump is currently in cooling mode | +| is-pumping | Contact | true | OPEN in case the heat pump is currently in pumping mode | +| is-summer | Contact | true | OPEN in case the heat pump is currently in summer mode | + +### System Parameters Group + +This group contains system paramters of the heat pump. + +| Channel ID | Item Type | Read only | Description | +| --------------------------- | ------------------ | --------- | ------------------------------------------- | +| operation-mode | Number | false | The current operation mode of the heat pump | +| comfort-temperature-heating | Number:Temperature | false | The current heating comfort temperature | +| eco-temperature-heating | Number:Temperature | false | The current heating eco temperature | +| comfort-temperature-water | Number:Temperature | false | The current water comfort temperature | +| eco-temperature-water | Number:Temperature | false | The current water eco temperature | + +### System Information Group + +This group contains general operational information about the device. + +| Channel ID | Item Type | Read only | Description | +| -------------------------- | -------------------- | --------- | ----------------------------------------------------- | +| fek-temperature | Number:Temperature | true | The current temperature measured by the FEK | +| fek-temperature-setpoint | Number:Temperature | true | The current set point of the FEK temperature | +| fek-humidity | Number:Dimensionless | true | The current humidity measured by the FEK | +| fek-dewpoint | Number:Temperature | true | The current dew point temperature measured by the FEK | +| outdoor-temperature | Number:Temperature | true | The current outdoor temperature | +| hk1-temperature | Number:Temperature | true | The current temperature of the HK1 | +| hk1-temperature-setpoint | Number:Temperature | true | The current temperature set point of the HK1 | +| supply-temperature | Number:Temperature | true | The current supply temperature | +| return-temperature | Number:Temperature | true | The current return measured | +| source-temperature | Number:Temperature | true | The current sourcetemperature | +| water-temperature | Number:Temperature | true | The current water temperature | +| water-temperature-setpoint | Number:Temperature | true | The current water temperature set point | + +### Energy Information Group + +This group contains about the energy consumption and delivery of the heat pump. + +| Channel ID | Item Type | Read only | Description | +| ----------------------- | ------------- | --------- | ------------------------------------------------ | +| production_heat_today | Number:Energy | true | The heat quantity delivered today | +| production_heat_total | Number:Energy | true | The heat quantity delivered in total | +| production_water_today | Number:Energy | true | The water heat quantity delivered today | +| production_water_total | Number:Energy | true | The water heat quantity delivered in total | +| consumption_heat_today | Number:Energy | true | The power consumption for heating today | +| consumption_heat_total | Number:Energy | true | The power consumption for heating in total | +| consumption_water_today | Number:Energy | true | The power consumption for water heating today | +| consumption_water_total | Number:Energy | true | The power consumption for water heating in total | + + + +## Full Example + +### Thing Configuration + +``` +Bridge modbus:tcp:bridge [ host="hostname|ip", port=502, id=1] +Thing modbus:heatpump:stiebelEltron "StiebelEltron" (modbus:tcp:modbusbridge) [ ] +``` + + +### Item Configuration + +``` +Number:Temperature stiebel_eltron_temperature_ffk "Temperature FFK [%.1f °C]" { channel="modbus:heatpump:stiebelEltron:systemInformation#fek-temperature" } +Number:Temperature stiebel_eltron_setpoint_ffk "Set point FFK [%.1f °C]" { channel="modbus:heatpump:stiebelEltron:systemInformation#fek-temperature-setpoint" } +Number:Dimensionless stiebel_eltron_humidity_ffk "Humidity FFK [%.1f %%]" { channel="modbus:heatpump:stiebelEltron:systemInformation#fek-humidity" } +Number:Temperature stiebel_eltron_dewpoint_ffk "Dew point FFK [%.1f °C]" { channel="modbus:heatpump:stiebelEltron:systemInformation#fek-dewpoint" } + +Number:Temperature stiebel_eltron_outdoor_temp "Outdoor temperature [%.1f °C]" { channel="modbus:heatpump:stiebelEltron:systemInformation#outdoor-temperature" } +Number:Temperature stiebel_eltron_temp_hk1 "Temperature HK1 [%.1f °C]" { channel="modbus:heatpump:stiebelEltron:systemInformation#hk1-temperature" } +Number:Temperature stiebel_eltron_setpoint_hk1 "Set point HK1 [%.1f °C]" { channel="modbus:heatpump:stiebelEltron:systemInformation#hk1-temperature-setpoint" } +Number:Temperature stiebel_eltron_temp_water "Water temperature [%.1f °C]" { channel="modbus:heatpump:stiebelEltron:systemInformation#water-temperature" } +Number:Temperature stiebel_eltron_setpoint_water "Water setpoint [%.1f °C]" { channel="modbus:heatpump:stiebelEltron:systemInformation#water-temperature-setpoint" } +Number:Temperature stiebel_eltron_source_temp "Source temperature [%.1f °C]" { channel="modbus:heatpump:stiebelEltron:systemInformation#source-temperature" } +Number:Temperature stiebel_eltron_vorlauf_temp "Supply tempertature [%.1f °C]" { channel="modbus:heatpump:stiebelEltron:systemInformation#supply-temperature" } +Number:Temperature stiebel_eltron_ruecklauf_temp "Return temperature [%.1f °C]" { channel="modbus:heatpump:stiebelEltron:systemInformation#return-temperature" } + +Number stiebel_eltron_heating_comfort_temp "Heating Comfort Temperature [%.1f °C]" { channel="modbus:heatpump:stiebelEltron:systemParameter#comfort-temperature-heating" } +Number stiebel_eltron_heating_eco_temp "Heating Eco Temperature [%.1f °C]" { channel="modbus:heatpump:stiebelEltron:systemParameter#eco-temperature-heating" } +Number stiebel_eltron_water_comfort_temp "Water Comfort Temperature [%.1f °C]" { channel="modbus:heatpump:stiebelEltron:systemParameter#comfort-temperature-water" } +Number stiebel_eltron_water_eco_temp "Water Eco Temperature [%.1f °C]" { channel="modbus:heatpump:stiebelEltron:systemParameter#eco-temperature-water" } +Number stiebel_eltron_operation_mode "Operation Mode" { channel="modbus:heatpump:stiebelEltron:systemParameter#operation-mode" } + +Contact stiebel_eltron_mode_pump "Pump [%d]" { channel="modbus:heatpump:stiebelEltron:systemState#is-pumping" } +Contact stiebel_eltron_mode_heating "Heating [%d]" { channel="modbus:heatpump:stiebelEltron:systemState#is-heating" } +Contact stiebel_eltron_mode_water "Heating Water [%d]" { channel="modbus:heatpump:stiebelEltron:systemState#is-heating-water" } +Contact stiebel_eltron_mode_cooling "Cooling [%d]" { channel="modbus:heatpump:stiebelEltron:systemState#is-cooling" } +Contact stiebel_eltron_mode_summer "Summer Mode [%d]" { channel="modbus:heatpump:stiebelEltron:systemState#is-summer" } + + +Number:Energy stiebel_eltron_production_heat_today "Heat quantity today [%.0f kWh]" { channel="modbus:heatpump:stiebelEltron:energyInformation#production_heat_today" } +Number:Energy stiebel_eltron_production_heat_total "Heat quantity total [%.3f MWh]" {channel="modbus:heatpump:stiebelEltron:energyInformation#production_heat_total"} +Number:Energy stiebel_eltron_production_water_today "Water heat quantity today [%.0f kWh]" { channel="modbus:heatpump:stiebelEltron:energyInformation#production_water_today" } +Number:Energy stiebel_eltron_production_water_total "Water heat quantity total [%.3f MWh]" {channel="modbus:heatpump:stiebelEltron:energyInformation#production_water_total"} +Number:Energy stiebel_eltron_consumption_heat_total "Heating power consumption total [%.3f MWh]" {channel="modbus:heatpump:stiebelEltron:energyInformation#consumption_heat_total"} +Number:Energy stiebel_eltron_consumption_heat_today "Heating power consumption today [%.0f kWh]" { channel="modbus:heatpump:stiebelEltron:energyInformation#consumption_heat_today" } +Number:Energy stiebel_eltron_consumption_water_today "Water heating power consumption today [%.0f kWh]" { channel="modbus:heatpump:stiebelEltron:energyInformation#consumption_water_today" } +Number:Energy stiebel_eltron_consumption_water_total "Water heating power consumption total [%.3f MWh]" {channel="modbus:heatpump:stiebelEltron:energyInformation#consumption_water_total"} + + +``` + +### Sitemap Configuration + +``` + Text label="Heat pumpt" icon="temperature" { + Frame label="Optation Mode" { + Default item=stiebel_eltron_mode_pump + Default item=stiebel_eltron_mode_heating + Default item=stiebel_eltron_mode_water + Default item=stiebel_eltron_mode_cooling + Default item=stiebel_eltron_mode_summer + } + Frame label= "State" { + Default item=stiebel_eltron_operation_mode icon="settings" + Default item=stiebel_eltron_outdoor_temp icon="temperature" + Default item=stiebel_eltron_temp_hk1 icon="temperature" + Default item=stiebel_eltron_setpoint_hk1 icon="temperature" + Default item=stiebel_eltron_vorlauf_temp icon="temperature" + Default item=stiebel_eltron_ruecklauf_temp icon="temperature" + Default item=stiebel_eltron_temp_water icon="temperature" + Default item=stiebel_eltron_setpoint_water icon="temperature" + Default item=stiebel_eltron_temperature_ffk icon="temperature" + Default item=stiebel_eltron_setpoint_ffk icon="temperature" + Default item=stiebel_eltron_humidity_ffk icon="humidity" + Default item=stiebel_eltron_dewpoint_ffk icon="temperature" + Default item=stiebel_eltron_source_temp icon="temperature" + } + Frame label="Paramters" { + Setpoint item=stiebel_eltron_heating_comfort_temp icon="temperature" step=1 minValue=5 maxValue=30 + Setpoint item=stiebel_eltron_heating_eco_temp icon="temperature" step=1 minValue=5 maxValue=30 + Setpoint item=stiebel_eltron_water_comfort_temp icon="temperature" step=1 minValue=10 maxValue=60 + Setpoint item=stiebel_eltron_water_eco_temp icon="temperature" step=1 minValue=10 maxValue=60 + } + Frame label="Energy consumption" { + Default item=stiebel_eltron_consumption_heat_today icon="energy" + Default item=stiebel_eltron_consumption_heat_total icon="energy" + Default item=stiebel_eltron_consumption_water_today icon="energy" + Default item=stiebel_eltron_consumption_water_total icon="energy" + } + Frame label="Heat quantity" { + Default item=stiebel_eltron_production_heat_today icon="radiator" + Default item=stiebel_eltron_production_heat_total icon="radiator" + Default item=stiebel_eltron_production_water_today icon="water" + Default item=stiebel_eltron_production_water_total icon="water" + } + + } + +``` + + diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/pom.xml b/bundles/org.openhab.binding.modbus.stiebeleltron/pom.xml new file mode 100644 index 0000000000000..0cf89e85dd1d5 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/pom.xml @@ -0,0 +1,32 @@ + + + + 4.0.0 + + + org.openhab.addons.bundles + org.openhab.addons.reactor.bundles + 2.5.6-SNAPSHOT + + + org.openhab.binding.modbus.stiebeleltron + + openHAB Add-ons :: Bundles :: StiebelEltron Bundle + + + + org.openhab.addons.bundles + org.openhab.binding.modbus + ${project.version} + provided + + + org.openhab.addons.bundles + org.openhab.io.transport.modbus + ${project.version} + provided + + + + diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/feature/feature.xml b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/feature/feature.xml new file mode 100644 index 0000000000000..5e1f17a38ce85 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/feature/feature.xml @@ -0,0 +1,11 @@ + + + file:${basedirRoot}/bundles/org.openhab.io.transport.modbus/target/feature/feature.xml + + + openhab-runtime-base + openhab-transport-modbus + mvn:org.openhab.addons.bundles/org.openhab.binding.modbus/${project.version} + mvn:org.openhab.addons.bundles/org.openhab.binding.modbus.stiebeleltron/${project.version} + + diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronBindingConstants.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronBindingConstants.java new file mode 100644 index 0000000000000..cae2fd68ee8d3 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronBindingConstants.java @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.modbus.stiebeleltron.internal; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.smarthome.core.thing.ThingTypeUID; +import org.openhab.binding.modbus.ModbusBindingConstants; + +/** + * The {@link Modbus.StiebelEltronBindingConstants} class defines common + * constants, which are used across the whole binding. + * + * @author Paul Frank - Initial contribution + */ +@NonNullByDefault +public class StiebelEltronBindingConstants { + + private static final String BINDING_ID = ModbusBindingConstants.BINDING_ID; + + // List of all Thing Type UIDs + public static final ThingTypeUID THING_TYPE_SAMPLE = new ThingTypeUID(BINDING_ID, "heatpump"); + + // Channel group ids + public static final String GROUP_SYSTEM_STATE = "systemState"; + public static final String GROUP_SYSTEM_PARAMETER = "systemParameter"; + public static final String GROUP_SYSTEM_INFO = "systemInformation"; + public static final String GROUP_ENERGY_INFO = "energyInformation"; + + // List of all Channel ids in device information group + public static final String CHANNEL_FEK_TEMPERATURE = "fek-temperature"; + public static final String CHANNEL_FEK_TEMPERATURE_SETPOINT = "fek-temperature-setpoint"; + public static final String CHANNEL_FEK_HUMIDITY = "fek-humidity"; + public static final String CHANNEL_FEK_DEWPOINT = "fek-dewpoint"; + public static final String CHANNEL_OUTDOOR_TEMPERATURE = "outdoor-temperature"; + public static final String CHANNEL_HK1_TEMPERATURE = "hk1-temperature"; + public static final String CHANNEL_HK1_TEMPERATURE_SETPOINT = "hk1-temperature-setpoint"; + public static final String CHANNEL_SUPPLY_TEMPERATURE = "supply-temperature"; + public static final String CHANNEL_RETURN_TEMPERATURE = "return-temperature"; + public static final String CHANNEL_SOURCE_TEMPERATURE = "source-temperature"; + public static final String CHANNEL_WATER_TEMPERATURE = "water-temperature"; + public static final String CHANNEL_WATER_TEMPERATURE_SETPOINT = "water-temperature-setpoint"; + + public static final String CHANNEL_PRODUCTION_HEAT_TODAY = "production_heat_today"; + public static final String CHANNEL_PRODUCTION_HEAT_TOTAL = "production_heat_total"; + public static final String CHANNEL_PRODUCTION_WATER_TODAY = "production_water_today"; + public static final String CHANNEL_PRODUCTION_WATER_TOTAL = "production_water_total"; + public static final String CHANNEL_CONSUMPTION_HEAT_TODAY = "consumption_heat_today"; + public static final String CHANNEL_CONSUMPTION_HEAT_TOTAL = "consumption_heat_total"; + public static final String CHANNEL_CONSUMPTION_WATER_TODAY = "consumption_water_today"; + public static final String CHANNEL_CONSUMPTION_WATER_TOTAL = "consumption_water_total"; + + public static final String CHANNEL_IS_HEATING = "is-heating"; + public static final String CHANNEL_IS_HEATING_WATER = "is-heating-water"; + public static final String CHANNEL_IS_COOLING = "is-cooling"; + public static final String CHANNEL_IS_PUMPING = "is-pumping"; + public static final String CHANNEL_IS_SUMMER = "is-summer"; + + public static final String CHANNEL_OPERATION_MODE = "operation-mode"; + public static final String CHANNEL_COMFORT_TEMPERATURE_HEATING = "comfort-temperature-heating"; + public static final String CHANNEL_ECO_TEMPERATURE_HEATING = "eco-temperature-heating"; + public static final String CHANNEL_COMFORT_TEMPERATURE_WATER = "comfort-temperature-water"; + public static final String CHANNEL_ECO_TEMPERATURE_WATER = "eco-temperature-water"; +} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronConfiguration.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronConfiguration.java new file mode 100644 index 0000000000000..c496d8dcf7d5e --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronConfiguration.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.modbus.stiebeleltron.internal; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * The {@link Modbus.StiebelEltronConfiguration} class contains fields mapping + * thing configuration parameters. + * + * @author Paul Frank - Initial contribution + */ +@NonNullByDefault +public class StiebelEltronConfiguration { + /** + * Refresh interval in seconds + */ + private long refresh; + + private int maxTries = 3;// backwards compatibility and tests + + /** + * Gets refresh period in milliseconds + */ + public long getRefreshMillis() { + return refresh * 1000; + } + + public int getMaxTries() { + return maxTries; + } + + public void setMaxTries(int maxTries) { + this.maxTries = maxTries; + } + +} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronHandlerFactory.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronHandlerFactory.java new file mode 100644 index 0000000000000..debaea29f9de3 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronHandlerFactory.java @@ -0,0 +1,77 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.modbus.stiebeleltron.internal; + +import static org.openhab.binding.modbus.stiebeleltron.internal.StiebelEltronBindingConstants.THING_TYPE_SAMPLE; + +import java.util.Collections; +import java.util.Set; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.smarthome.core.thing.Thing; +import org.eclipse.smarthome.core.thing.ThingTypeUID; +import org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory; +import org.eclipse.smarthome.core.thing.binding.ThingHandler; +import org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory; +import org.openhab.binding.modbus.stiebeleltron.internal.handler.StiebelEltronHandler; +import org.openhab.io.transport.modbus.ModbusManager; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; + +/** + * The {@link Modbus.StiebelEltronHandlerFactory} is responsible for creating things and thing + * handlers. + * + * @author Paul Frank - Initial contribution + */ +@NonNullByDefault +@Component(configurationPid = "binding.stiebeleltron", service = ThingHandlerFactory.class) +public class StiebelEltronHandlerFactory extends BaseThingHandlerFactory { + + /** + * Reference to the modbus manager + */ + private ModbusManager manager; + + private static final Set SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_SAMPLE); + + /** + * This factory needs a reference to the ModbusManager wich is provided + * by the org.openhab.io.transport.modbus bundle. Please make + * sure it's installed and enabled before using this bundle + * + * @param manager reference to the ModbusManager. We use this for modbus communication + */ + @Activate + public StiebelEltronHandlerFactory(@Reference ModbusManager manager) { + this.manager = manager; + } + + @Override + public boolean supportsThingType(ThingTypeUID thingTypeUID) { + return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID); + } + + @Override + protected @Nullable ThingHandler createHandler(Thing thing) { + ThingTypeUID thingTypeUID = thing.getThingTypeUID(); + + if (THING_TYPE_SAMPLE.equals(thingTypeUID)) { + return new StiebelEltronHandler(thing, manager); + } + + return null; + } +} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/EnergyBlock.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/EnergyBlock.java new file mode 100644 index 0000000000000..3ddd8b54237be --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/EnergyBlock.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.modbus.stiebeleltron.internal.dto; + +/** + * Dto class for the Energy Block + * + * @author Paul Frank - Initial contribution + * + */ +public class EnergyBlock { + + public int production_heat_today; + public int production_heat_total_low; + public int production_heat_total_high; + public int production_water_today; + public int production_water_total_low; + public int production_water_total_high; + + public int consumption_heat_today; + public int consumption_heat_total_low; + public int consumption_heat_total_high; + public int consumption_water_today; + public int consumption_water_total_low; + public int consumption_water_total_high; +} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemInformationBlock.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemInformationBlock.java new file mode 100644 index 0000000000000..a3a6393fbece7 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemInformationBlock.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.modbus.stiebeleltron.internal.dto; + +/** + * Dto class for the System Information Block + * + * @author Paul Frank - Initial contribution + * + */ +public class SystemInformationBlock { + + public short temperature_fek; + public short temperature_fek_setpoint; + public short humidity_ffk; + public short dewpoint_ffk; + public short temperature_outdoor; + public short temperature_hk1; + public short temperature_hk1_setpoint; + public short temperature_supply; + public short temperature_return; + public short temperature_source; + public short temperature_water; + public short temperature_water_setpoint; +} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemParameterBlock.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemParameterBlock.java new file mode 100644 index 0000000000000..f709e2fb0de7a --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemParameterBlock.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.modbus.stiebeleltron.internal.dto; + +/** + * Dto class for the System Parameter Block + * + * @author Paul Frank - Initial contribution + * + */ +public class SystemParameterBlock { + + public Integer operation_mode; + public short comfort_temperature_heating; + public short eco_temperature_heating; + public short comfort_temperature_water; + public short eco_temperature_water; +} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemStateBlock.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemStateBlock.java new file mode 100644 index 0000000000000..d80b92f5492b0 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemStateBlock.java @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.modbus.stiebeleltron.internal.dto; + +/** + * Dto class for the System State Block + * + * @author Paul Frank - Initial contribution + * + */ +public class SystemStateBlock { + + public Integer state; +} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java new file mode 100644 index 0000000000000..2fb0f8b432f8e --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java @@ -0,0 +1,736 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.modbus.stiebeleltron.internal.handler; + +import static org.eclipse.smarthome.core.library.unit.SIUnits.CELSIUS; +import static org.eclipse.smarthome.core.library.unit.SmartHomeUnits.KILOWATT_HOUR; +import static org.eclipse.smarthome.core.library.unit.SmartHomeUnits.PERCENT; +import static org.openhab.binding.modbus.stiebeleltron.internal.StiebelEltronBindingConstants.*; + +import java.math.BigDecimal; +import java.util.Optional; + +import javax.measure.Unit; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.smarthome.core.library.types.DecimalType; +import org.eclipse.smarthome.core.library.types.OpenClosedType; +import org.eclipse.smarthome.core.library.types.QuantityType; +import org.eclipse.smarthome.core.thing.Bridge; +import org.eclipse.smarthome.core.thing.ChannelUID; +import org.eclipse.smarthome.core.thing.Thing; +import org.eclipse.smarthome.core.thing.ThingStatus; +import org.eclipse.smarthome.core.thing.ThingStatusDetail; +import org.eclipse.smarthome.core.thing.ThingStatusInfo; +import org.eclipse.smarthome.core.thing.binding.BaseThingHandler; +import org.eclipse.smarthome.core.thing.binding.ThingHandler; +import org.eclipse.smarthome.core.types.Command; +import org.eclipse.smarthome.core.types.RefreshType; +import org.eclipse.smarthome.core.types.State; +import org.openhab.binding.modbus.handler.EndpointNotInitializedException; +import org.openhab.binding.modbus.handler.ModbusEndpointThingHandler; +import org.openhab.binding.modbus.stiebeleltron.internal.StiebelEltronConfiguration; +import org.openhab.binding.modbus.stiebeleltron.internal.dto.EnergyBlock; +import org.openhab.binding.modbus.stiebeleltron.internal.dto.SystemInformationBlock; +import org.openhab.binding.modbus.stiebeleltron.internal.dto.SystemParameterBlock; +import org.openhab.binding.modbus.stiebeleltron.internal.dto.SystemStateBlock; +import org.openhab.binding.modbus.stiebeleltron.internal.parser.EnergyBlockParser; +import org.openhab.binding.modbus.stiebeleltron.internal.parser.SystemInfromationBlockParser; +import org.openhab.binding.modbus.stiebeleltron.internal.parser.SystemParameterBlockParser; +import org.openhab.binding.modbus.stiebeleltron.internal.parser.SystemStateBlockParser; +import org.openhab.io.transport.modbus.BasicModbusReadRequestBlueprint; +import org.openhab.io.transport.modbus.BasicModbusRegister; +import org.openhab.io.transport.modbus.BasicModbusRegisterArray; +import org.openhab.io.transport.modbus.BasicModbusWriteRegisterRequestBlueprint; +import org.openhab.io.transport.modbus.BasicPollTaskImpl; +import org.openhab.io.transport.modbus.BasicWriteTask; +import org.openhab.io.transport.modbus.BitArray; +import org.openhab.io.transport.modbus.ModbusManager; +import org.openhab.io.transport.modbus.ModbusReadCallback; +import org.openhab.io.transport.modbus.ModbusReadFunctionCode; +import org.openhab.io.transport.modbus.ModbusReadRequestBlueprint; +import org.openhab.io.transport.modbus.ModbusRegister; +import org.openhab.io.transport.modbus.ModbusRegisterArray; +import org.openhab.io.transport.modbus.ModbusResponse; +import org.openhab.io.transport.modbus.ModbusWriteCallback; +import org.openhab.io.transport.modbus.ModbusWriteRequestBlueprint; +import org.openhab.io.transport.modbus.PollTask; +import org.openhab.io.transport.modbus.endpoint.ModbusSlaveEndpoint; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * The {@link Modbus.StiebelEltronHandler} is responsible for handling commands, + * which are sent to one of the channels and for polling the modbus. + * + * @author Paul Frank - Initial contribution + */ +@NonNullByDefault +public class StiebelEltronHandler extends BaseThingHandler { + + public abstract class AbstractBasePoller { + /** + * Logger instance + */ + private final Logger logger = LoggerFactory.getLogger(StiebelEltronHandler.class); + + private volatile @Nullable PollTask pollTask; + + public AbstractBasePoller() { + } + + public synchronized void unregisterPollTask() { + @Nullable + PollTask task = pollTask; + if (task == null) { + return; + } + logger.debug("Unregistering polling from ModbusManager"); + StiebelEltronHandler.this.modbusManager.unregisterRegularPoll(task); + + pollTask = null; + + } + + /** + * Register poll task This is where we set up our regular poller + */ + public synchronized void registerPollTask(int address, int length, ModbusReadFunctionCode readFunctionCode) { + + logger.debug("Setting up regular polling"); + + @Nullable + ModbusSlaveEndpoint myendpoint = StiebelEltronHandler.this.endpoint; + @Nullable + StiebelEltronConfiguration myconfig = StiebelEltronHandler.this.config; + if (myconfig == null || myendpoint == null) { + throw new IllegalStateException("registerPollTask called without proper configuration"); + } + + logger.debug("Setting up regular polling"); + + BasicModbusReadRequestBlueprint request = new BasicModbusReadRequestBlueprint(getSlaveId(), + readFunctionCode, address, length, myconfig.getMaxTries()); + + pollTask = new BasicPollTaskImpl(myendpoint, request, new ModbusReadCallback() { + + @Override + public void onRegisters(@Nullable ModbusReadRequestBlueprint request, + @Nullable ModbusRegisterArray registers) { + if (registers == null) { + logger.info("Received empty register array on poll"); + return; + } + try { + handlePolledData(registers); + + if (StiebelEltronHandler.this.getThing().getStatus() != ThingStatus.ONLINE) { + updateStatus(ThingStatus.ONLINE); + } + } catch (Exception error) { + StiebelEltronHandler.this.handleError(error); + } + } + + @Override + public void onError(@Nullable ModbusReadRequestBlueprint request, @Nullable Exception error) { + StiebelEltronHandler.this.handleError(error); + } + + @Override + public void onBits(@Nullable ModbusReadRequestBlueprint request, @Nullable BitArray bits) { + // don't care, we don't expect this result + } + }); + + long refreshMillis = myconfig.getRefreshMillis(); + @Nullable + PollTask task = pollTask; + if (task != null) { + StiebelEltronHandler.this.modbusManager.registerRegularPoll(task, refreshMillis, 1000); + } + } + + protected abstract void handlePolledData(ModbusRegisterArray registers); + + } + + /** + * Logger instance + */ + private final Logger logger = LoggerFactory.getLogger(StiebelEltronHandler.class); + + /** + * Configuration instance + */ + protected @Nullable StiebelEltronConfiguration config = null; + /** + * Parser used to convert incoming raw messages into system blocks + */ + private final SystemInfromationBlockParser systemInformationBlockParser = new SystemInfromationBlockParser(); + /** + * Parser used to convert incoming raw messages into system state blocks + */ + private final SystemStateBlockParser systemstateBlockParser = new SystemStateBlockParser(); + /** + * Parser used to convert incoming raw messages into system parameter blocks + */ + private final SystemParameterBlockParser systemParameterBlockParser = new SystemParameterBlockParser(); + /** + * Parser used to convert incoming raw messages into model blocks + */ + private final EnergyBlockParser energyBlockParser = new EnergyBlockParser(); + /** + * This is the task used to poll the device + */ + private volatile @Nullable AbstractBasePoller systemInformationPoller = null; + /** + * This is the task used to poll the device + */ + private volatile @Nullable AbstractBasePoller energyPoller = null; + /** + * This is the task used to poll the device + */ + private volatile @Nullable AbstractBasePoller systemStatePoller = null; + /** + * This is the task used to poll the device + */ + private volatile @Nullable AbstractBasePoller systemParameterPoller = null; + /** + * This is the slave endpoint we're connecting to + */ + protected volatile @Nullable ModbusSlaveEndpoint endpoint = null; + + /** + * This is the slave id, we store this once initialization is complete + */ + private volatile int slaveId; + + /** + * Reference to the modbus manager + */ + protected ModbusManager modbusManager; + + /** + * Instances of this handler should get a reference to the modbus manager + * + * @param thing the thing to handle + * @param modbusManager the modbus manager + */ + public StiebelEltronHandler(Thing thing, ModbusManager modbusManager) { + super(thing); + this.modbusManager = modbusManager; + } + + /** + * @param address address of the value to be written on the modbus + * @param shortValue value to be written on the modbus + */ + protected void writeInt16(int address, short shortValue) { + @Nullable + StiebelEltronConfiguration myconfig = StiebelEltronHandler.this.config; + if (myconfig == null) { + throw new IllegalStateException("registerPollTask called without proper configuration"); + } + // big endian byte ordering + byte b1 = (byte) (shortValue >> 8); + byte b2 = (byte) shortValue; + + ModbusRegister register = new BasicModbusRegister(b1, b2); + ModbusRegisterArray data = new BasicModbusRegisterArray(new ModbusRegister[] { register }); + + BasicModbusWriteRegisterRequestBlueprint request = new BasicModbusWriteRegisterRequestBlueprint(slaveId, + address, data, false, myconfig.getMaxTries()); + + ModbusSlaveEndpoint slaveEndpoint = this.endpoint; + if (slaveEndpoint == null) { + return; + } + + BasicWriteTask writeTask = new BasicWriteTask(slaveEndpoint, request, new ModbusWriteCallback() { + @Override + public void onWriteResponse(ModbusWriteRequestBlueprint request, ModbusResponse response) { + if (hasConfigurationError()) { + return; + } + logger.debug("Successful write, matching request {}", request); + StiebelEltronHandler.this.updateStatus(ThingStatus.ONLINE); + } + + @Override + public void onError(ModbusWriteRequestBlueprint request, Exception error) { + StiebelEltronHandler.this.handleError(error); + } + }); + logger.trace("Submitting write task: {}", writeTask); + modbusManager.submitOneTimeWrite(writeTask); + } + + /** + * @param command get the value of this command. + * @return short the value of the command multiplied by 10 (see datatype 2 in the stiebel eltron modbus + * documentation) + */ + private short getScaledInt16Value(Command command) { + if (command instanceof QuantityType) { + QuantityType c = (QuantityType) command; + return (short) (c.doubleValue() * 10); + } + if (command instanceof DecimalType) { + DecimalType c = (DecimalType) command; + return (short) (c.doubleValue() * 10); + } + return 0; + } + + /** + * @param command get the value of this command. + * @return short the value of the command as short + */ + private short getInt16Value(Command command) { + if (command instanceof DecimalType) { + DecimalType c = (DecimalType) command; + return c.shortValue(); + } + return 0; + } + + /** + * Handle incoming commands. + */ + @Override + public void handleCommand(ChannelUID channelUID, Command command) { + if (RefreshType.REFRESH == command) { + // TODO: Implement refresh + } else { + if (GROUP_SYSTEM_PARAMETER.equals(channelUID.getGroupId())) { + switch (channelUID.getIdWithoutGroup()) { + case CHANNEL_OPERATION_MODE: + writeInt16(1500, getInt16Value(command)); + break; + case CHANNEL_COMFORT_TEMPERATURE_HEATING: + writeInt16(1501, getScaledInt16Value(command)); + break; + case CHANNEL_ECO_TEMPERATURE_HEATING: + writeInt16(1502, getScaledInt16Value(command)); + break; + case CHANNEL_COMFORT_TEMPERATURE_WATER: + writeInt16(1509, getScaledInt16Value(command)); + break; + case CHANNEL_ECO_TEMPERATURE_WATER: + writeInt16(1510, getScaledInt16Value(command)); + break; + } + } + } + } + + /** + * Initialization: Load the config object of the block Connect to the slave + * bridge Start the periodic polling + */ + @Override + public void initialize() { + config = getConfigAs(StiebelEltronConfiguration.class); + logger.debug("Initializing thing with properties: {}", thing.getProperties()); + + startUp(); + } + + /* + * This method starts the operation of this handler + * Connect to the slave bridge Start the periodic polling + */ + private void startUp() { + + connectEndpoint(); + + if (endpoint == null || config == null) { + logger.debug("Invalid endpoint/config/manager ref for sunspec handler"); + return; + } + + updateStatus(ThingStatus.UNKNOWN); + + if (systemInformationPoller == null) { + AbstractBasePoller poller = new AbstractBasePoller() { + @Override + protected void handlePolledData(ModbusRegisterArray registers) { + handlePolledSystemInformationData(registers); + } + + }; + poller.registerPollTask(500, 36, ModbusReadFunctionCode.READ_INPUT_REGISTERS); + systemInformationPoller = poller; + } + if (energyPoller == null) { + AbstractBasePoller poller = new AbstractBasePoller() { + @Override + protected void handlePolledData(ModbusRegisterArray registers) { + handlePolledEnergyData(registers); + } + + }; + poller.registerPollTask(3500, 16, ModbusReadFunctionCode.READ_INPUT_REGISTERS); + energyPoller = poller; + } + if (systemStatePoller == null) { + AbstractBasePoller poller = new AbstractBasePoller() { + @Override + protected void handlePolledData(ModbusRegisterArray registers) { + handlePolledSystemStateData(registers); + } + + }; + poller.registerPollTask(2500, 2, ModbusReadFunctionCode.READ_INPUT_REGISTERS); + systemStatePoller = poller; + } + if (systemParameterPoller == null) { + AbstractBasePoller poller = new AbstractBasePoller() { + @Override + protected void handlePolledData(ModbusRegisterArray registers) { + handlePolledSystemParameterData(registers); + } + + }; + poller.registerPollTask(1500, 11, ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS); + systemParameterPoller = poller; + } + } + + /** + * Dispose the binding correctly + */ + @Override + public void dispose() { + tearDown(); + } + + /** + * Unregister the poll tasks and release the endpoint reference + */ + private void tearDown() { + logger.trace("unregisterPollTasks"); + if (systemInformationPoller != null) { + logger.debug("Unregistering systemInformationPoller from ModbusManager"); + systemInformationPoller.unregisterPollTask(); + + systemInformationPoller = null; + } + if (energyPoller != null) { + logger.debug("Unregistering energyPoller from ModbusManager"); + energyPoller.unregisterPollTask(); + + energyPoller = null; + } + if (systemStatePoller != null) { + logger.debug("Unregistering systemStatePoller from ModbusManager"); + systemStatePoller.unregisterPollTask(); + + systemStatePoller = null; + } + if (systemParameterPoller != null) { + logger.debug("Unregistering systemParameterPoller from ModbusManager"); + systemParameterPoller.unregisterPollTask(); + + systemParameterPoller = null; + } + + unregisterEndpoint(); + } + + /** + * Returns the current slave id from the bridge + */ + public int getSlaveId() { + return slaveId; + } + + /** + * Get the endpoint handler from the bridge this handler is connected to Checks + * that we're connected to the right type of bridge + * + * @return the endpoint handler or null if the bridge does not exist + */ + private @Nullable ModbusEndpointThingHandler getEndpointThingHandler() { + Bridge bridge = getBridge(); + if (bridge == null) { + logger.debug("Bridge is null"); + return null; + } + if (bridge.getStatus() != ThingStatus.ONLINE) { + logger.debug("Bridge is not online"); + return null; + } + + ThingHandler handler = bridge.getHandler(); + if (handler == null) { + logger.debug("Bridge handler is null"); + return null; + } + + if (handler instanceof ModbusEndpointThingHandler) { + ModbusEndpointThingHandler slaveEndpoint = (ModbusEndpointThingHandler) handler; + return slaveEndpoint; + } else { + logger.debug("Unexpected bridge handler: {}", handler); + throw new IllegalStateException(); + } + } + + /** + * Get a reference to the modbus endpoint + */ + private void connectEndpoint() { + if (endpoint != null) { + return; + } + + ModbusEndpointThingHandler slaveEndpointThingHandler = getEndpointThingHandler(); + if (slaveEndpointThingHandler == null) { + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, String.format("Bridge '%s' is offline", + Optional.ofNullable(getBridge()).map(b -> b.getLabel()).orElse(""))); + logger.debug("No bridge handler available -- aborting init for {}", this); + return; + } + + try { + slaveId = slaveEndpointThingHandler.getSlaveId(); + + endpoint = slaveEndpointThingHandler.asSlaveEndpoint(); + } catch (EndpointNotInitializedException e) { + // this will be handled below as endpoint remains null + } + + if (endpoint == null) { + @SuppressWarnings("null") + String label = Optional.ofNullable(getBridge()).map(b -> b.getLabel()).orElse(""); + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, + String.format("Bridge '%s' not completely initialized", label)); + logger.debug("Bridge not initialized fully (no endpoint) -- aborting init for {}", this); + return; + } + } + + /** + * Remove the endpoint if exists + */ + private synchronized void unregisterEndpoint() { + endpoint = null; + } + + /** + * Returns value divided by the 10 + * + * @param value the value to alter + * @return the scaled value as a DecimalType + */ + protected State getScaled(Number value, Unit unit) { + return new QuantityType<>(BigDecimal.valueOf(value.longValue(), 1), unit); + } + + /** + * Returns high value * 1000 + low value + * + * @param high the high value + * @param low the low valze + * @return the scaled value as a DecimalType + */ + protected State getEnergyQuantity(int high, int low) { + double value = high * 1000 + low; + return new QuantityType<>(value, KILOWATT_HOUR); + } + + /** + * This method is called each time new data has been polled from the modbus + * slave The register array is first parsed, then each of the channels are + * updated to the new values + * + * @param registers byte array read from the modbus slave + */ + protected void handlePolledSystemInformationData(ModbusRegisterArray registers) { + logger.trace("System Information block received, size: {}", registers.size()); + + SystemInformationBlock block = systemInformationBlockParser.parse(registers); + + // System information group + updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_FEK_TEMPERATURE), getScaled(block.temperature_fek, CELSIUS)); + updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_FEK_TEMPERATURE_SETPOINT), + getScaled(block.temperature_fek_setpoint, CELSIUS)); + updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_FEK_HUMIDITY), getScaled(block.humidity_ffk, PERCENT)); + updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_FEK_DEWPOINT), getScaled(block.dewpoint_ffk, CELSIUS)); + updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_OUTDOOR_TEMPERATURE), + getScaled(block.temperature_outdoor, CELSIUS)); + updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_HK1_TEMPERATURE), getScaled(block.temperature_hk1, CELSIUS)); + updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_HK1_TEMPERATURE_SETPOINT), + getScaled(block.temperature_hk1_setpoint, CELSIUS)); + updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_SUPPLY_TEMPERATURE), + getScaled(block.temperature_supply, CELSIUS)); + updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_RETURN_TEMPERATURE), + getScaled(block.temperature_return, CELSIUS)); + updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_SOURCE_TEMPERATURE), + getScaled(block.temperature_source, CELSIUS)); + updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_WATER_TEMPERATURE), + getScaled(block.temperature_water, CELSIUS)); + updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_WATER_TEMPERATURE_SETPOINT), + getScaled(block.temperature_water_setpoint, CELSIUS)); + } + + /** + * This method is called each time new data has been polled from the modbus + * slave The register array is first parsed, then each of the channels are + * updated to the new values + * + * @param registers byte array read from the modbus slave + */ + protected void handlePolledEnergyData(ModbusRegisterArray registers) { + logger.trace("Energy block received, size: {}", registers.size()); + + EnergyBlock block = energyBlockParser.parse(registers); + + // Energy information group + updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_PRODUCTION_HEAT_TODAY), + new QuantityType<>(block.production_heat_today, KILOWATT_HOUR)); + updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_PRODUCTION_HEAT_TOTAL), + getEnergyQuantity(block.production_heat_total_high, block.production_heat_total_low)); + updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_PRODUCTION_WATER_TODAY), + new QuantityType<>(block.production_water_today, KILOWATT_HOUR)); + updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_PRODUCTION_WATER_TOTAL), + getEnergyQuantity(block.production_water_total_high, block.production_water_total_low)); + updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_CONSUMPTION_HEAT_TODAY), + new QuantityType<>(block.consumption_heat_today, KILOWATT_HOUR)); + updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_CONSUMPTION_HEAT_TOTAL), + getEnergyQuantity(block.consumption_heat_total_high, block.consumption_heat_total_low)); + updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_CONSUMPTION_WATER_TODAY), + new QuantityType<>(block.consumption_water_today, KILOWATT_HOUR)); + updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_CONSUMPTION_WATER_TOTAL), + getEnergyQuantity(block.consumption_water_total_high, block.consumption_water_total_low)); + } + + /** + * This method is called each time new data has been polled from the modbus + * slave The register array is first parsed, then each of the channels are + * updated to the new values + * + * @param registers byte array read from the modbus slave + */ + protected void handlePolledSystemStateData(ModbusRegisterArray registers) { + logger.trace("System state block received, size: {}", registers.size()); + + SystemStateBlock block = systemstateBlockParser.parse(registers); + boolean is_heating = (block.state & 16) != 0; + updateState(channelUID(GROUP_SYSTEM_STATE, CHANNEL_IS_HEATING), + is_heating ? OpenClosedType.OPEN : OpenClosedType.CLOSED); + updateState(channelUID(GROUP_SYSTEM_STATE, CHANNEL_IS_HEATING_WATER), + (block.state & 32) != 0 ? OpenClosedType.OPEN : OpenClosedType.CLOSED); + updateState(channelUID(GROUP_SYSTEM_STATE, CHANNEL_IS_COOLING), + (block.state & 256) != 0 ? OpenClosedType.OPEN : OpenClosedType.CLOSED); + updateState(channelUID(GROUP_SYSTEM_STATE, CHANNEL_IS_SUMMER), + (block.state & 128) != 0 ? OpenClosedType.OPEN : OpenClosedType.CLOSED); + updateState(channelUID(GROUP_SYSTEM_STATE, CHANNEL_IS_PUMPING), + (block.state & 1) != 0 ? OpenClosedType.OPEN : OpenClosedType.CLOSED); + + } + + /** + * This method is called each time new data has been polled from the modbus + * slave The register array is first parsed, then each of the channels are + * updated to the new values + * + * @param registers byte array read from the modbus slave + */ + protected void handlePolledSystemParameterData(ModbusRegisterArray registers) { + logger.trace("System state block received, size: {}", registers.size()); + + SystemParameterBlock block = systemParameterBlockParser.parse(registers); + updateState(channelUID(GROUP_SYSTEM_PARAMETER, CHANNEL_OPERATION_MODE), new DecimalType(block.operation_mode)); + + updateState(channelUID(GROUP_SYSTEM_PARAMETER, CHANNEL_COMFORT_TEMPERATURE_HEATING), + getScaled(block.comfort_temperature_heating, CELSIUS)); + updateState(channelUID(GROUP_SYSTEM_PARAMETER, CHANNEL_ECO_TEMPERATURE_HEATING), + getScaled(block.eco_temperature_heating, CELSIUS)); + updateState(channelUID(GROUP_SYSTEM_PARAMETER, CHANNEL_COMFORT_TEMPERATURE_WATER), + getScaled(block.comfort_temperature_water, CELSIUS)); + updateState(channelUID(GROUP_SYSTEM_PARAMETER, CHANNEL_ECO_TEMPERATURE_WATER), + getScaled(block.eco_temperature_water, CELSIUS)); + } + + /** + * @param bridgeStatusInfo + */ + @Override + public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { + super.bridgeStatusChanged(bridgeStatusInfo); + + logger.debug("Thing status changed to {}", this.getThing().getStatus().name()); + if (getThing().getStatus() == ThingStatus.ONLINE) { + startUp(); + } else if (getThing().getStatus() == ThingStatus.OFFLINE) { + tearDown(); + } + } + + /** + * Handle errors received during communication + */ + protected void handleError(@Nullable Exception error) { + // Ignore all incoming data and errors if configuration is not correct + if (hasConfigurationError() || getThing().getStatus() == ThingStatus.OFFLINE) { + return; + } + String msg = ""; + String cls = ""; + if (error != null) { + cls = error.getClass().getName(); + msg = error.getMessage(); + } + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, + String.format("Error with read: %s: %s", cls, msg)); + } + + /** + * Returns true, if we're in a CONFIGURATION_ERROR state + * + * @return + */ + protected boolean hasConfigurationError() { + ThingStatusInfo statusInfo = getThing().getStatusInfo(); + return statusInfo.getStatus() == ThingStatus.OFFLINE + && statusInfo.getStatusDetail() == ThingStatusDetail.CONFIGURATION_ERROR; + } + + /** + * Reset communication status to ONLINE if we're in an OFFLINE state + */ + protected void resetCommunicationError() { + ThingStatusInfo statusInfo = thing.getStatusInfo(); + if (ThingStatus.OFFLINE.equals(statusInfo.getStatus()) + && ThingStatusDetail.COMMUNICATION_ERROR.equals(statusInfo.getStatusDetail())) { + updateStatus(ThingStatus.ONLINE); + } + } + + /** + * Returns the channel UID for the specified group and channel id + * + * @param string the channel group + * @param string the channel id in that group + * @return the globally unique channel uid + */ + ChannelUID channelUID(String group, String id) { + return new ChannelUID(getThing().getUID(), group, id); + } + +} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/AbstractBaseParser.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/AbstractBaseParser.java new file mode 100644 index 0000000000000..0d7f8342ae0e7 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/AbstractBaseParser.java @@ -0,0 +1,128 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.modbus.stiebeleltron.internal.parser; + +import java.util.Optional; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.smarthome.core.library.types.DecimalType; +import org.openhab.io.transport.modbus.ModbusBitUtilities; +import org.openhab.io.transport.modbus.ModbusConstants.ValueType; +import org.openhab.io.transport.modbus.ModbusRegisterArray; + +/** + * Base class for parsers with some helper methods + * + * @author Nagy Attila Gabor - Initial contribution + * @author Paul Frank - Added more methods + */ +@NonNullByDefault +public class AbstractBaseParser { + + /** + * Extract an optional double value + * + * @param raw the register array to extract from + * @param index the address of the field + * @return the parsed value or empty if the field is not implemented + */ + protected Optional extractOptionalDouble(ModbusRegisterArray raw, int index) { + return ModbusBitUtilities.extractStateFromRegisters(raw, index, ValueType.INT16) + .map(value -> ((float) value.intValue()) / 10.0).filter(value -> value != (short) 0x8000); + } + + /** + * Extract a mandatory double value + * + * @param raw the register array to extract from + * @param index the address of the field + * @param def the default value + * @return the parsed value or the default if the field is not implemented + */ + protected Double extractDouble(ModbusRegisterArray raw, int index, double def) { + return extractOptionalDouble(raw, index).orElse(def); + } + + /** + * Extract an optional int16 value + * + * @param raw the register array to extract from + * @param index the address of the field + * @return the parsed value or empty if the field is not implemented + */ + protected Optional extractOptionalInt16(ModbusRegisterArray raw, int index) { + return ModbusBitUtilities.extractStateFromRegisters(raw, index, ValueType.INT16).map(DecimalType::shortValue) + .filter(value -> value != (short) 0x8000); + } + + /** + * Extract a mandatory int16 value + * + * @param raw the register array to extract from + * @param index the address of the field + * @param def the default value + * @return the parsed value or the default if the field is not implemented + */ + protected Short extractInt16(ModbusRegisterArray raw, int index, short def) { + return extractOptionalInt16(raw, index).orElse(def); + } + + /** + * Extract an optional uint16 value + * + * @param raw the register array to extract from + * @param index the address of the field + * @return the parsed value or empty if the field is not implemented + */ + protected Optional extractOptionalUInt16(ModbusRegisterArray raw, int index) { + return ModbusBitUtilities.extractStateFromRegisters(raw, index, ValueType.UINT16).map(DecimalType::intValue) + .filter(value -> value != 0xffff); + } + + /** + * Extract a mandatory uint16 value + * + * @param raw the register array to extract from + * @param index the address of the field + * @param def the default value + * @return the parsed value or the default if the field is not implemented + */ + protected Integer extractUInt16(ModbusRegisterArray raw, int index, int def) { + return extractOptionalUInt16(raw, index).orElse(def); + } + + /** + * Extract an optional acc32 value + * + * @param raw the register array to extract from + * @param index the address of the field + * @return the parsed value or empty if the field is not implemented + */ + protected Optional extractOptionalUInt32(ModbusRegisterArray raw, int index) { + return ModbusBitUtilities.extractStateFromRegisters(raw, index, ValueType.UINT32).map(DecimalType::longValue) + .filter(value -> value != 0); + } + + /** + * Extract a mandatory acc32 value + * + * @param raw the register array to extract from + * @param index the address of the field + * @param def the default value + * @return the parsed value or default if the field is not implemented + */ + protected Long extractUnit32(ModbusRegisterArray raw, int index, long def) { + return extractOptionalUInt32(raw, index).orElse(def); + } + +} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/EnergyBlockParser.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/EnergyBlockParser.java new file mode 100644 index 0000000000000..59337914ab467 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/EnergyBlockParser.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.modbus.stiebeleltron.internal.parser; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.modbus.stiebeleltron.internal.dto.EnergyBlock; +import org.openhab.io.transport.modbus.ModbusRegisterArray; + +/** + * Parses inverter modbus data into an Energy Block + * + * @author Paul Frank - Initial contribution + * + */ +@NonNullByDefault +public class EnergyBlockParser extends AbstractBaseParser { + + public EnergyBlock parse(ModbusRegisterArray raw) { + EnergyBlock block = new EnergyBlock(); + + block.production_heat_today = extractUInt16(raw, 0, (short) 0); + block.production_heat_total_low = extractUInt16(raw, 1, (short) 0); + block.production_heat_total_high = extractUInt16(raw, 2, (short) 0); + block.production_water_today = extractUInt16(raw, 3, (short) 0); + block.production_water_total_low = extractUInt16(raw, 4, (short) 0); + block.production_water_total_high = extractUInt16(raw, 5, (short) 0); + + block.consumption_heat_today = extractUInt16(raw, 10, (short) 0); + block.consumption_heat_total_low = extractUInt16(raw, 11, (short) 0); + block.consumption_heat_total_high = extractUInt16(raw, 12, (short) 0); + block.consumption_water_today = extractUInt16(raw, 13, (short) 0); + block.consumption_water_total_low = extractUInt16(raw, 14, (short) 0); + block.consumption_water_total_high = extractUInt16(raw, 15, (short) 0); + return block; + } +} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/SystemInfromationBlockParser.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/SystemInfromationBlockParser.java new file mode 100644 index 0000000000000..ae5cc905d6338 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/SystemInfromationBlockParser.java @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.modbus.stiebeleltron.internal.parser; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.modbus.stiebeleltron.internal.dto.SystemInformationBlock; +import org.openhab.io.transport.modbus.ModbusRegisterArray; + +/** + * Parses inverter modbus data into an SystemB Information lock + * + * @author Paul Frank - Initial contribution + * + */ +@NonNullByDefault +public class SystemInfromationBlockParser extends AbstractBaseParser { + + public SystemInformationBlock parse(ModbusRegisterArray raw) { + SystemInformationBlock block = new SystemInformationBlock(); + + block.temperature_fek = extractInt16(raw, 2, (short) 0); + block.temperature_fek_setpoint = extractInt16(raw, 3, (short) 0); + block.humidity_ffk = extractInt16(raw, 4, (short) 0); + block.dewpoint_ffk = extractInt16(raw, 5, (short) 0); + block.temperature_outdoor = extractInt16(raw, 6, (short) 0); + block.temperature_hk1 = extractInt16(raw, 7, (short) 0); + block.temperature_hk1_setpoint = extractInt16(raw, 9, (short) 0); + block.temperature_supply = extractInt16(raw, 12, (short) 0); + block.temperature_return = extractInt16(raw, 15, (short) 0); + block.temperature_water = extractInt16(raw, 21, (short) 0); + block.temperature_water_setpoint = extractInt16(raw, 22, (short) 0); + block.temperature_source = extractInt16(raw, 35, (short) 0); + return block; + } +} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/SystemParameterBlockParser.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/SystemParameterBlockParser.java new file mode 100644 index 0000000000000..88e0ec6d5387d --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/SystemParameterBlockParser.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.modbus.stiebeleltron.internal.parser; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.modbus.stiebeleltron.internal.dto.SystemParameterBlock; +import org.openhab.io.transport.modbus.ModbusRegisterArray; + +/** + * Parses inverter modbus data into an System Parameter Block + * + * @author Paul Frank - Initial contribution + * + */ +@NonNullByDefault +public class SystemParameterBlockParser extends AbstractBaseParser { + + public SystemParameterBlock parse(ModbusRegisterArray raw) { + SystemParameterBlock block = new SystemParameterBlock(); + + block.operation_mode = extractUInt16(raw, 0, 0); + block.comfort_temperature_heating = extractInt16(raw, 1, (short) 0); + block.eco_temperature_heating = extractInt16(raw, 2, (short) 0); + block.comfort_temperature_water = extractInt16(raw, 9, (short) 0); + block.eco_temperature_water = extractInt16(raw, 10, (short) 0); + return block; + } +} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/SystemStateBlockParser.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/SystemStateBlockParser.java new file mode 100644 index 0000000000000..a49d8388a5aa5 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/SystemStateBlockParser.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.modbus.stiebeleltron.internal.parser; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.modbus.stiebeleltron.internal.dto.SystemStateBlock; +import org.openhab.io.transport.modbus.ModbusRegisterArray; + +/** + * Parses inverter modbus data into an System State Block + * + * @author Paul Frank - Initial contribution + * + */ +@NonNullByDefault +public class SystemStateBlockParser extends AbstractBaseParser { + + public SystemStateBlock parse(ModbusRegisterArray raw) { + SystemStateBlock block = new SystemStateBlock(); + + block.state = extractUInt16(raw, 0, 0); + return block; + } +} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/config/config-descriptions.xml b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/config/config-descriptions.xml new file mode 100644 index 0000000000000..501ccd03cf6a3 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/config/config-descriptions.xml @@ -0,0 +1,25 @@ + + + + + + + + Poll interval in seconds. Use zero to disable automatic polling. + 5 + s + + + + + 3 + Number of tries when reading data, if some of the reading fail. For single try, enter 1. + true + + + + + diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/i18n/modbus.stiebeleltron_xx_XX.properties b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/i18n/modbus.stiebeleltron_xx_XX.properties new file mode 100644 index 0000000000000..666d68d7acd33 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/i18n/modbus.stiebeleltron_xx_XX.properties @@ -0,0 +1,17 @@ +# FIXME: please substitute the xx_XX with a proper locale, ie. de_DE +# FIXME: please do not add the file to the repo if you add or change no content +# binding +binding.modbus.stiebeleltron.name = +binding.modbus.stiebeleltron.description = + +# thing types +thing-type.modbus.stiebeleltron.sample.label = +thing-type.modbus.stiebeleltron.sample.description = + +# thing type config description +thing-type.config.modbus.stiebeleltron.sample.config1.label = +thing-type.config.modbus.stiebeleltron.sample.config1.description = + +# channel types +channel-type.modbus.stiebeleltron.sample-channel.label = +channel-type.modbus.stiebeleltron.sample-channel.description = diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-groups.xml b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-groups.xml new file mode 100644 index 0000000000000..01ca5fb0e6f5e --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-groups.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-types.xml b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-types.xml new file mode 100644 index 0000000000000..4938fde06da50 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-types.xml @@ -0,0 +1,171 @@ + + + + + Number:Temperature + + + + + + Number:Temperature + + + + + Number:Dimensionless + + + + + Number:Temperature + + + + + Number:Temperature + + + + + + Number:Temperature + + + + + Number:Temperature + + + + + Number:Temperature + + + + + Number:Temperature + + + + + Number:Temperature + + + + + Number:Temperature + + + + + Number:Temperature + + + + + + + Number:Energy + + + + + Number:Energy + + + + + Number:Energy + + + + + Number:Energy + + + + + + Number:Energy + + + + + Number:Energy + + + + + Number:Energy + + + + + Number:Energy + + + + + Contact + + + + + Contact + + + + + Contact + + + + + Contact + + + + + Contact + + + + + Number + + + + + + + + + + + + + + Number:Temperature + + + + + Number:Temperature + + + + + Number:Temperature + + + + + Number:Temperature + + + + diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-types.xml b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-types.xml new file mode 100644 index 0000000000000..0e3f262775918 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-types.xml @@ -0,0 +1,27 @@ + + + + + + + + + + Stiebel Eltron ISG connected through modbus + + + + + + + + + + + + + + diff --git a/bundles/pom.xml b/bundles/pom.xml index 18e000ff456d1..7ac0dd9ee188d 100644 --- a/bundles/pom.xml +++ b/bundles/pom.xml @@ -1,522 +1,981 @@ 4.0.0 - + + org.openhab.addons + org.openhab.addons.reactor 2.5.9-SNAPSHOT - + org.openhab.addons.bundles + org.openhab.addons.reactor.bundles + pom - + openHAB Add-ons :: Bundles - + + + org.openhab.io.homekit + org.openhab.io.hueemulation + org.openhab.io.imperihome + org.openhab.io.javasound + org.openhab.io.neeo + org.openhab.io.openhabcloud + org.openhab.io.transport.modbus + org.openhab.io.mqttembeddedbroker + org.openhab.io.webaudio + + org.openhab.transform.bin2json + org.openhab.transform.exec + org.openhab.transform.javascript + org.openhab.transform.jinja + org.openhab.transform.jsonpath + org.openhab.transform.map + org.openhab.transform.regex + org.openhab.transform.scale + org.openhab.transform.xpath + org.openhab.transform.xslt + + org.openhab.binding.adorne + org.openhab.binding.airquality + org.openhab.binding.airvisualnode + org.openhab.binding.alarmdecoder + org.openhab.binding.allplay + org.openhab.binding.amazondashbutton + org.openhab.binding.amazonechocontrol + org.openhab.binding.ambientweather + org.openhab.binding.astro + org.openhab.binding.atlona + org.openhab.binding.autelis + org.openhab.binding.avmfritz + org.openhab.binding.bigassfan + org.openhab.binding.bluetooth + org.openhab.binding.bluetooth.airthings + org.openhab.binding.bluetooth.am43 + org.openhab.binding.bluetooth.bluegiga + org.openhab.binding.bluetooth.bluez + org.openhab.binding.bluetooth.blukii org.openhab.binding.bluetooth.daikinmadoka org.openhab.binding.bluetooth.ruuvitag + org.openhab.binding.boschindego + org.openhab.binding.bosesoundtouch + org.openhab.binding.bsblan org.openhab.binding.bticinosmarther org.openhab.binding.buienradar org.openhab.binding.caddx org.openhab.binding.cbus + org.openhab.binding.chromecast + org.openhab.binding.cm11a + org.openhab.binding.coolmasternet + org.openhab.binding.coronastats + org.openhab.binding.daikin + org.openhab.binding.danfossairunit + org.openhab.binding.darksky + org.openhab.binding.deconz + org.openhab.binding.denonmarantz + org.openhab.binding.digiplex + org.openhab.binding.digitalstrom + org.openhab.binding.dlinksmarthome + org.openhab.binding.dmx + org.openhab.binding.doorbird org.openhab.binding.draytonwiser org.openhab.binding.dscalarm + org.openhab.binding.dsmr + org.openhab.binding.dwdpollenflug + org.openhab.binding.dwdunwetter + org.openhab.binding.ecobee + org.openhab.binding.elerotransmitterstick + org.openhab.binding.energenie org.openhab.binding.enigma2 org.openhab.binding.enocean + org.openhab.binding.enturno + org.openhab.binding.etherrain + org.openhab.binding.evohome + org.openhab.binding.exec + org.openhab.binding.feed + org.openhab.binding.feican org.openhab.binding.fmiweather org.openhab.binding.folding + org.openhab.binding.foobot + org.openhab.binding.freebox + org.openhab.binding.fronius + org.openhab.binding.fsinternetradio + org.openhab.binding.ftpupload + org.openhab.binding.gardena + org.openhab.binding.goecharger + org.openhab.binding.globalcache + org.openhab.binding.gpstracker org.openhab.binding.gree org.openhab.binding.groheondus + org.openhab.binding.harmonyhub + org.openhab.binding.hdanywhere + org.openhab.binding.hdpowerview + org.openhab.binding.helios org.openhab.binding.heliosventilation org.openhab.binding.heos + org.openhab.binding.homematic + org.openhab.binding.hpprinter + org.openhab.binding.hue + org.openhab.binding.hydrawise + org.openhab.binding.hyperion + org.openhab.binding.iaqualink + org.openhab.binding.icalendar + org.openhab.binding.icloud + org.openhab.binding.ihc + org.openhab.binding.innogysmarthome + org.openhab.binding.insteon + org.openhab.binding.ipp + org.openhab.binding.irtrans + org.openhab.binding.jeelink + org.openhab.binding.keba + org.openhab.binding.km200 + org.openhab.binding.knx + org.openhab.binding.kodi + org.openhab.binding.konnected + org.openhab.binding.kostalinverter + org.openhab.binding.lametrictime org.openhab.binding.lcn org.openhab.binding.leapmotion + org.openhab.binding.lghombot + org.openhab.binding.lgtvserial + org.openhab.binding.lgwebos + org.openhab.binding.lifx + org.openhab.binding.linky + org.openhab.binding.linuxinput + org.openhab.binding.lirc + org.openhab.binding.logreader + org.openhab.binding.loxone + org.openhab.binding.lutron + org.openhab.binding.mail + org.openhab.binding.max + org.openhab.binding.mcp23017 + org.openhab.binding.melcloud org.openhab.binding.meteoalerte org.openhab.binding.meteoblue + org.openhab.binding.meteostick + org.openhab.binding.miele + org.openhab.binding.mihome + org.openhab.binding.miio + org.openhab.binding.millheat + org.openhab.binding.milight + org.openhab.binding.minecraft + org.openhab.binding.modbus + org.openhab.binding.modbus.stiebeleltron + org.openhab.binding.modbus.sunspec org.openhab.binding.mpd org.openhab.binding.mqtt + org.openhab.binding.mqtt.generic + org.openhab.binding.mqtt.homeassistant + org.openhab.binding.mqtt.homie + org.openhab.binding.nanoleaf + org.openhab.binding.neato + org.openhab.binding.neeo + org.openhab.binding.neohub + org.openhab.binding.nest + org.openhab.binding.netatmo + org.openhab.binding.network + org.openhab.binding.networkupstools + org.openhab.binding.nibeheatpump + org.openhab.binding.nibeuplink + org.openhab.binding.nikobus + org.openhab.binding.nikohomecontrol org.openhab.binding.novafinedust org.openhab.binding.ntp + org.openhab.binding.nuki + org.openhab.binding.oceanic org.openhab.binding.ojelectronics org.openhab.binding.omnikinverter + org.openhab.binding.onebusaway + org.openhab.binding.onewiregpio + org.openhab.binding.onewire + org.openhab.binding.onkyo + org.openhab.binding.opengarage + org.openhab.binding.opensprinkler + org.openhab.binding.openthermgateway + org.openhab.binding.openuv + org.openhab.binding.openweathermap org.openhab.binding.openwebnet org.openhab.binding.oppo org.openhab.binding.orvibo + org.openhab.binding.paradoxalarm + org.openhab.binding.pentair + org.openhab.binding.phc + org.openhab.binding.pioneeravr + org.openhab.binding.pixometer + org.openhab.binding.pjlinkdevice + org.openhab.binding.plclogo + org.openhab.binding.plugwise + org.openhab.binding.powermax + org.openhab.binding.pulseaudio + org.openhab.binding.pushbullet org.openhab.binding.radiothermostat org.openhab.binding.regoheatpump + org.openhab.binding.rfxcom + org.openhab.binding.rme + org.openhab.binding.robonect + org.openhab.binding.rotel + org.openhab.binding.rotelra1x + org.openhab.binding.russound + org.openhab.binding.sagercaster + org.openhab.binding.samsungtv + org.openhab.binding.satel + org.openhab.binding.seneye + org.openhab.binding.sensebox + org.openhab.binding.sensibo + org.openhab.binding.serialbutton + org.openhab.binding.shelly + org.openhab.binding.silvercrestwifisocket + org.openhab.binding.siemensrds + org.openhab.binding.sinope + org.openhab.binding.sleepiq + org.openhab.binding.smaenergymeter + org.openhab.binding.smartmeter org.openhab.binding.smhi org.openhab.binding.snmp + org.openhab.binding.solaredge + org.openhab.binding.solarlog - org.openhab.binding.somfymylink + org.openhab.binding.somfymylink org.openhab.binding.somfytahoma + org.openhab.binding.sonos + org.openhab.binding.sonyaudio + org.openhab.binding.sonyprojector + org.openhab.binding.spotify + org.openhab.binding.squeezebox + org.openhab.binding.synopanalyzer + org.openhab.binding.systeminfo + org.openhab.binding.tado + org.openhab.binding.tankerkoenig + org.openhab.binding.telegram + org.openhab.binding.tellstick + org.openhab.binding.tesla + org.openhab.binding.tibber + org.openhab.binding.tplinksmarthome + org.openhab.binding.tradfri + org.openhab.binding.unifi org.openhab.binding.upnpcontrol org.openhab.binding.urtsi + org.openhab.binding.valloxmv + org.openhab.binding.vektiva + org.openhab.binding.velbus + org.openhab.binding.velux org.openhab.binding.verisure org.openhab.binding.vigicrues org.openhab.binding.vitotronic + org.openhab.binding.volvooncall + org.openhab.binding.weathercompany + org.openhab.binding.weatherunderground + org.openhab.binding.wemo + org.openhab.binding.wifiled + org.openhab.binding.windcentrale + org.openhab.binding.xmltv + org.openhab.binding.xmppclient + org.openhab.binding.yamahareceiver + org.openhab.binding.yeelight + org.openhab.binding.zoneminder + org.openhab.binding.zway + + org.openhab.extensionservice.marketplace + org.openhab.extensionservice.marketplace.automation + + org.openhab.voice.googletts + org.openhab.voice.mactts + org.openhab.voice.marytts + org.openhab.voice.picotts + org.openhab.voice.pollytts + org.openhab.voice.voicerss + + - + + + + org.openhab.core.bom + org.openhab.core.bom.compile + pom + provided + + + org.openhab.core.bom + org.openhab.core.bom.openhab-core + pom + provided + + + org.openhab.core.bom + org.openhab.core.bom.test + pom + test + + + + org.apache.karaf.features + framework + ${karaf.version} + kar + true + + + * + * + + + + + + org.apache.karaf.features + standard + ${karaf.version} + features + xml + provided + + - + + + - + + + + + org.apache.maven.plugins + maven-jar-plugin + + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + true + + + + org.apache.karaf.tooling + karaf-maven-plugin + ${karaf.version} + true + + 80 + true + true + false + true + true + + + + compile + + features-generate-descriptor + + generate-resources + + ${feature.directory} + + + + karaf-feature-verification + + verify + + verify + + + + mvn:org.apache.karaf.features/framework/${karaf.version}/xml/features + mvn:org.apache.karaf.features/standard/${karaf.version}/xml/features + + file:${project.build.directory}/feature/feature.xml + + org.apache.karaf.features:framework + 1.8 + + framework + + + openhab-* + + false + true + first + + + + + + - + + + biz.aQute.bnd + bnd-maven-plugin + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar-no-fork + + + + + + org.apache.karaf.tooling + karaf-maven-plugin + + + + org.apache.maven.plugins + maven-dependency-plugin + 3.1.1 + + + embed-dependencies + + unpack-dependencies + + + runtime + jar + javax.activation,org.apache.karaf.features + ${dep.noembedding} + ${project.build.directory}/classes + true + true + true + jar + + + + + + - + + + + shrink-bundle + + + shrinkBundle.profile + + + + + + com.github.wvengen + proguard-maven-plugin + 2.1.1 + + + shrink-bundle + package + + proguard + + + + + false + true + ${project.build.directory} + + ${java.home}/lib/rt.jar + + + + + + + + + + + + + + + no-embed-dependencies + + + noEmbedDependencies.profile + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + embed-dependencies + none + + + + + + + - + From aa4d2c8f64db20fb2deb122d13d29e4fe1a689d6 Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Tue, 16 Jun 2020 22:26:16 +0200 Subject: [PATCH 02/20] Update bundles/org.openhab.binding.modbus.stiebeleltron/README.md Co-authored-by: Fabian Wolter Signed-off-by: Paul Frank --- bundles/org.openhab.binding.modbus.stiebeleltron/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/README.md b/bundles/org.openhab.binding.modbus.stiebeleltron/README.md index decac47abbdb3..032ab4251a68a 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/README.md +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/README.md @@ -29,7 +29,7 @@ Bridge modbus:tcp:bridge [ host="10.0.0.2", port=502, id=1 ] ## Thing Configuration -You need first to set up either a TCP Modbus bridge according to the Modbus documentation. +You need first to set up a TCP Modbus bridge according to the Modbus documentation. Things in this extension will use the selected bridge to connect to the device. The following parameters are valid for all thing types: @@ -204,4 +204,3 @@ Number:Energy stiebel_eltron_consumption_water_total "Water heating p ``` - From 88c021a384f8c7d3f80aa2449b2007992ca3b2cc Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Tue, 16 Jun 2020 22:26:33 +0200 Subject: [PATCH 03/20] Update bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/config/config-descriptions.xml Co-authored-by: Fabian Wolter Signed-off-by: Paul Frank --- .../src/main/resources/ESH-INF/config/config-descriptions.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/config/config-descriptions.xml b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/config/config-descriptions.xml index 501ccd03cf6a3..de7c46ccd1a39 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/config/config-descriptions.xml +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/config/config-descriptions.xml @@ -6,7 +6,7 @@ - + Poll interval in seconds. Use zero to disable automatic polling. 5 From 9f1804676841e278e7d38e48e11670bf92c64449 Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Tue, 16 Jun 2020 22:26:53 +0200 Subject: [PATCH 04/20] Update bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/config/config-descriptions.xml Co-authored-by: Fabian Wolter Signed-off-by: Paul Frank --- .../src/main/resources/ESH-INF/config/config-descriptions.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/config/config-descriptions.xml b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/config/config-descriptions.xml index de7c46ccd1a39..9cce1df2c1d37 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/config/config-descriptions.xml +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/config/config-descriptions.xml @@ -7,7 +7,7 @@ - + Poll interval in seconds. Use zero to disable automatic polling. 5 s From 6493eea4dc4035953f83f5fd424d0b3843e22e2f Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Wed, 17 Jun 2020 19:05:55 +0200 Subject: [PATCH 05/20] fix review finding Signed-off-by: Paul Frank --- .../README.md | 36 +- .../StiebelEltronBindingConstants.java | 16 +- .../internal/StiebelEltronHandlerFactory.java | 3 - .../modbus.stiebeleltron_xx_XX.properties | 17 - .../ESH-INF/thing/heatpump-channel-groups.xml | 16 +- .../ESH-INF/thing/heatpump-channel-types.xml | 76 +-- bundles/pom.xml | 482 +----------------- 7 files changed, 84 insertions(+), 562 deletions(-) delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/i18n/modbus.stiebeleltron_xx_XX.properties diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/README.md b/bundles/org.openhab.binding.modbus.stiebeleltron/README.md index 032ab4251a68a..fa55b5c2dd430 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/README.md +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/README.md @@ -12,9 +12,9 @@ A Internet Service Gateway (ISG) with an installed modbus extension is required This bundle adds the following thing types to the Modbus binding. Note, that the things will show up under the Modbus binding. -| Thing | Description | -| ------------------------ | -------------------------------------------------- | -| Stiebel Eltron ISG | A stiebel eltron heat pump connected through a ISG | +| Thing | ThingTypeID | Description | +| ------------------ | ----------- | -------------------------------------------------- | +| Stiebel Eltron ISG | heatpump | A stiebel eltron heat pump connected through a ISG | ## Discovery @@ -59,13 +59,13 @@ This group contains general operational information about the heat pump. This group contains system paramters of the heat pump. -| Channel ID | Item Type | Read only | Description | -| --------------------------- | ------------------ | --------- | ------------------------------------------- | -| operation-mode | Number | false | The current operation mode of the heat pump | -| comfort-temperature-heating | Number:Temperature | false | The current heating comfort temperature | -| eco-temperature-heating | Number:Temperature | false | The current heating eco temperature | -| comfort-temperature-water | Number:Temperature | false | The current water comfort temperature | -| eco-temperature-water | Number:Temperature | false | The current water eco temperature | +| Channel ID | Item Type | Read only | Description | +| --------------------------- | ------------------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | +| operation-mode | Number | false | The current operation mode of the heat pump (1=ready mode, 2=program mode, 3=comfort mode, 4=eco mode, 5=heating water mode, 0=emergency mode) | +| comfort-temperature-heating | Number:Temperature | false | The current heating comfort temperature | +| eco-temperature-heating | Number:Temperature | false | The current heating eco temperature | +| comfort-temperature-water | Number:Temperature | false | The current water comfort temperature | +| eco-temperature-water | Number:Temperature | false | The current water eco temperature | ### System Information Group @@ -92,14 +92,14 @@ This group contains about the energy consumption and delivery of the heat pump. | Channel ID | Item Type | Read only | Description | | ----------------------- | ------------- | --------- | ------------------------------------------------ | -| production_heat_today | Number:Energy | true | The heat quantity delivered today | -| production_heat_total | Number:Energy | true | The heat quantity delivered in total | -| production_water_today | Number:Energy | true | The water heat quantity delivered today | -| production_water_total | Number:Energy | true | The water heat quantity delivered in total | -| consumption_heat_today | Number:Energy | true | The power consumption for heating today | -| consumption_heat_total | Number:Energy | true | The power consumption for heating in total | -| consumption_water_today | Number:Energy | true | The power consumption for water heating today | -| consumption_water_total | Number:Energy | true | The power consumption for water heating in total | +| production-heat-today | Number:Energy | true | The heat quantity delivered today | +| production-heat-total | Number:Energy | true | The heat quantity delivered in total | +| production-water-today | Number:Energy | true | The water heat quantity delivered today | +| production-water-total | Number:Energy | true | The water heat quantity delivered in total | +| consumption-heat-today | Number:Energy | true | The power consumption for heating today | +| consumption-heat-total | Number:Energy | true | The power consumption for heating in total | +| consumption-water-today | Number:Energy | true | The power consumption for water heating today | +| consumption-water-total | Number:Energy | true | The power consumption for water heating in total | diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronBindingConstants.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronBindingConstants.java index cae2fd68ee8d3..fec82b06697f9 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronBindingConstants.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronBindingConstants.java @@ -50,14 +50,14 @@ public class StiebelEltronBindingConstants { public static final String CHANNEL_WATER_TEMPERATURE = "water-temperature"; public static final String CHANNEL_WATER_TEMPERATURE_SETPOINT = "water-temperature-setpoint"; - public static final String CHANNEL_PRODUCTION_HEAT_TODAY = "production_heat_today"; - public static final String CHANNEL_PRODUCTION_HEAT_TOTAL = "production_heat_total"; - public static final String CHANNEL_PRODUCTION_WATER_TODAY = "production_water_today"; - public static final String CHANNEL_PRODUCTION_WATER_TOTAL = "production_water_total"; - public static final String CHANNEL_CONSUMPTION_HEAT_TODAY = "consumption_heat_today"; - public static final String CHANNEL_CONSUMPTION_HEAT_TOTAL = "consumption_heat_total"; - public static final String CHANNEL_CONSUMPTION_WATER_TODAY = "consumption_water_today"; - public static final String CHANNEL_CONSUMPTION_WATER_TOTAL = "consumption_water_total"; + public static final String CHANNEL_PRODUCTION_HEAT_TODAY = "production-heat-today"; + public static final String CHANNEL_PRODUCTION_HEAT_TOTAL = "production-heat-total"; + public static final String CHANNEL_PRODUCTION_WATER_TODAY = "production-water-today"; + public static final String CHANNEL_PRODUCTION_WATER_TOTAL = "production-water-total"; + public static final String CHANNEL_CONSUMPTION_HEAT_TODAY = "consumption-heat-today"; + public static final String CHANNEL_CONSUMPTION_HEAT_TOTAL = "consumption-heat-total"; + public static final String CHANNEL_CONSUMPTION_WATER_TODAY = "consumption-water-today"; + public static final String CHANNEL_CONSUMPTION_WATER_TOTAL = "consumption-water-total"; public static final String CHANNEL_IS_HEATING = "is-heating"; public static final String CHANNEL_IS_HEATING_WATER = "is-heating-water"; diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronHandlerFactory.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronHandlerFactory.java index debaea29f9de3..42d69ff44bea1 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronHandlerFactory.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronHandlerFactory.java @@ -40,9 +40,6 @@ @Component(configurationPid = "binding.stiebeleltron", service = ThingHandlerFactory.class) public class StiebelEltronHandlerFactory extends BaseThingHandlerFactory { - /** - * Reference to the modbus manager - */ private ModbusManager manager; private static final Set SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_SAMPLE); diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/i18n/modbus.stiebeleltron_xx_XX.properties b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/i18n/modbus.stiebeleltron_xx_XX.properties deleted file mode 100644 index 666d68d7acd33..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/i18n/modbus.stiebeleltron_xx_XX.properties +++ /dev/null @@ -1,17 +0,0 @@ -# FIXME: please substitute the xx_XX with a proper locale, ie. de_DE -# FIXME: please do not add the file to the repo if you add or change no content -# binding -binding.modbus.stiebeleltron.name = -binding.modbus.stiebeleltron.description = - -# thing types -thing-type.modbus.stiebeleltron.sample.label = -thing-type.modbus.stiebeleltron.sample.description = - -# thing type config description -thing-type.config.modbus.stiebeleltron.sample.config1.label = -thing-type.config.modbus.stiebeleltron.sample.config1.description = - -# channel types -channel-type.modbus.stiebeleltron.sample-channel.label = -channel-type.modbus.stiebeleltron.sample-channel.description = diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-groups.xml b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-groups.xml index 01ca5fb0e6f5e..07ef115617d6e 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-groups.xml +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-groups.xml @@ -47,14 +47,14 @@ - - - - - - - - + + + + + + + + diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-types.xml b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-types.xml index 4938fde06da50..f62f1cf43c23d 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-types.xml +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-types.xml @@ -6,137 +6,137 @@ Number:Temperature - + Number:Temperature - + Number:Dimensionless - + Number:Temperature - + Number:Temperature - + Number:Temperature - + Number:Temperature - + Number:Temperature - + Number:Temperature - + Number:Temperature - + Number:Temperature - + Number:Temperature - + - + Number:Energy - + - + Number:Energy - + - + Number:Energy - + - + Number:Energy - + - + Number:Energy - + - + Number:Energy - + - + Number:Energy - + - + Number:Energy - + Contact - + Contact - + Contact - + Contact - + Contact - + Number - + @@ -150,22 +150,22 @@ Number:Temperature - + Number:Temperature - + Number:Temperature - + Number:Temperature - + diff --git a/bundles/pom.xml b/bundles/pom.xml index 7ac0dd9ee188d..61b6bc1b29d51 100644 --- a/bundles/pom.xml +++ b/bundles/pom.xml @@ -1,981 +1,523 @@ 4.0.0 - + - org.openhab.addons - org.openhab.addons.reactor 2.5.9-SNAPSHOT - + org.openhab.addons.bundles - org.openhab.addons.reactor.bundles - pom - + openHAB Add-ons :: Bundles - + - - org.openhab.io.homekit - org.openhab.io.hueemulation - org.openhab.io.imperihome - org.openhab.io.javasound - org.openhab.io.neeo - org.openhab.io.openhabcloud - org.openhab.io.transport.modbus - org.openhab.io.mqttembeddedbroker - org.openhab.io.webaudio - - org.openhab.transform.bin2json - org.openhab.transform.exec - org.openhab.transform.javascript - org.openhab.transform.jinja - org.openhab.transform.jsonpath - org.openhab.transform.map - org.openhab.transform.regex - org.openhab.transform.scale - org.openhab.transform.xpath - org.openhab.transform.xslt - - org.openhab.binding.adorne - org.openhab.binding.airquality - org.openhab.binding.airvisualnode - org.openhab.binding.alarmdecoder - org.openhab.binding.allplay - org.openhab.binding.amazondashbutton - org.openhab.binding.amazonechocontrol - org.openhab.binding.ambientweather - org.openhab.binding.astro - org.openhab.binding.atlona - org.openhab.binding.autelis - org.openhab.binding.avmfritz - org.openhab.binding.bigassfan - org.openhab.binding.bluetooth - org.openhab.binding.bluetooth.airthings - org.openhab.binding.bluetooth.am43 - org.openhab.binding.bluetooth.bluegiga - org.openhab.binding.bluetooth.bluez - org.openhab.binding.bluetooth.blukii org.openhab.binding.bluetooth.daikinmadoka org.openhab.binding.bluetooth.ruuvitag - org.openhab.binding.boschindego - org.openhab.binding.bosesoundtouch - org.openhab.binding.bsblan org.openhab.binding.bticinosmarther org.openhab.binding.buienradar org.openhab.binding.caddx org.openhab.binding.cbus - org.openhab.binding.chromecast - org.openhab.binding.cm11a - org.openhab.binding.coolmasternet - org.openhab.binding.coronastats - org.openhab.binding.daikin - org.openhab.binding.danfossairunit - org.openhab.binding.darksky - org.openhab.binding.deconz - org.openhab.binding.denonmarantz - org.openhab.binding.digiplex - org.openhab.binding.digitalstrom - org.openhab.binding.dlinksmarthome - org.openhab.binding.dmx - org.openhab.binding.doorbird org.openhab.binding.draytonwiser org.openhab.binding.dscalarm - org.openhab.binding.dsmr - org.openhab.binding.dwdpollenflug - org.openhab.binding.dwdunwetter - org.openhab.binding.ecobee - org.openhab.binding.elerotransmitterstick - org.openhab.binding.energenie org.openhab.binding.enigma2 org.openhab.binding.enocean - org.openhab.binding.enturno - org.openhab.binding.etherrain - org.openhab.binding.evohome - org.openhab.binding.exec - org.openhab.binding.feed - org.openhab.binding.feican org.openhab.binding.fmiweather org.openhab.binding.folding - org.openhab.binding.foobot - org.openhab.binding.freebox - org.openhab.binding.fronius - org.openhab.binding.fsinternetradio - org.openhab.binding.ftpupload - org.openhab.binding.gardena - org.openhab.binding.goecharger - org.openhab.binding.globalcache - org.openhab.binding.gpstracker org.openhab.binding.gree org.openhab.binding.groheondus - org.openhab.binding.harmonyhub - org.openhab.binding.hdanywhere - org.openhab.binding.hdpowerview - org.openhab.binding.helios org.openhab.binding.heliosventilation org.openhab.binding.heos - org.openhab.binding.homematic - org.openhab.binding.hpprinter - org.openhab.binding.hue - org.openhab.binding.hydrawise - org.openhab.binding.hyperion - org.openhab.binding.iaqualink - org.openhab.binding.icalendar - org.openhab.binding.icloud - org.openhab.binding.ihc - org.openhab.binding.innogysmarthome - org.openhab.binding.insteon - org.openhab.binding.ipp - org.openhab.binding.irtrans - org.openhab.binding.jeelink - org.openhab.binding.keba - org.openhab.binding.km200 - org.openhab.binding.knx - org.openhab.binding.kodi - org.openhab.binding.konnected - org.openhab.binding.kostalinverter - org.openhab.binding.lametrictime org.openhab.binding.lcn org.openhab.binding.leapmotion - org.openhab.binding.lghombot - org.openhab.binding.lgtvserial - org.openhab.binding.lgwebos - org.openhab.binding.lifx - org.openhab.binding.linky - org.openhab.binding.linuxinput - org.openhab.binding.lirc - org.openhab.binding.logreader - org.openhab.binding.loxone - org.openhab.binding.lutron - org.openhab.binding.mail - org.openhab.binding.max - org.openhab.binding.mcp23017 - org.openhab.binding.melcloud org.openhab.binding.meteoalerte org.openhab.binding.meteoblue - org.openhab.binding.meteostick - org.openhab.binding.miele - org.openhab.binding.mihome - org.openhab.binding.miio - org.openhab.binding.millheat - org.openhab.binding.milight - org.openhab.binding.minecraft - org.openhab.binding.modbus - org.openhab.binding.modbus.stiebeleltron - org.openhab.binding.modbus.sunspec + org.openhab.binding.modbus.stiebeleltron org.openhab.binding.mpd org.openhab.binding.mqtt - org.openhab.binding.mqtt.generic - org.openhab.binding.mqtt.homeassistant - org.openhab.binding.mqtt.homie - org.openhab.binding.nanoleaf - org.openhab.binding.neato - org.openhab.binding.neeo - org.openhab.binding.neohub - org.openhab.binding.nest - org.openhab.binding.netatmo - org.openhab.binding.network - org.openhab.binding.networkupstools - org.openhab.binding.nibeheatpump - org.openhab.binding.nibeuplink - org.openhab.binding.nikobus - org.openhab.binding.nikohomecontrol org.openhab.binding.novafinedust org.openhab.binding.ntp - org.openhab.binding.nuki - org.openhab.binding.oceanic org.openhab.binding.ojelectronics org.openhab.binding.omnikinverter - org.openhab.binding.onebusaway - org.openhab.binding.onewiregpio - org.openhab.binding.onewire - org.openhab.binding.onkyo - org.openhab.binding.opengarage - org.openhab.binding.opensprinkler - org.openhab.binding.openthermgateway - org.openhab.binding.openuv - org.openhab.binding.openweathermap org.openhab.binding.openwebnet org.openhab.binding.oppo org.openhab.binding.orvibo - org.openhab.binding.paradoxalarm - org.openhab.binding.pentair - org.openhab.binding.phc - org.openhab.binding.pioneeravr - org.openhab.binding.pixometer - org.openhab.binding.pjlinkdevice - org.openhab.binding.plclogo - org.openhab.binding.plugwise - org.openhab.binding.powermax - org.openhab.binding.pulseaudio - org.openhab.binding.pushbullet org.openhab.binding.radiothermostat org.openhab.binding.regoheatpump - org.openhab.binding.rfxcom - org.openhab.binding.rme - org.openhab.binding.robonect - org.openhab.binding.rotel - org.openhab.binding.rotelra1x - org.openhab.binding.russound - org.openhab.binding.sagercaster - org.openhab.binding.samsungtv - org.openhab.binding.satel - org.openhab.binding.seneye - org.openhab.binding.sensebox - org.openhab.binding.sensibo - org.openhab.binding.serialbutton - org.openhab.binding.shelly - org.openhab.binding.silvercrestwifisocket - org.openhab.binding.siemensrds - org.openhab.binding.sinope - org.openhab.binding.sleepiq - org.openhab.binding.smaenergymeter - org.openhab.binding.smartmeter org.openhab.binding.smhi org.openhab.binding.snmp - org.openhab.binding.solaredge - org.openhab.binding.solarlog - org.openhab.binding.somfymylink + org.openhab.binding.somfymylink org.openhab.binding.somfytahoma - org.openhab.binding.sonos - org.openhab.binding.sonyaudio - org.openhab.binding.sonyprojector - org.openhab.binding.spotify - org.openhab.binding.squeezebox - org.openhab.binding.synopanalyzer - org.openhab.binding.systeminfo - org.openhab.binding.tado - org.openhab.binding.tankerkoenig - org.openhab.binding.telegram - org.openhab.binding.tellstick - org.openhab.binding.tesla - org.openhab.binding.tibber - org.openhab.binding.tplinksmarthome - org.openhab.binding.tradfri - org.openhab.binding.unifi org.openhab.binding.upnpcontrol org.openhab.binding.urtsi - org.openhab.binding.valloxmv - org.openhab.binding.vektiva - org.openhab.binding.velbus - org.openhab.binding.velux org.openhab.binding.verisure org.openhab.binding.vigicrues org.openhab.binding.vitotronic - org.openhab.binding.volvooncall - org.openhab.binding.weathercompany - org.openhab.binding.weatherunderground - org.openhab.binding.wemo - org.openhab.binding.wifiled - org.openhab.binding.windcentrale - org.openhab.binding.xmltv - org.openhab.binding.xmppclient - org.openhab.binding.yamahareceiver - org.openhab.binding.yeelight - org.openhab.binding.zoneminder - org.openhab.binding.zway - - org.openhab.extensionservice.marketplace - org.openhab.extensionservice.marketplace.automation - - org.openhab.voice.googletts - org.openhab.voice.mactts - org.openhab.voice.marytts - org.openhab.voice.picotts - org.openhab.voice.pollytts - org.openhab.voice.voicerss - - - + - - - org.openhab.core.bom - org.openhab.core.bom.compile - pom - provided - - - org.openhab.core.bom - org.openhab.core.bom.openhab-core - pom - provided - - - org.openhab.core.bom - org.openhab.core.bom.test - pom - test - - - - org.apache.karaf.features - framework - ${karaf.version} - kar - true - - - * - * - - - - - - org.apache.karaf.features - standard - ${karaf.version} - features - xml - provided - - - + - - - + - - - - org.apache.maven.plugins - maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - true - - - - org.apache.karaf.tooling - karaf-maven-plugin - ${karaf.version} - true - - 80 - true - true - false - true - true - - - - compile - - features-generate-descriptor - - generate-resources - - ${feature.directory} - - - - karaf-feature-verification - - verify - - verify - - - - mvn:org.apache.karaf.features/framework/${karaf.version}/xml/features - mvn:org.apache.karaf.features/standard/${karaf.version}/xml/features - - file:${project.build.directory}/feature/feature.xml - - org.apache.karaf.features:framework - 1.8 - - framework - - - openhab-* - - false - true - first - - - - - - - + - - biz.aQute.bnd - bnd-maven-plugin - - - org.apache.maven.plugins - maven-source-plugin - - - attach-sources - - jar-no-fork - - - - - - org.apache.karaf.tooling - karaf-maven-plugin - - - - org.apache.maven.plugins - maven-dependency-plugin - 3.1.1 - - - embed-dependencies - - unpack-dependencies - - - runtime - jar - javax.activation,org.apache.karaf.features - ${dep.noembedding} - ${project.build.directory}/classes - true - true - true - jar - - - - - - - + - - - shrink-bundle - - - shrinkBundle.profile - - - - - - com.github.wvengen - proguard-maven-plugin - 2.1.1 - - - shrink-bundle - package - - proguard - - - - - false - true - ${project.build.directory} - - ${java.home}/lib/rt.jar - - - - - - - - - - - - - - - no-embed-dependencies - - - noEmbedDependencies.profile - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - embed-dependencies - none - - - - - - - - + From b2f08c4c93f79953b38b18e69f21a66aec37dbcc Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Thu, 18 Jun 2020 07:24:09 +0200 Subject: [PATCH 06/20] renamed THING_TYPE_SAMPLE Signed-off-by: Paul Frank --- .../internal/StiebelEltronBindingConstants.java | 2 +- .../stiebeleltron/internal/StiebelEltronHandlerFactory.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronBindingConstants.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronBindingConstants.java index fec82b06697f9..3a40ecb48bdfc 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronBindingConstants.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronBindingConstants.java @@ -28,7 +28,7 @@ public class StiebelEltronBindingConstants { private static final String BINDING_ID = ModbusBindingConstants.BINDING_ID; // List of all Thing Type UIDs - public static final ThingTypeUID THING_TYPE_SAMPLE = new ThingTypeUID(BINDING_ID, "heatpump"); + public static final ThingTypeUID THING_TYPE_HEATPUMP = new ThingTypeUID(BINDING_ID, "heatpump"); // Channel group ids public static final String GROUP_SYSTEM_STATE = "systemState"; diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronHandlerFactory.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronHandlerFactory.java index 42d69ff44bea1..54dc499afb38b 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronHandlerFactory.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronHandlerFactory.java @@ -12,7 +12,7 @@ */ package org.openhab.binding.modbus.stiebeleltron.internal; -import static org.openhab.binding.modbus.stiebeleltron.internal.StiebelEltronBindingConstants.THING_TYPE_SAMPLE; +import static org.openhab.binding.modbus.stiebeleltron.internal.StiebelEltronBindingConstants.THING_TYPE_HEATPUMP; import java.util.Collections; import java.util.Set; @@ -42,7 +42,7 @@ public class StiebelEltronHandlerFactory extends BaseThingHandlerFactory { private ModbusManager manager; - private static final Set SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_SAMPLE); + private static final Set SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_HEATPUMP); /** * This factory needs a reference to the ModbusManager wich is provided @@ -65,7 +65,7 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) { protected @Nullable ThingHandler createHandler(Thing thing) { ThingTypeUID thingTypeUID = thing.getThingTypeUID(); - if (THING_TYPE_SAMPLE.equals(thingTypeUID)) { + if (THING_TYPE_HEATPUMP.equals(thingTypeUID)) { return new StiebelEltronHandler(thing, manager); } From 9ad3c45c6d59bef7e196352c38d77c28af2776a8 Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Fri, 19 Jun 2020 21:31:55 +0200 Subject: [PATCH 07/20] fix remaining review comment Signed-off-by: Paul Frank --- .../internal/dto/EnergyBlock.java | 24 +-- .../handler/StiebelEltronHandler.java | 170 ++++++++---------- .../internal/parser/AbstractBaseParser.java | 2 +- .../internal/parser/EnergyBlockParser.java | 24 +-- 4 files changed, 98 insertions(+), 122 deletions(-) diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/EnergyBlock.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/EnergyBlock.java index 3ddd8b54237be..d23fd243147bd 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/EnergyBlock.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/EnergyBlock.java @@ -20,17 +20,17 @@ */ public class EnergyBlock { - public int production_heat_today; - public int production_heat_total_low; - public int production_heat_total_high; - public int production_water_today; - public int production_water_total_low; - public int production_water_total_high; + public int productionHeatToday; + public int productionHeatTotalLow; + public int productionHeatTotalHigh; + public int productionWaterToday; + public int productionWaterTotalLow; + public int productionWaterTotalHigh; - public int consumption_heat_today; - public int consumption_heat_total_low; - public int consumption_heat_total_high; - public int consumption_water_today; - public int consumption_water_total_low; - public int consumption_water_total_high; + public int consumptionHeatToday; + public int consumptionHeatTotalLow; + public int consumptionHeatTotalHigh; + public int consumptionWaterToday; + public int consumptionWaterTotalLow; + public int consumptionWaterTotalHigh; } diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java index 2fb0f8b432f8e..1d3d8fb9a8c73 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java @@ -81,18 +81,12 @@ public class StiebelEltronHandler extends BaseThingHandler { public abstract class AbstractBasePoller { - /** - * Logger instance - */ + private final Logger logger = LoggerFactory.getLogger(StiebelEltronHandler.class); private volatile @Nullable PollTask pollTask; - public AbstractBasePoller() { - } - public synchronized void unregisterPollTask() { - @Nullable PollTask task = pollTask; if (task == null) { return; @@ -101,7 +95,6 @@ public synchronized void unregisterPollTask() { StiebelEltronHandler.this.modbusManager.unregisterRegularPoll(task); pollTask = null; - } /** @@ -111,16 +104,12 @@ public synchronized void registerPollTask(int address, int length, ModbusReadFun logger.debug("Setting up regular polling"); - @Nullable ModbusSlaveEndpoint myendpoint = StiebelEltronHandler.this.endpoint; - @Nullable StiebelEltronConfiguration myconfig = StiebelEltronHandler.this.config; if (myconfig == null || myendpoint == null) { throw new IllegalStateException("registerPollTask called without proper configuration"); } - logger.debug("Setting up regular polling"); - BasicModbusReadRequestBlueprint request = new BasicModbusReadRequestBlueprint(getSlaveId(), readFunctionCode, address, length, myconfig.getMaxTries()); @@ -130,17 +119,13 @@ public synchronized void registerPollTask(int address, int length, ModbusReadFun public void onRegisters(@Nullable ModbusReadRequestBlueprint request, @Nullable ModbusRegisterArray registers) { if (registers == null) { - logger.info("Received empty register array on poll"); + logger.warn("Received empty register array on poll"); return; } - try { - handlePolledData(registers); - - if (StiebelEltronHandler.this.getThing().getStatus() != ThingStatus.ONLINE) { - updateStatus(ThingStatus.ONLINE); - } - } catch (Exception error) { - StiebelEltronHandler.this.handleError(error); + handlePolledData(registers); + + if (StiebelEltronHandler.this.getThing().getStatus() != ThingStatus.ONLINE) { + updateStatus(ThingStatus.ONLINE); } } @@ -283,28 +268,28 @@ public void onError(ModbusWriteRequestBlueprint request, Exception error) { * @return short the value of the command multiplied by 10 (see datatype 2 in the stiebel eltron modbus * documentation) */ - private short getScaledInt16Value(Command command) { + private short getScaledInt16Value(Command command) throws IllegalArgumentException { if (command instanceof QuantityType) { - QuantityType c = (QuantityType) command; + QuantityType c = ((QuantityType) command).toUnit(CELSIUS); return (short) (c.doubleValue() * 10); } if (command instanceof DecimalType) { DecimalType c = (DecimalType) command; return (short) (c.doubleValue() * 10); } - return 0; + throw new IllegalArgumentException(); } /** * @param command get the value of this command. * @return short the value of the command as short */ - private short getInt16Value(Command command) { + private short getInt16Value(Command command) throws IllegalArgumentException { if (command instanceof DecimalType) { DecimalType c = (DecimalType) command; return c.shortValue(); } - return 0; + throw new IllegalArgumentException(); } /** @@ -312,9 +297,7 @@ private short getInt16Value(Command command) { */ @Override public void handleCommand(ChannelUID channelUID, Command command) { - if (RefreshType.REFRESH == command) { - // TODO: Implement refresh - } else { + try { if (GROUP_SYSTEM_PARAMETER.equals(channelUID.getGroupId())) { switch (channelUID.getIdWithoutGroup()) { case CHANNEL_OPERATION_MODE: @@ -335,6 +318,9 @@ public void handleCommand(ChannelUID channelUID, Command command) { } } } + catch(IllegalArgumentException e){ + handleError(e); + } } /** @@ -351,18 +337,42 @@ public void initialize() { /* * This method starts the operation of this handler - * Connect to the slave bridge Start the periodic polling + * Connect to the slave bridge Start the periodic polling1 */ private void startUp() { - connectEndpoint(); + if (endpoint != null) { + return; + } - if (endpoint == null || config == null) { - logger.debug("Invalid endpoint/config/manager ref for sunspec handler"); + ModbusEndpointThingHandler slaveEndpointThingHandler = getEndpointThingHandler(); + if (slaveEndpointThingHandler == null) { + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, "Bridge is offline"); + logger.debug("No bridge handler available -- aborting init for {}", this); return; } - updateStatus(ThingStatus.UNKNOWN); + try { + slaveId = slaveEndpointThingHandler.getSlaveId(); + + endpoint = slaveEndpointThingHandler.asSlaveEndpoint(); + } catch (EndpointNotInitializedException e) { + // this will be handled below as endpoint remains null + } + + if (endpoint == null) { + @SuppressWarnings("null") + String label = Optional.ofNullable(getBridge()).map(b -> b.getLabel()).orElse(""); + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, + String.format("Bridge '%s' not completely initialized", label)); + logger.debug("Bridge not initialized fully (no endpoint) -- aborting init for {}", this); + return; + } + + if (config == null) { + logger.debug("Invalid endpoint/config/manager ref for stiebel eltron handler"); + return; + } if (systemInformationPoller == null) { AbstractBasePoller poller = new AbstractBasePoller() { @@ -408,6 +418,7 @@ protected void handlePolledData(ModbusRegisterArray registers) { poller.registerPollTask(1500, 11, ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS); systemParameterPoller = poller; } + updateStatus(ThingStatus.UNKNOWN); } /** @@ -422,33 +433,39 @@ public void dispose() { * Unregister the poll tasks and release the endpoint reference */ private void tearDown() { - logger.trace("unregisterPollTasks"); - if (systemInformationPoller != null) { + AbstractBasePoller poller = systemInformationPoller; + if (poller != null) { logger.debug("Unregistering systemInformationPoller from ModbusManager"); - systemInformationPoller.unregisterPollTask(); + poller.unregisterPollTask(); systemInformationPoller = null; } - if (energyPoller != null) { + + poller = energyPoller; + if (poller != null) { logger.debug("Unregistering energyPoller from ModbusManager"); - energyPoller.unregisterPollTask(); + poller.unregisterPollTask(); energyPoller = null; } - if (systemStatePoller != null) { + + poller = systemStatePoller; + if (poller != null) { logger.debug("Unregistering systemStatePoller from ModbusManager"); - systemStatePoller.unregisterPollTask(); + poller.unregisterPollTask(); systemStatePoller = null; } - if (systemParameterPoller != null) { + + poller = systemParameterPoller; + if (poller != null) { logger.debug("Unregistering systemParameterPoller from ModbusManager"); - systemParameterPoller.unregisterPollTask(); + poller.unregisterPollTask(); systemParameterPoller = null; } - unregisterEndpoint(); + endpoint = null; } /** @@ -485,52 +502,11 @@ public int getSlaveId() { ModbusEndpointThingHandler slaveEndpoint = (ModbusEndpointThingHandler) handler; return slaveEndpoint; } else { - logger.debug("Unexpected bridge handler: {}", handler); - throw new IllegalStateException(); - } - } - - /** - * Get a reference to the modbus endpoint - */ - private void connectEndpoint() { - if (endpoint != null) { - return; - } - - ModbusEndpointThingHandler slaveEndpointThingHandler = getEndpointThingHandler(); - if (slaveEndpointThingHandler == null) { - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, String.format("Bridge '%s' is offline", - Optional.ofNullable(getBridge()).map(b -> b.getLabel()).orElse(""))); - logger.debug("No bridge handler available -- aborting init for {}", this); - return; - } - - try { - slaveId = slaveEndpointThingHandler.getSlaveId(); - - endpoint = slaveEndpointThingHandler.asSlaveEndpoint(); - } catch (EndpointNotInitializedException e) { - // this will be handled below as endpoint remains null - } - - if (endpoint == null) { - @SuppressWarnings("null") - String label = Optional.ofNullable(getBridge()).map(b -> b.getLabel()).orElse(""); - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, - String.format("Bridge '%s' not completely initialized", label)); - logger.debug("Bridge not initialized fully (no endpoint) -- aborting init for {}", this); - return; + throw new IllegalStateException("Unexpected bridge handler: " + handler.toString()); } } - /** - * Remove the endpoint if exists - */ - private synchronized void unregisterEndpoint() { - endpoint = null; - } - + /** * Returns value divided by the 10 * @@ -602,21 +578,21 @@ protected void handlePolledEnergyData(ModbusRegisterArray registers) { // Energy information group updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_PRODUCTION_HEAT_TODAY), - new QuantityType<>(block.production_heat_today, KILOWATT_HOUR)); + new QuantityType<>(block.productionHeatToday, KILOWATT_HOUR)); updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_PRODUCTION_HEAT_TOTAL), - getEnergyQuantity(block.production_heat_total_high, block.production_heat_total_low)); + getEnergyQuantity(block.productionHeatTotalHigh, block.productionHeatTotalLow)); updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_PRODUCTION_WATER_TODAY), - new QuantityType<>(block.production_water_today, KILOWATT_HOUR)); + new QuantityType<>(block.productionWaterToday, KILOWATT_HOUR)); updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_PRODUCTION_WATER_TOTAL), - getEnergyQuantity(block.production_water_total_high, block.production_water_total_low)); + getEnergyQuantity(block.productionWaterTotalHigh, block.productionWaterTotalLow)); updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_CONSUMPTION_HEAT_TODAY), - new QuantityType<>(block.consumption_heat_today, KILOWATT_HOUR)); + new QuantityType<>(block.consumptionHeatToday, KILOWATT_HOUR)); updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_CONSUMPTION_HEAT_TOTAL), - getEnergyQuantity(block.consumption_heat_total_high, block.consumption_heat_total_low)); + getEnergyQuantity(block.consumptionHeatTotalHigh, block.consumptionHeatTotalLow)); updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_CONSUMPTION_WATER_TODAY), - new QuantityType<>(block.consumption_water_today, KILOWATT_HOUR)); + new QuantityType<>(block.consumptionWaterToday, KILOWATT_HOUR)); updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_CONSUMPTION_WATER_TOTAL), - getEnergyQuantity(block.consumption_water_total_high, block.consumption_water_total_low)); + getEnergyQuantity(block.consumptionWaterTotalHigh, block.consumptionWaterTotalLow)); } /** @@ -630,9 +606,9 @@ protected void handlePolledSystemStateData(ModbusRegisterArray registers) { logger.trace("System state block received, size: {}", registers.size()); SystemStateBlock block = systemstateBlockParser.parse(registers); - boolean is_heating = (block.state & 16) != 0; + boolean isHeating = (block.state & 16) != 0; updateState(channelUID(GROUP_SYSTEM_STATE, CHANNEL_IS_HEATING), - is_heating ? OpenClosedType.OPEN : OpenClosedType.CLOSED); + isHeating ? OpenClosedType.OPEN : OpenClosedType.CLOSED); updateState(channelUID(GROUP_SYSTEM_STATE, CHANNEL_IS_HEATING_WATER), (block.state & 32) != 0 ? OpenClosedType.OPEN : OpenClosedType.CLOSED); updateState(channelUID(GROUP_SYSTEM_STATE, CHANNEL_IS_COOLING), diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/AbstractBaseParser.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/AbstractBaseParser.java index 0d7f8342ae0e7..58835b137f810 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/AbstractBaseParser.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/AbstractBaseParser.java @@ -38,7 +38,7 @@ public class AbstractBaseParser { */ protected Optional extractOptionalDouble(ModbusRegisterArray raw, int index) { return ModbusBitUtilities.extractStateFromRegisters(raw, index, ValueType.INT16) - .map(value -> ((float) value.intValue()) / 10.0).filter(value -> value != (short) 0x8000); + .map(value -> ((double) value.intValue()) / 10.0).filter(value -> value != (short) 0x8000); } /** diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/EnergyBlockParser.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/EnergyBlockParser.java index 59337914ab467..f31028cb79da4 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/EnergyBlockParser.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/EnergyBlockParser.java @@ -28,19 +28,19 @@ public class EnergyBlockParser extends AbstractBaseParser { public EnergyBlock parse(ModbusRegisterArray raw) { EnergyBlock block = new EnergyBlock(); - block.production_heat_today = extractUInt16(raw, 0, (short) 0); - block.production_heat_total_low = extractUInt16(raw, 1, (short) 0); - block.production_heat_total_high = extractUInt16(raw, 2, (short) 0); - block.production_water_today = extractUInt16(raw, 3, (short) 0); - block.production_water_total_low = extractUInt16(raw, 4, (short) 0); - block.production_water_total_high = extractUInt16(raw, 5, (short) 0); + block.productionHeatToday = extractUInt16(raw, 0, (short) 0); + block.productionHeatTotalLow = extractUInt16(raw, 1, (short) 0); + block.productionHeatTotalHigh = extractUInt16(raw, 2, (short) 0); + block.productionWaterToday = extractUInt16(raw, 3, (short) 0); + block.productionWaterTotalLow = extractUInt16(raw, 4, (short) 0); + block.productionWaterTotalHigh = extractUInt16(raw, 5, (short) 0); - block.consumption_heat_today = extractUInt16(raw, 10, (short) 0); - block.consumption_heat_total_low = extractUInt16(raw, 11, (short) 0); - block.consumption_heat_total_high = extractUInt16(raw, 12, (short) 0); - block.consumption_water_today = extractUInt16(raw, 13, (short) 0); - block.consumption_water_total_low = extractUInt16(raw, 14, (short) 0); - block.consumption_water_total_high = extractUInt16(raw, 15, (short) 0); + block.consumptionHeatToday = extractUInt16(raw, 10, (short) 0); + block.consumptionHeatTotalLow = extractUInt16(raw, 11, (short) 0); + block.consumptionHeatTotalHigh = extractUInt16(raw, 12, (short) 0); + block.consumptionWaterToday = extractUInt16(raw, 13, (short) 0); + block.consumptionWaterTotalLow = extractUInt16(raw, 14, (short) 0); + block.consumptionWaterTotalHigh = extractUInt16(raw, 15, (short) 0); return block; } } From 696c6ba0ed9b45b3911504b7d201323a0a164289 Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Fri, 19 Jun 2020 21:45:26 +0200 Subject: [PATCH 08/20] removed warnings Signed-off-by: Paul Frank --- .../handler/StiebelEltronHandler.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java index 1d3d8fb9a8c73..1840ef172e4ff 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java @@ -36,7 +36,6 @@ import org.eclipse.smarthome.core.thing.binding.BaseThingHandler; import org.eclipse.smarthome.core.thing.binding.ThingHandler; import org.eclipse.smarthome.core.types.Command; -import org.eclipse.smarthome.core.types.RefreshType; import org.eclipse.smarthome.core.types.State; import org.openhab.binding.modbus.handler.EndpointNotInitializedException; import org.openhab.binding.modbus.handler.ModbusEndpointThingHandler; @@ -70,7 +69,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; - /** * The {@link Modbus.StiebelEltronHandler} is responsible for handling commands, * which are sent to one of the channels and for polling the modbus. @@ -79,7 +77,7 @@ */ @NonNullByDefault public class StiebelEltronHandler extends BaseThingHandler { - + public abstract class AbstractBasePoller { private final Logger logger = LoggerFactory.getLogger(StiebelEltronHandler.class); @@ -211,7 +209,7 @@ public void onBits(@Nullable ModbusReadRequestBlueprint request, @Nullable BitAr /** * Instances of this handler should get a reference to the modbus manager * - * @param thing the thing to handle + * @param thing the thing to handle * @param modbusManager the modbus manager */ public StiebelEltronHandler(Thing thing, ModbusManager modbusManager) { @@ -220,7 +218,7 @@ public StiebelEltronHandler(Thing thing, ModbusManager modbusManager) { } /** - * @param address address of the value to be written on the modbus + * @param address address of the value to be written on the modbus * @param shortValue value to be written on the modbus */ protected void writeInt16(int address, short shortValue) { @@ -228,7 +226,7 @@ protected void writeInt16(int address, short shortValue) { StiebelEltronConfiguration myconfig = StiebelEltronHandler.this.config; if (myconfig == null) { throw new IllegalStateException("registerPollTask called without proper configuration"); - } + } // big endian byte ordering byte b1 = (byte) (shortValue >> 8); byte b2 = (byte) shortValue; @@ -265,13 +263,17 @@ public void onError(ModbusWriteRequestBlueprint request, Exception error) { /** * @param command get the value of this command. - * @return short the value of the command multiplied by 10 (see datatype 2 in the stiebel eltron modbus - * documentation) + * @return short the value of the command multiplied by 10 (see datatype 2 in + * the stiebel eltron modbus documentation) */ private short getScaledInt16Value(Command command) throws IllegalArgumentException { if (command instanceof QuantityType) { QuantityType c = ((QuantityType) command).toUnit(CELSIUS); - return (short) (c.doubleValue() * 10); + if (c != null) { + return (short) (c.doubleValue() * 10); + } else { + throw new IllegalArgumentException(); + } } if (command instanceof DecimalType) { DecimalType c = (DecimalType) command; @@ -317,8 +319,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { break; } } - } - catch(IllegalArgumentException e){ + } catch (IllegalArgumentException e) { handleError(e); } } @@ -336,8 +337,8 @@ public void initialize() { } /* - * This method starts the operation of this handler - * Connect to the slave bridge Start the periodic polling1 + * This method starts the operation of this handler Connect to the slave bridge + * Start the periodic polling1 */ private void startUp() { @@ -386,7 +387,7 @@ protected void handlePolledData(ModbusRegisterArray registers) { systemInformationPoller = poller; } if (energyPoller == null) { - AbstractBasePoller poller = new AbstractBasePoller() { + AbstractBasePoller poller = new AbstractBasePoller() { @Override protected void handlePolledData(ModbusRegisterArray registers) { handlePolledEnergyData(registers); @@ -397,7 +398,7 @@ protected void handlePolledData(ModbusRegisterArray registers) { energyPoller = poller; } if (systemStatePoller == null) { - AbstractBasePoller poller = new AbstractBasePoller() { + AbstractBasePoller poller = new AbstractBasePoller() { @Override protected void handlePolledData(ModbusRegisterArray registers) { handlePolledSystemStateData(registers); @@ -408,7 +409,7 @@ protected void handlePolledData(ModbusRegisterArray registers) { systemStatePoller = poller; } if (systemParameterPoller == null) { - AbstractBasePoller poller = new AbstractBasePoller() { + AbstractBasePoller poller = new AbstractBasePoller() { @Override protected void handlePolledData(ModbusRegisterArray registers) { handlePolledSystemParameterData(registers); @@ -506,7 +507,6 @@ public int getSlaveId() { } } - /** * Returns value divided by the 10 * @@ -521,7 +521,7 @@ protected State getScaled(Number value, Unit unit) { * Returns high value * 1000 + low value * * @param high the high value - * @param low the low valze + * @param low the low valze * @return the scaled value as a DecimalType */ protected State getEnergyQuantity(int high, int low) { From b69c402a54834c2d1e91753bdb5d9a91d25f78bb Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Mon, 22 Jun 2020 20:50:17 +0200 Subject: [PATCH 09/20] Added handling for REFRESH and changed exception Signed-off-by: Paul Frank --- .../handler/StiebelEltronException.java | 29 +++++++ .../handler/StiebelEltronHandler.java | 78 +++++++++++++------ 2 files changed, 84 insertions(+), 23 deletions(-) create mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronException.java diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronException.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronException.java new file mode 100644 index 0000000000000..44b2c90caed70 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronException.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.modbus.stiebeleltron.internal.handler; + +/** + * Thrown when the stiebel eltron handler sees an error. + * + * @author Paul Frank - Initial contribution + */ +@SuppressWarnings("serial") +public class StiebelEltronException extends Exception { + + public StiebelEltronException() { + } + + public StiebelEltronException(String message) { + super(message); + } +} \ No newline at end of file diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java index 1840ef172e4ff..bd3928a1c1e5b 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java @@ -36,6 +36,7 @@ import org.eclipse.smarthome.core.thing.binding.BaseThingHandler; import org.eclipse.smarthome.core.thing.binding.ThingHandler; import org.eclipse.smarthome.core.types.Command; +import org.eclipse.smarthome.core.types.RefreshType; import org.eclipse.smarthome.core.types.State; import org.openhab.binding.modbus.handler.EndpointNotInitializedException; import org.openhab.binding.modbus.handler.ModbusEndpointThingHandler; @@ -77,7 +78,7 @@ */ @NonNullByDefault public class StiebelEltronHandler extends BaseThingHandler { - + public abstract class AbstractBasePoller { private final Logger logger = LoggerFactory.getLogger(StiebelEltronHandler.class); @@ -139,13 +140,20 @@ public void onBits(@Nullable ModbusReadRequestBlueprint request, @Nullable BitAr }); long refreshMillis = myconfig.getRefreshMillis(); - @Nullable + PollTask task = pollTask; if (task != null) { StiebelEltronHandler.this.modbusManager.registerRegularPoll(task, refreshMillis, 1000); } } + public synchronized void poll() { + PollTask task = pollTask; + if (task != null) { + StiebelEltronHandler.this.modbusManager.submitOneTimePoll(task); + } + } + protected abstract void handlePolledData(ModbusRegisterArray registers); } @@ -266,32 +274,32 @@ public void onError(ModbusWriteRequestBlueprint request, Exception error) { * @return short the value of the command multiplied by 10 (see datatype 2 in * the stiebel eltron modbus documentation) */ - private short getScaledInt16Value(Command command) throws IllegalArgumentException { + private short getScaledInt16Value(Command command) throws StiebelEltronException { if (command instanceof QuantityType) { QuantityType c = ((QuantityType) command).toUnit(CELSIUS); if (c != null) { return (short) (c.doubleValue() * 10); } else { - throw new IllegalArgumentException(); + throw new StiebelEltronException("Unsupported unit"); } } if (command instanceof DecimalType) { DecimalType c = (DecimalType) command; return (short) (c.doubleValue() * 10); } - throw new IllegalArgumentException(); + throw new StiebelEltronException("Unsupported command type"); } /** * @param command get the value of this command. * @return short the value of the command as short */ - private short getInt16Value(Command command) throws IllegalArgumentException { + private short getInt16Value(Command command) throws StiebelEltronException { if (command instanceof DecimalType) { DecimalType c = (DecimalType) command; return c.shortValue(); } - throw new IllegalArgumentException(); + throw new StiebelEltronException("Unsupported command type"); } /** @@ -299,28 +307,52 @@ private short getInt16Value(Command command) throws IllegalArgumentException { */ @Override public void handleCommand(ChannelUID channelUID, Command command) { - try { - if (GROUP_SYSTEM_PARAMETER.equals(channelUID.getGroupId())) { - switch (channelUID.getIdWithoutGroup()) { - case CHANNEL_OPERATION_MODE: - writeInt16(1500, getInt16Value(command)); - break; - case CHANNEL_COMFORT_TEMPERATURE_HEATING: - writeInt16(1501, getScaledInt16Value(command)); + if (RefreshType.REFRESH == command) { + AbstractBasePoller poller = null; + String groupId = channelUID.getGroupId(); + if (groupId != null) { + switch (groupId) { + case GROUP_SYSTEM_STATE: + poller = systemStatePoller; break; - case CHANNEL_ECO_TEMPERATURE_HEATING: - writeInt16(1502, getScaledInt16Value(command)); + case GROUP_SYSTEM_PARAMETER: + poller = systemParameterPoller; break; - case CHANNEL_COMFORT_TEMPERATURE_WATER: - writeInt16(1509, getScaledInt16Value(command)); + case GROUP_SYSTEM_INFO: + poller = systemInformationPoller; break; - case CHANNEL_ECO_TEMPERATURE_WATER: - writeInt16(1510, getScaledInt16Value(command)); + case GROUP_ENERGY_INFO: + poller = energyPoller; break; } } - } catch (IllegalArgumentException e) { - handleError(e); + if (poller != null) { + poller.poll(); + } + } else { + try { + if (GROUP_SYSTEM_PARAMETER.equals(channelUID.getGroupId())) { + switch (channelUID.getIdWithoutGroup()) { + case CHANNEL_OPERATION_MODE: + writeInt16(1500, getInt16Value(command)); + break; + case CHANNEL_COMFORT_TEMPERATURE_HEATING: + writeInt16(1501, getScaledInt16Value(command)); + break; + case CHANNEL_ECO_TEMPERATURE_HEATING: + writeInt16(1502, getScaledInt16Value(command)); + break; + case CHANNEL_COMFORT_TEMPERATURE_WATER: + writeInt16(1509, getScaledInt16Value(command)); + break; + case CHANNEL_ECO_TEMPERATURE_WATER: + writeInt16(1510, getScaledInt16Value(command)); + break; + } + } + } catch (StiebelEltronException e) { + handleError(e); + } } } From 9255cf2dd9962c104295fb47c95fa16f13bd42c6 Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Wed, 24 Jun 2020 20:44:28 +0200 Subject: [PATCH 10/20] Update bundles/org.openhab.binding.modbus.stiebeleltron/README.md Co-authored-by: Fabian Wolter Signed-off-by: Paul Frank --- bundles/org.openhab.binding.modbus.stiebeleltron/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/README.md b/bundles/org.openhab.binding.modbus.stiebeleltron/README.md index fa55b5c2dd430..2f39f07df6f36 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/README.md +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/README.md @@ -2,7 +2,7 @@ This extension adds support for the Stiebel Eltron modbus protocol. -A Internet Service Gateway (ISG) with an installed modbus extension is required in order to run this binding. In case the modbus extension is not yet installed on the ISG, the ISG Updater Tool for the update can be found here: https://www.stiebel-eltron.de/de/home/produkte-loesungen/erneuerbare_energien/regelung_energiemanagement/internet_servicegateway/isg_web/downloads.html +An Internet Service Gateway (ISG) with an installed modbus extension is required in order to run this binding. In case the modbus extension is not yet installed on the ISG, the ISG Updater Tool for the update can be found here: https://www.stiebel-eltron.de/de/home/produkte-loesungen/erneuerbare_energien/regelung_energiemanagement/internet_servicegateway/isg_web/downloads.html @@ -203,4 +203,3 @@ Number:Energy stiebel_eltron_consumption_water_total "Water heating p } ``` - From 95fbb82bab8907a568cd8c0583d97614a77b42f1 Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Wed, 24 Jun 2020 20:44:54 +0200 Subject: [PATCH 11/20] Update bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemInformationBlock.java Co-authored-by: Fabian Wolter Signed-off-by: Paul Frank --- .../stiebeleltron/internal/dto/SystemInformationBlock.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemInformationBlock.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemInformationBlock.java index a3a6393fbece7..cf2a32fc7e7d0 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemInformationBlock.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemInformationBlock.java @@ -20,7 +20,7 @@ */ public class SystemInformationBlock { - public short temperature_fek; + public short temperatureFek; public short temperature_fek_setpoint; public short humidity_ffk; public short dewpoint_ffk; From b7befb6f57e751f51d52f0bdd514614e51375159 Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Wed, 24 Jun 2020 20:45:07 +0200 Subject: [PATCH 12/20] Update bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java Co-authored-by: Fabian Wolter Signed-off-by: Paul Frank --- .../stiebeleltron/internal/handler/StiebelEltronHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java index bd3928a1c1e5b..b94d8190d380e 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java @@ -546,7 +546,7 @@ public int getSlaveId() { * @return the scaled value as a DecimalType */ protected State getScaled(Number value, Unit unit) { - return new QuantityType<>(BigDecimal.valueOf(value.longValue(), 1), unit); + return QuantityType.valueOf(value.doubleValue(), unit); } /** From b8d80b481a47d36c034b26cac5d7f7bec6d0c4ce Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Wed, 24 Jun 2020 21:06:36 +0200 Subject: [PATCH 13/20] fixed review findings Signed-off-by: Paul Frank --- .../internal/dto/SystemInformationBlock.java | 22 +++---- .../internal/dto/SystemParameterBlock.java | 10 +-- .../internal/dto/SystemStateBlock.java | 2 +- .../handler/StiebelEltronException.java | 3 + .../handler/StiebelEltronHandler.java | 61 ++++++++++--------- .../parser/SystemInfromationBlockParser.java | 24 ++++---- .../parser/SystemParameterBlockParser.java | 10 +-- .../ESH-INF/config/config-descriptions.xml | 2 +- 8 files changed, 71 insertions(+), 63 deletions(-) diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemInformationBlock.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemInformationBlock.java index cf2a32fc7e7d0..14a7dbee5b53a 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemInformationBlock.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemInformationBlock.java @@ -21,15 +21,15 @@ public class SystemInformationBlock { public short temperatureFek; - public short temperature_fek_setpoint; - public short humidity_ffk; - public short dewpoint_ffk; - public short temperature_outdoor; - public short temperature_hk1; - public short temperature_hk1_setpoint; - public short temperature_supply; - public short temperature_return; - public short temperature_source; - public short temperature_water; - public short temperature_water_setpoint; + public short temperatureFekSetPoint; + public short humidityFek; + public short dewpointFek; + public short temperatureOutdoor; + public short temperatureHk1; + public short temperatureHk1SetPoint; + public short temperatureSupply; + public short temperatureReturn; + public short temperatureSource; + public short temperatureWater; + public short temperatureWaterSetPoint; } diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemParameterBlock.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemParameterBlock.java index f709e2fb0de7a..694bb43617594 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemParameterBlock.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemParameterBlock.java @@ -20,9 +20,9 @@ */ public class SystemParameterBlock { - public Integer operation_mode; - public short comfort_temperature_heating; - public short eco_temperature_heating; - public short comfort_temperature_water; - public short eco_temperature_water; + public int operationMode; + public short comfortTemperatureHeating; + public short ecoTemperatureHeating; + public short comfortTemperatureWater; + public short ecoTemperatureWater; } diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemStateBlock.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemStateBlock.java index d80b92f5492b0..320f949eefcf4 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemStateBlock.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/dto/SystemStateBlock.java @@ -20,5 +20,5 @@ */ public class SystemStateBlock { - public Integer state; + public int state; } diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronException.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronException.java index 44b2c90caed70..dca1dcd23713c 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronException.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronException.java @@ -12,12 +12,15 @@ */ package org.openhab.binding.modbus.stiebeleltron.internal.handler; +import org.eclipse.jdt.annotation.NonNullByDefault; + /** * Thrown when the stiebel eltron handler sees an error. * * @author Paul Frank - Initial contribution */ @SuppressWarnings("serial") +@NonNullByDefault public class StiebelEltronException extends Exception { public StiebelEltronException() { diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java index b94d8190d380e..0f1e9cd776ca5 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java @@ -17,7 +17,6 @@ import static org.eclipse.smarthome.core.library.unit.SmartHomeUnits.PERCENT; import static org.openhab.binding.modbus.stiebeleltron.internal.StiebelEltronBindingConstants.*; -import java.math.BigDecimal; import java.util.Optional; import javax.measure.Unit; @@ -230,7 +229,6 @@ public StiebelEltronHandler(Thing thing, ModbusManager modbusManager) { * @param shortValue value to be written on the modbus */ protected void writeInt16(int address, short shortValue) { - @Nullable StiebelEltronConfiguration myconfig = StiebelEltronHandler.this.config; if (myconfig == null) { throw new IllegalStateException("registerPollTask called without proper configuration"); @@ -308,9 +306,9 @@ private short getInt16Value(Command command) throws StiebelEltronException { @Override public void handleCommand(ChannelUID channelUID, Command command) { if (RefreshType.REFRESH == command) { - AbstractBasePoller poller = null; String groupId = channelUID.getGroupId(); if (groupId != null) { + AbstractBasePoller poller; switch (groupId) { case GROUP_SYSTEM_STATE: poller = systemStatePoller; @@ -324,10 +322,13 @@ public void handleCommand(ChannelUID channelUID, Command command) { case GROUP_ENERGY_INFO: poller = energyPoller; break; + default: + poller = null; + break; + } + if (poller != null) { + poller.poll(); } - } - if (poller != null) { - poller.poll(); } } else { try { @@ -381,7 +382,6 @@ private void startUp() { ModbusEndpointThingHandler slaveEndpointThingHandler = getEndpointThingHandler(); if (slaveEndpointThingHandler == null) { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, "Bridge is offline"); - logger.debug("No bridge handler available -- aborting init for {}", this); return; } @@ -398,7 +398,6 @@ private void startUp() { String label = Optional.ofNullable(getBridge()).map(b -> b.getLabel()).orElse(""); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, String.format("Bridge '%s' not completely initialized", label)); - logger.debug("Bridge not initialized fully (no endpoint) -- aborting init for {}", this); return; } @@ -574,26 +573,28 @@ protected void handlePolledSystemInformationData(ModbusRegisterArray registers) SystemInformationBlock block = systemInformationBlockParser.parse(registers); // System information group - updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_FEK_TEMPERATURE), getScaled(block.temperature_fek, CELSIUS)); + updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_FEK_TEMPERATURE), getScaled(block.temperatureFek, CELSIUS)); updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_FEK_TEMPERATURE_SETPOINT), - getScaled(block.temperature_fek_setpoint, CELSIUS)); - updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_FEK_HUMIDITY), getScaled(block.humidity_ffk, PERCENT)); - updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_FEK_DEWPOINT), getScaled(block.dewpoint_ffk, CELSIUS)); + getScaled(block.temperatureFekSetPoint, CELSIUS)); + updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_FEK_HUMIDITY), getScaled(block.humidityFek, PERCENT)); + updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_FEK_DEWPOINT), getScaled(block.dewpointFek, CELSIUS)); updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_OUTDOOR_TEMPERATURE), - getScaled(block.temperature_outdoor, CELSIUS)); - updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_HK1_TEMPERATURE), getScaled(block.temperature_hk1, CELSIUS)); + getScaled(block.temperatureOutdoor, CELSIUS)); + updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_HK1_TEMPERATURE), getScaled(block.temperatureHk1, CELSIUS)); updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_HK1_TEMPERATURE_SETPOINT), - getScaled(block.temperature_hk1_setpoint, CELSIUS)); + getScaled(block.temperatureHk1SetPoint, CELSIUS)); updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_SUPPLY_TEMPERATURE), - getScaled(block.temperature_supply, CELSIUS)); + getScaled(block.temperatureSupply, CELSIUS)); updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_RETURN_TEMPERATURE), - getScaled(block.temperature_return, CELSIUS)); + getScaled(block.temperatureReturn, CELSIUS)); updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_SOURCE_TEMPERATURE), - getScaled(block.temperature_source, CELSIUS)); + getScaled(block.temperatureSource, CELSIUS)); updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_WATER_TEMPERATURE), - getScaled(block.temperature_water, CELSIUS)); + getScaled(block.temperatureWater, CELSIUS)); updateState(channelUID(GROUP_SYSTEM_INFO, CHANNEL_WATER_TEMPERATURE_SETPOINT), - getScaled(block.temperature_water_setpoint, CELSIUS)); + getScaled(block.temperatureWaterSetPoint, CELSIUS)); + + resetCommunicationError(); } /** @@ -625,6 +626,8 @@ protected void handlePolledEnergyData(ModbusRegisterArray registers) { new QuantityType<>(block.consumptionWaterToday, KILOWATT_HOUR)); updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_CONSUMPTION_WATER_TOTAL), getEnergyQuantity(block.consumptionWaterTotalHigh, block.consumptionWaterTotalLow)); + + resetCommunicationError(); } /** @@ -650,6 +653,7 @@ protected void handlePolledSystemStateData(ModbusRegisterArray registers) { updateState(channelUID(GROUP_SYSTEM_STATE, CHANNEL_IS_PUMPING), (block.state & 1) != 0 ? OpenClosedType.OPEN : OpenClosedType.CLOSED); + resetCommunicationError(); } /** @@ -663,16 +667,18 @@ protected void handlePolledSystemParameterData(ModbusRegisterArray registers) { logger.trace("System state block received, size: {}", registers.size()); SystemParameterBlock block = systemParameterBlockParser.parse(registers); - updateState(channelUID(GROUP_SYSTEM_PARAMETER, CHANNEL_OPERATION_MODE), new DecimalType(block.operation_mode)); + updateState(channelUID(GROUP_SYSTEM_PARAMETER, CHANNEL_OPERATION_MODE), new DecimalType(block.operationMode)); updateState(channelUID(GROUP_SYSTEM_PARAMETER, CHANNEL_COMFORT_TEMPERATURE_HEATING), - getScaled(block.comfort_temperature_heating, CELSIUS)); + getScaled(block.comfortTemperatureHeating, CELSIUS)); updateState(channelUID(GROUP_SYSTEM_PARAMETER, CHANNEL_ECO_TEMPERATURE_HEATING), - getScaled(block.eco_temperature_heating, CELSIUS)); + getScaled(block.ecoTemperatureHeating, CELSIUS)); updateState(channelUID(GROUP_SYSTEM_PARAMETER, CHANNEL_COMFORT_TEMPERATURE_WATER), - getScaled(block.comfort_temperature_water, CELSIUS)); + getScaled(block.comfortTemperatureWater, CELSIUS)); updateState(channelUID(GROUP_SYSTEM_PARAMETER, CHANNEL_ECO_TEMPERATURE_WATER), - getScaled(block.eco_temperature_water, CELSIUS)); + getScaled(block.ecoTemperatureWater, CELSIUS)); + + resetCommunicationError(); } /** @@ -682,10 +688,9 @@ protected void handlePolledSystemParameterData(ModbusRegisterArray registers) { public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { super.bridgeStatusChanged(bridgeStatusInfo); - logger.debug("Thing status changed to {}", this.getThing().getStatus().name()); - if (getThing().getStatus() == ThingStatus.ONLINE) { + if (bridgeStatusInfo.getStatus() == ThingStatus.ONLINE) { startUp(); - } else if (getThing().getStatus() == ThingStatus.OFFLINE) { + } else if (bridgeStatusInfo.getStatus() == ThingStatus.OFFLINE) { tearDown(); } } diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/SystemInfromationBlockParser.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/SystemInfromationBlockParser.java index ae5cc905d6338..71b81b70fa0da 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/SystemInfromationBlockParser.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/SystemInfromationBlockParser.java @@ -28,18 +28,18 @@ public class SystemInfromationBlockParser extends AbstractBaseParser { public SystemInformationBlock parse(ModbusRegisterArray raw) { SystemInformationBlock block = new SystemInformationBlock(); - block.temperature_fek = extractInt16(raw, 2, (short) 0); - block.temperature_fek_setpoint = extractInt16(raw, 3, (short) 0); - block.humidity_ffk = extractInt16(raw, 4, (short) 0); - block.dewpoint_ffk = extractInt16(raw, 5, (short) 0); - block.temperature_outdoor = extractInt16(raw, 6, (short) 0); - block.temperature_hk1 = extractInt16(raw, 7, (short) 0); - block.temperature_hk1_setpoint = extractInt16(raw, 9, (short) 0); - block.temperature_supply = extractInt16(raw, 12, (short) 0); - block.temperature_return = extractInt16(raw, 15, (short) 0); - block.temperature_water = extractInt16(raw, 21, (short) 0); - block.temperature_water_setpoint = extractInt16(raw, 22, (short) 0); - block.temperature_source = extractInt16(raw, 35, (short) 0); + block.temperatureFek = extractInt16(raw, 2, (short) 0); + block.temperatureFekSetPoint = extractInt16(raw, 3, (short) 0); + block.humidityFek = extractInt16(raw, 4, (short) 0); + block.dewpointFek = extractInt16(raw, 5, (short) 0); + block.temperatureOutdoor = extractInt16(raw, 6, (short) 0); + block.temperatureHk1 = extractInt16(raw, 7, (short) 0); + block.temperatureHk1SetPoint = extractInt16(raw, 9, (short) 0); + block.temperatureSupply = extractInt16(raw, 12, (short) 0); + block.temperatureReturn = extractInt16(raw, 15, (short) 0); + block.temperatureWater = extractInt16(raw, 21, (short) 0); + block.temperatureWaterSetPoint = extractInt16(raw, 22, (short) 0); + block.temperatureSource = extractInt16(raw, 35, (short) 0); return block; } } diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/SystemParameterBlockParser.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/SystemParameterBlockParser.java index 88e0ec6d5387d..f1bd72f7c4321 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/SystemParameterBlockParser.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/SystemParameterBlockParser.java @@ -28,11 +28,11 @@ public class SystemParameterBlockParser extends AbstractBaseParser { public SystemParameterBlock parse(ModbusRegisterArray raw) { SystemParameterBlock block = new SystemParameterBlock(); - block.operation_mode = extractUInt16(raw, 0, 0); - block.comfort_temperature_heating = extractInt16(raw, 1, (short) 0); - block.eco_temperature_heating = extractInt16(raw, 2, (short) 0); - block.comfort_temperature_water = extractInt16(raw, 9, (short) 0); - block.eco_temperature_water = extractInt16(raw, 10, (short) 0); + block.operationMode = extractUInt16(raw, 0, 0); + block.comfortTemperatureHeating = extractInt16(raw, 1, (short) 0); + block.ecoTemperatureHeating = extractInt16(raw, 2, (short) 0); + block.comfortTemperatureWater = extractInt16(raw, 9, (short) 0); + block.ecoTemperatureWater = extractInt16(raw, 10, (short) 0); return block; } } diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/config/config-descriptions.xml b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/config/config-descriptions.xml index 9cce1df2c1d37..d88938a7c4f46 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/config/config-descriptions.xml +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/config/config-descriptions.xml @@ -6,7 +6,7 @@ - + Poll interval in seconds. Use zero to disable automatic polling. 5 From 979016502f2acc1fc9bd619b99881297b71c52fa Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Wed, 24 Jun 2020 21:07:42 +0200 Subject: [PATCH 14/20] mvn spotless:apply Signed-off-by: Paul Frank --- .../internal/StiebelEltronConfiguration.java | 1 - .../handler/StiebelEltronException.java | 4 +- .../handler/StiebelEltronHandler.java | 12 +--- .../internal/parser/AbstractBaseParser.java | 1 - .../ESH-INF/thing/heatpump-channel-groups.xml | 60 +++++++++---------- .../ESH-INF/thing/heatpump-channel-types.xml | 58 +++++++++--------- .../ESH-INF/thing/heatpump-types.xml | 14 ++--- 7 files changed, 71 insertions(+), 79 deletions(-) diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronConfiguration.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronConfiguration.java index c496d8dcf7d5e..e86e763cbc4d8 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronConfiguration.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronConfiguration.java @@ -43,5 +43,4 @@ public int getMaxTries() { public void setMaxTries(int maxTries) { this.maxTries = maxTries; } - } diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronException.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronException.java index dca1dcd23713c..7a20e0f09cbc2 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronException.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronException.java @@ -28,5 +28,5 @@ public StiebelEltronException() { public StiebelEltronException(String message) { super(message); - } -} \ No newline at end of file + } +} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java index 0f1e9cd776ca5..dc3199fc56d07 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java @@ -154,7 +154,6 @@ public synchronized void poll() { } protected abstract void handlePolledData(ModbusRegisterArray registers); - } /** @@ -216,7 +215,7 @@ public synchronized void poll() { /** * Instances of this handler should get a reference to the modbus manager * - * @param thing the thing to handle + * @param thing the thing to handle * @param modbusManager the modbus manager */ public StiebelEltronHandler(Thing thing, ModbusManager modbusManager) { @@ -225,7 +224,7 @@ public StiebelEltronHandler(Thing thing, ModbusManager modbusManager) { } /** - * @param address address of the value to be written on the modbus + * @param address address of the value to be written on the modbus * @param shortValue value to be written on the modbus */ protected void writeInt16(int address, short shortValue) { @@ -412,7 +411,6 @@ private void startUp() { protected void handlePolledData(ModbusRegisterArray registers) { handlePolledSystemInformationData(registers); } - }; poller.registerPollTask(500, 36, ModbusReadFunctionCode.READ_INPUT_REGISTERS); systemInformationPoller = poller; @@ -423,7 +421,6 @@ protected void handlePolledData(ModbusRegisterArray registers) { protected void handlePolledData(ModbusRegisterArray registers) { handlePolledEnergyData(registers); } - }; poller.registerPollTask(3500, 16, ModbusReadFunctionCode.READ_INPUT_REGISTERS); energyPoller = poller; @@ -434,7 +431,6 @@ protected void handlePolledData(ModbusRegisterArray registers) { protected void handlePolledData(ModbusRegisterArray registers) { handlePolledSystemStateData(registers); } - }; poller.registerPollTask(2500, 2, ModbusReadFunctionCode.READ_INPUT_REGISTERS); systemStatePoller = poller; @@ -445,7 +441,6 @@ protected void handlePolledData(ModbusRegisterArray registers) { protected void handlePolledData(ModbusRegisterArray registers) { handlePolledSystemParameterData(registers); } - }; poller.registerPollTask(1500, 11, ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS); systemParameterPoller = poller; @@ -552,7 +547,7 @@ protected State getScaled(Number value, Unit unit) { * Returns high value * 1000 + low value * * @param high the high value - * @param low the low valze + * @param low the low valze * @return the scaled value as a DecimalType */ protected State getEnergyQuantity(int high, int low) { @@ -745,5 +740,4 @@ protected void resetCommunicationError() { ChannelUID channelUID(String group, String id) { return new ChannelUID(getThing().getUID(), group, id); } - } diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/AbstractBaseParser.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/AbstractBaseParser.java index 58835b137f810..1b1319a681e60 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/AbstractBaseParser.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/parser/AbstractBaseParser.java @@ -124,5 +124,4 @@ protected Optional extractOptionalUInt32(ModbusRegisterArray raw, int inde protected Long extractUnit32(ModbusRegisterArray raw, int index, long def) { return extractOptionalUInt32(raw, index).orElse(def); } - } diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-groups.xml b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-groups.xml index 07ef115617d6e..76f2fd8a343ad 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-groups.xml +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-groups.xml @@ -7,54 +7,54 @@ - - - - - + + + + + - - - - - + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - + + + + + + + + diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-types.xml b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-types.xml index f62f1cf43c23d..b409f22da06c8 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-types.xml +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-types.xml @@ -7,132 +7,132 @@ Number:Temperature - + Number:Temperature - + Number:Dimensionless - + Number:Temperature - + Number:Temperature - + Number:Temperature - + Number:Temperature - + Number:Temperature - + Number:Temperature - + Number:Temperature - + Number:Temperature - + Number:Temperature - + Number:Energy - + Number:Energy - + Number:Energy - + Number:Energy - + Number:Energy - + Number:Energy - + Number:Energy - + Number:Energy - + Contact - + Contact - + Contact - + Contact - + Contact - + Number @@ -151,21 +151,21 @@ Number:Temperature - + Number:Temperature - + Number:Temperature - + Number:Temperature - + diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-types.xml b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-types.xml index 0e3f262775918..deca01b55d0f8 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-types.xml +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-types.xml @@ -6,20 +6,20 @@ - - + + Stiebel Eltron ISG connected through modbus - - - - + + + + - + From f9528e38a573dc8357afdcca1809a64ff90558e1 Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Wed, 24 Jun 2020 21:27:49 +0200 Subject: [PATCH 15/20] rebased from upstream 2.5.x and upgraded 2.5.7 Signed-off-by: Paul Frank --- bundles/org.openhab.binding.modbus.stiebeleltron/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/pom.xml b/bundles/org.openhab.binding.modbus.stiebeleltron/pom.xml index 0cf89e85dd1d5..6a8b234f9c087 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/pom.xml +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/pom.xml @@ -7,7 +7,7 @@ org.openhab.addons.bundles org.openhab.addons.reactor.bundles - 2.5.6-SNAPSHOT + 2.5.7-SNAPSHOT org.openhab.binding.modbus.stiebeleltron From 9c7602088cadcf08023ec069400a75305939dfe5 Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Sun, 12 Jul 2020 10:06:20 +0200 Subject: [PATCH 16/20] Adapted to simplified modbus api Signed-off-by: Paul Frank --- .../internal/StiebelEltronHandlerFactory.java | 19 +- .../handler/StiebelEltronHandler.java | 164 +++++++----------- 2 files changed, 68 insertions(+), 115 deletions(-) diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronHandlerFactory.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronHandlerFactory.java index 54dc499afb38b..0b150747ceecd 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronHandlerFactory.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/StiebelEltronHandlerFactory.java @@ -25,10 +25,7 @@ import org.eclipse.smarthome.core.thing.binding.ThingHandler; import org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory; import org.openhab.binding.modbus.stiebeleltron.internal.handler.StiebelEltronHandler; -import org.openhab.io.transport.modbus.ModbusManager; -import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Reference; /** * The {@link Modbus.StiebelEltronHandlerFactory} is responsible for creating things and thing @@ -40,22 +37,8 @@ @Component(configurationPid = "binding.stiebeleltron", service = ThingHandlerFactory.class) public class StiebelEltronHandlerFactory extends BaseThingHandlerFactory { - private ModbusManager manager; - private static final Set SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_HEATPUMP); - /** - * This factory needs a reference to the ModbusManager wich is provided - * by the org.openhab.io.transport.modbus bundle. Please make - * sure it's installed and enabled before using this bundle - * - * @param manager reference to the ModbusManager. We use this for modbus communication - */ - @Activate - public StiebelEltronHandlerFactory(@Reference ModbusManager manager) { - this.manager = manager; - } - @Override public boolean supportsThingType(ThingTypeUID thingTypeUID) { return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID); @@ -66,7 +49,7 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) { ThingTypeUID thingTypeUID = thing.getThingTypeUID(); if (THING_TYPE_HEATPUMP.equals(thingTypeUID)) { - return new StiebelEltronHandler(thing, manager); + return new StiebelEltronHandler(thing); } return null; diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java index dc3199fc56d07..e2a8f5665afe8 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java @@ -48,24 +48,15 @@ import org.openhab.binding.modbus.stiebeleltron.internal.parser.SystemInfromationBlockParser; import org.openhab.binding.modbus.stiebeleltron.internal.parser.SystemParameterBlockParser; import org.openhab.binding.modbus.stiebeleltron.internal.parser.SystemStateBlockParser; -import org.openhab.io.transport.modbus.BasicModbusReadRequestBlueprint; -import org.openhab.io.transport.modbus.BasicModbusRegister; -import org.openhab.io.transport.modbus.BasicModbusRegisterArray; -import org.openhab.io.transport.modbus.BasicModbusWriteRegisterRequestBlueprint; -import org.openhab.io.transport.modbus.BasicPollTaskImpl; -import org.openhab.io.transport.modbus.BasicWriteTask; -import org.openhab.io.transport.modbus.BitArray; -import org.openhab.io.transport.modbus.ModbusManager; -import org.openhab.io.transport.modbus.ModbusReadCallback; +import org.openhab.io.transport.modbus.AsyncModbusFailure; +import org.openhab.io.transport.modbus.ModbusCommunicationInterface; import org.openhab.io.transport.modbus.ModbusReadFunctionCode; import org.openhab.io.transport.modbus.ModbusReadRequestBlueprint; import org.openhab.io.transport.modbus.ModbusRegister; import org.openhab.io.transport.modbus.ModbusRegisterArray; -import org.openhab.io.transport.modbus.ModbusResponse; -import org.openhab.io.transport.modbus.ModbusWriteCallback; +import org.openhab.io.transport.modbus.ModbusWriteRegisterRequestBlueprint; import org.openhab.io.transport.modbus.ModbusWriteRequestBlueprint; import org.openhab.io.transport.modbus.PollTask; -import org.openhab.io.transport.modbus.endpoint.ModbusSlaveEndpoint; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -89,9 +80,11 @@ public synchronized void unregisterPollTask() { if (task == null) { return; } - logger.debug("Unregistering polling from ModbusManager"); - StiebelEltronHandler.this.modbusManager.unregisterRegularPoll(task); + ModbusCommunicationInterface mycomms = StiebelEltronHandler.this.comms; + if (mycomms != null) { + mycomms.unregisterRegularPoll(task); + } pollTask = null; } @@ -102,54 +95,31 @@ public synchronized void registerPollTask(int address, int length, ModbusReadFun logger.debug("Setting up regular polling"); - ModbusSlaveEndpoint myendpoint = StiebelEltronHandler.this.endpoint; + ModbusCommunicationInterface mycomms = StiebelEltronHandler.this.comms; StiebelEltronConfiguration myconfig = StiebelEltronHandler.this.config; - if (myconfig == null || myendpoint == null) { + if (myconfig == null || mycomms == null) { throw new IllegalStateException("registerPollTask called without proper configuration"); } - BasicModbusReadRequestBlueprint request = new BasicModbusReadRequestBlueprint(getSlaveId(), + ModbusReadRequestBlueprint request = new ModbusReadRequestBlueprint(getSlaveId(), readFunctionCode, address, length, myconfig.getMaxTries()); - pollTask = new BasicPollTaskImpl(myendpoint, request, new ModbusReadCallback() { - - @Override - public void onRegisters(@Nullable ModbusReadRequestBlueprint request, - @Nullable ModbusRegisterArray registers) { - if (registers == null) { - logger.warn("Received empty register array on poll"); - return; - } - handlePolledData(registers); - - if (StiebelEltronHandler.this.getThing().getStatus() != ThingStatus.ONLINE) { - updateStatus(ThingStatus.ONLINE); - } - } - - @Override - public void onError(@Nullable ModbusReadRequestBlueprint request, @Nullable Exception error) { - StiebelEltronHandler.this.handleError(error); - } - - @Override - public void onBits(@Nullable ModbusReadRequestBlueprint request, @Nullable BitArray bits) { - // don't care, we don't expect this result - } - }); long refreshMillis = myconfig.getRefreshMillis(); - PollTask task = pollTask; - if (task != null) { - StiebelEltronHandler.this.modbusManager.registerRegularPoll(task, refreshMillis, 1000); - } + pollTask = mycomms.registerRegularPoll(request, refreshMillis, 1000, result -> { + result.getRegisters().ifPresent(this::handlePolledData); + if (getThing().getStatus() != ThingStatus.ONLINE) { + updateStatus(ThingStatus.ONLINE); + } + }, failure -> {StiebelEltronHandler.this.handleReadError(failure);}); } public synchronized void poll() { PollTask task = pollTask; - if (task != null) { - StiebelEltronHandler.this.modbusManager.submitOneTimePoll(task); + ModbusCommunicationInterface mycomms = StiebelEltronHandler.this.comms; + if (task != null && mycomms != null) { + mycomms.submitOneTimePoll(task.getRequest(), task.getResultCallback(), task.getFailureCallback()); } } @@ -198,29 +168,23 @@ public synchronized void poll() { */ private volatile @Nullable AbstractBasePoller systemParameterPoller = null; /** - * This is the slave endpoint we're connecting to + * Communication interface to the slave endpoint we're connecting to */ - protected volatile @Nullable ModbusSlaveEndpoint endpoint = null; + protected volatile @Nullable ModbusCommunicationInterface comms = null; /** * This is the slave id, we store this once initialization is complete */ private volatile int slaveId; - /** - * Reference to the modbus manager - */ - protected ModbusManager modbusManager; - /** * Instances of this handler should get a reference to the modbus manager * * @param thing the thing to handle * @param modbusManager the modbus manager */ - public StiebelEltronHandler(Thing thing, ModbusManager modbusManager) { + public StiebelEltronHandler(Thing thing) { super(thing); - this.modbusManager = modbusManager; } /** @@ -229,41 +193,28 @@ public StiebelEltronHandler(Thing thing, ModbusManager modbusManager) { */ protected void writeInt16(int address, short shortValue) { StiebelEltronConfiguration myconfig = StiebelEltronHandler.this.config; - if (myconfig == null) { + ModbusCommunicationInterface mycomms = StiebelEltronHandler.this.comms; + + if (myconfig == null || mycomms == null) { throw new IllegalStateException("registerPollTask called without proper configuration"); } // big endian byte ordering byte b1 = (byte) (shortValue >> 8); byte b2 = (byte) shortValue; - ModbusRegister register = new BasicModbusRegister(b1, b2); - ModbusRegisterArray data = new BasicModbusRegisterArray(new ModbusRegister[] { register }); + ModbusRegister register = new ModbusRegister(b1, b2); + ModbusRegisterArray data = new ModbusRegisterArray(new ModbusRegister[] { register }); - BasicModbusWriteRegisterRequestBlueprint request = new BasicModbusWriteRegisterRequestBlueprint(slaveId, + ModbusWriteRegisterRequestBlueprint request = new ModbusWriteRegisterRequestBlueprint(slaveId, address, data, false, myconfig.getMaxTries()); - ModbusSlaveEndpoint slaveEndpoint = this.endpoint; - if (slaveEndpoint == null) { - return; - } - - BasicWriteTask writeTask = new BasicWriteTask(slaveEndpoint, request, new ModbusWriteCallback() { - @Override - public void onWriteResponse(ModbusWriteRequestBlueprint request, ModbusResponse response) { - if (hasConfigurationError()) { - return; - } - logger.debug("Successful write, matching request {}", request); - StiebelEltronHandler.this.updateStatus(ThingStatus.ONLINE); - } - - @Override - public void onError(ModbusWriteRequestBlueprint request, Exception error) { - StiebelEltronHandler.this.handleError(error); + mycomms.submitOneTimeWrite(request, result -> { + if (hasConfigurationError()) { + return; } - }); - logger.trace("Submitting write task: {}", writeTask); - modbusManager.submitOneTimeWrite(writeTask); + logger.debug("Successful write, matching request {}", request); + StiebelEltronHandler.this.updateStatus(ThingStatus.ONLINE); + }, failure -> {StiebelEltronHandler.this.handleWriteError(failure);}); } /** @@ -350,8 +301,16 @@ public void handleCommand(ChannelUID channelUID, Command command) { break; } } - } catch (StiebelEltronException e) { - handleError(e); + } catch (StiebelEltronException error) { + if (hasConfigurationError() || getThing().getStatus() == ThingStatus.OFFLINE) { + return; + } + String msg = ""; + String cls = ""; + cls = error.getClass().getName(); + msg = error.getMessage(); + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, + String.format("Error with: %s: %s", cls, msg)); } } } @@ -374,7 +333,7 @@ public void initialize() { */ private void startUp() { - if (endpoint != null) { + if (comms != null) { return; } @@ -387,12 +346,12 @@ private void startUp() { try { slaveId = slaveEndpointThingHandler.getSlaveId(); - endpoint = slaveEndpointThingHandler.asSlaveEndpoint(); + comms = slaveEndpointThingHandler.getCommunicationInterface(); } catch (EndpointNotInitializedException e) { // this will be handled below as endpoint remains null } - if (endpoint == null) { + if (comms == null) { @SuppressWarnings("null") String label = Optional.ofNullable(getBridge()).map(b -> b.getLabel()).orElse(""); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, @@ -401,7 +360,7 @@ private void startUp() { } if (config == null) { - logger.debug("Invalid endpoint/config/manager ref for stiebel eltron handler"); + logger.debug("Invalid comms/config/manager ref for stiebel eltron handler"); return; } @@ -492,7 +451,7 @@ private void tearDown() { systemParameterPoller = null; } - endpoint = null; + comms = null; } /** @@ -693,21 +652,32 @@ public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { /** * Handle errors received during communication */ - protected void handleError(@Nullable Exception error) { + protected void handleReadError(AsyncModbusFailure failure) { // Ignore all incoming data and errors if configuration is not correct if (hasConfigurationError() || getThing().getStatus() == ThingStatus.OFFLINE) { return; } - String msg = ""; - String cls = ""; - if (error != null) { - cls = error.getClass().getName(); - msg = error.getMessage(); - } + String msg = failure.getCause().getMessage(); + String cls = failure.getCause().getClass().getName(); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, String.format("Error with read: %s: %s", cls, msg)); } + /** + * Handle errors received during communication + */ + protected void handleWriteError(AsyncModbusFailure failure) { + // Ignore all incoming data and errors if configuration is not correct + if (hasConfigurationError() || getThing().getStatus() == ThingStatus.OFFLINE) { + return; + } + String msg = failure.getCause().getMessage(); + String cls = failure.getCause().getClass().getName(); + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, + String.format("Error with write: %s: %s", cls, msg)); + } + + /** * Returns true, if we're in a CONFIGURATION_ERROR state * From 1f48432c733a623cc420ddfbd15577a754611014 Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Mon, 13 Jul 2020 21:30:45 +0200 Subject: [PATCH 17/20] fixes Signed-off-by: Paul Frank --- .../stiebeleltron/internal/handler/StiebelEltronHandler.java | 4 ++-- .../main/resources/ESH-INF/thing/heatpump-channel-groups.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java index e2a8f5665afe8..d537bd2fa7b42 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java @@ -499,7 +499,7 @@ public int getSlaveId() { * @return the scaled value as a DecimalType */ protected State getScaled(Number value, Unit unit) { - return QuantityType.valueOf(value.doubleValue(), unit); + return QuantityType.valueOf(value.doubleValue() / 10, unit); } /** @@ -511,7 +511,7 @@ protected State getScaled(Number value, Unit unit) { */ protected State getEnergyQuantity(int high, int low) { double value = high * 1000 + low; - return new QuantityType<>(value, KILOWATT_HOUR); + return QuantityType.valueOf(value, KILOWATT_HOUR); } /** diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-groups.xml b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-groups.xml index 76f2fd8a343ad..f35627a7cfb00 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-groups.xml +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/resources/ESH-INF/thing/heatpump-channel-groups.xml @@ -48,7 +48,7 @@ - + From 73f0e28287bb28833127abf82c9e84227e058fde Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Mon, 13 Jul 2020 21:34:04 +0200 Subject: [PATCH 18/20] review findings Signed-off-by: Paul Frank --- .../internal/handler/StiebelEltronHandler.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java index d537bd2fa7b42..963c22ebf6d73 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/handler/StiebelEltronHandler.java @@ -112,7 +112,7 @@ public synchronized void registerPollTask(int address, int length, ModbusReadFun if (getThing().getStatus() != ThingStatus.ONLINE) { updateStatus(ThingStatus.ONLINE); } - }, failure -> {StiebelEltronHandler.this.handleReadError(failure);}); + }, StiebelEltronHandler.this::handleReadError); } public synchronized void poll() { @@ -305,10 +305,8 @@ public void handleCommand(ChannelUID channelUID, Command command) { if (hasConfigurationError() || getThing().getStatus() == ThingStatus.OFFLINE) { return; } - String msg = ""; - String cls = ""; - cls = error.getClass().getName(); - msg = error.getMessage(); + String cls = error.getClass().getName(); + String msg = error.getMessage(); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, String.format("Error with: %s: %s", cls, msg)); } From 875e04c66318b1bf052ea14a48ff7955f5519df9 Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Thu, 27 Aug 2020 08:18:29 +0200 Subject: [PATCH 19/20] update version Signed-off-by: Paul Frank --- bundles/org.openhab.binding.modbus.stiebeleltron/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/pom.xml b/bundles/org.openhab.binding.modbus.stiebeleltron/pom.xml index 6a8b234f9c087..4a1805500df35 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/pom.xml +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/pom.xml @@ -7,7 +7,7 @@ org.openhab.addons.bundles org.openhab.addons.reactor.bundles - 2.5.7-SNAPSHOT + 2.5.9-SNAPSHOT org.openhab.binding.modbus.stiebeleltron From c078020df7aa2085c432ffdfe007747c32389c66 Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Thu, 27 Aug 2020 08:30:00 +0200 Subject: [PATCH 20/20] updated documentation Signed-off-by: Paul Frank --- bundles/org.openhab.binding.modbus.stiebeleltron/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/README.md b/bundles/org.openhab.binding.modbus.stiebeleltron/README.md index 2f39f07df6f36..c58a896c18640 100644 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/README.md +++ b/bundles/org.openhab.binding.modbus.stiebeleltron/README.md @@ -2,7 +2,8 @@ This extension adds support for the Stiebel Eltron modbus protocol. -An Internet Service Gateway (ISG) with an installed modbus extension is required in order to run this binding. In case the modbus extension is not yet installed on the ISG, the ISG Updater Tool for the update can be found here: https://www.stiebel-eltron.de/de/home/produkte-loesungen/erneuerbare_energien/regelung_energiemanagement/internet_servicegateway/isg_web/downloads.html +An Internet Service Gateway (ISG) with an installed modbus extension is required in order to run this binding. +In case the modbus extension is not yet installed on the ISG, the ISG Updater Tool for the update can be found here: https://www.stiebel-eltron.de/de/home/produkte-loesungen/erneuerbare_energien/regelung_energiemanagement/internet_servicegateway/isg_web/downloads.html