From c19e6ddf1995f67aabf2cc1b627d46d8e8ae2ff3 Mon Sep 17 00:00:00 2001 From: Christian Koch Date: Sat, 16 Nov 2024 16:02:22 +0100 Subject: [PATCH] New version using seperate things for parts of the Lambda Heat Pump System, enables more than one heat pump, boiler, buffer, heating cirucuit. Signed-off-by: Christian Koch Beschreibung in: file:///D:/Prog/Git/mingw64/share/doc/git-doc/git-commit.html --- .gitignore | 7 + .../internal/LambdaBindingConstants.java | 20 +- .../resources/OH-INF/i18n/lambda.properties | 12 +- .../thing/boiler-channel-group-types.xml | 2 +- .../thing/general-channel-types copy.xml | 92 --- .../OH-INF/thing/general-thing-types.xml | 4 +- .../thing/heating-channel-group-types.xml | 2 +- .../OH-INF/thing/heating-thing-types.xml | 2 +- .../thing/heatpump-channel-group-types.xml | 2 +- .../OH-INF/thing/heatpump-thing-types..xml | 2 +- .../NOTICE | 13 - .../README.md | 174 ----- .../pom.xml | 25 - .../LambdaGeneralBindingConstants.java | 52 -- .../internal/LambdaGeneralConfiguration.java | 47 -- .../internal/LambdaGeneralHandlerFactory.java | 57 -- .../internal/dto/AmbientBlock.java | 28 - .../internal/dto/EManagerBlock.java | 28 - .../handler/LambdaGeneralException.java | 33 - .../handler/LambdaGeneralHandler.java | 623 ----------------- .../internal/parser/AbstractBaseParser.java | 128 ---- .../internal/parser/AmbientBlockParser.java | 38 - .../internal/parser/EManagerBlockParser.java | 39 -- .../OH-INF/config/config-descriptions.xml | 25 - .../OH-INF/i18n/lambda-general.properties | 32 - .../thing/lambda-general-channel-groups.xml | 29 - .../thing/lambda-general-channel-types.xml | 91 --- .../OH-INF/thing/lambda-general-types.xml | 23 - .../org.openhab.binding.modbus.lambda/NOTICE | 13 - .../README.md | 189 ----- .../org.openhab.binding.modbus.lambda/pom.xml | 25 - .../lambda/internal/BoilerConfiguration.java | 62 -- .../lambda/internal/BufferConfiguration.java | 61 -- .../lambda/internal/GeneralConfiguration.java | 47 -- .../internal/HeatingCircuitConfiguration.java | 61 -- .../internal/HeatpumpConfiguration.java | 63 -- .../internal/LambdaBindingConstants.java | 115 --- .../lambda/internal/LambdaHandlerFactory.java | 85 --- .../lambda/internal/dto/AmbientBlock.java | 28 - .../lambda/internal/dto/BoilerBlock.java | 27 - .../lambda/internal/dto/BoilerReg50Block.java | 25 - .../lambda/internal/dto/BufferBlock.java | 27 - .../lambda/internal/dto/BufferReg50Block.java | 25 - .../lambda/internal/dto/EManagerBlock.java | 28 - .../internal/dto/HeatingCircuitBlock.java | 31 - .../dto/HeatingCircuitReg50Block.java | 27 - .../lambda/internal/dto/HeatpumpBlock.java | 39 -- .../internal/dto/HeatpumpReg50Block.java | 25 - .../internal/handler/BoilerHandler.java | 575 --------------- .../internal/handler/BufferHandler.java | 541 --------------- .../internal/handler/GeneralHandler.java | 568 --------------- .../handler/HeatingCircuitHandler.java | 652 ------------------ .../internal/handler/HeatpumpHandler.java | 596 ---------------- .../internal/handler/LambdaException.java | 33 - .../internal/parser/AbstractBaseParser.java | 128 ---- .../internal/parser/AmbientBlockParser.java | 38 - .../internal/parser/BoilerBlockParser.java | 37 - .../parser/BoilerReg50BlockParser.java | 34 - .../internal/parser/BufferBlockParser.java | 37 - .../parser/BufferReg50BlockParser.java | 34 - .../internal/parser/EManagerBlockParser.java | 39 -- 61 files changed, 30 insertions(+), 5915 deletions(-) delete mode 100644 bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/general-channel-types copy.xml delete mode 100644 bundles/org.openhab.binding.modbus.lambdageneral/NOTICE delete mode 100644 bundles/org.openhab.binding.modbus.lambdageneral/README.md delete mode 100644 bundles/org.openhab.binding.modbus.lambdageneral/pom.xml delete mode 100644 bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/LambdaGeneralBindingConstants.java delete mode 100644 bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/LambdaGeneralConfiguration.java delete mode 100644 bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/LambdaGeneralHandlerFactory.java delete mode 100644 bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/dto/AmbientBlock.java delete mode 100644 bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/dto/EManagerBlock.java delete mode 100644 bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/handler/LambdaGeneralException.java delete mode 100644 bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/handler/LambdaGeneralHandler.java delete mode 100644 bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/parser/AbstractBaseParser.java delete mode 100644 bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/parser/AmbientBlockParser.java delete mode 100644 bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/parser/EManagerBlockParser.java delete mode 100644 bundles/org.openhab.binding.modbus.lambdageneral/src/main/resources/OH-INF/config/config-descriptions.xml delete mode 100644 bundles/org.openhab.binding.modbus.lambdageneral/src/main/resources/OH-INF/i18n/lambda-general.properties delete mode 100644 bundles/org.openhab.binding.modbus.lambdageneral/src/main/resources/OH-INF/thing/lambda-general-channel-groups.xml delete mode 100644 bundles/org.openhab.binding.modbus.lambdageneral/src/main/resources/OH-INF/thing/lambda-general-channel-types.xml delete mode 100644 bundles/org.openhab.binding.modbus.lambdageneral/src/main/resources/OH-INF/thing/lambda-general-types.xml delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/NOTICE delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/README.md delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/pom.xml delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/BoilerConfiguration.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/BufferConfiguration.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/GeneralConfiguration.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/HeatingCircuitConfiguration.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/HeatpumpConfiguration.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/LambdaBindingConstants.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/LambdaHandlerFactory.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/AmbientBlock.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/BoilerBlock.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/BoilerReg50Block.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/BufferBlock.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/BufferReg50Block.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/EManagerBlock.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/HeatingCircuitBlock.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/HeatingCircuitReg50Block.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/HeatpumpBlock.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/HeatpumpReg50Block.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/BoilerHandler.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/BufferHandler.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/GeneralHandler.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/HeatingCircuitHandler.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/HeatpumpHandler.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/LambdaException.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/AbstractBaseParser.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/AmbientBlockParser.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/BoilerBlockParser.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/BoilerReg50BlockParser.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/BufferBlockParser.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/BufferReg50BlockParser.java delete mode 100644 bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/EManagerBlockParser.java diff --git a/.gitignore b/.gitignore index 93f8fcbb6200b..753247525ccf4 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,10 @@ pom.xml.versionsBackup .vim shell.nix tags +bundles/org.openhab.binding.modbus.stiebeleltron_mist/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/HeatingCircuitReg50Block.java +bundles/org.openhab.binding.modbus.stiebeleltron_mist/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/HeatingCircuitHandler.java +bundles/org.openhab.binding.modbus.stiebeleltron_mist/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/BoilerReg50BlockParser.java +bundles/org.openhab.binding.modbus.stiebeleltron_mist/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/BufferReg50BlockParser.java +bundles/org.openhab.binding.modbus.stiebeleltron_mist/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/HeatingCircuitBlockParser.java +bundles/org.openhab.binding.modbus.stiebeleltron_mist/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/HeatingCircuitReg50BlockParser.java +bundles/org.openhab.binding.modbus.stiebeleltron_mist/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/HeatpumpReg50BlockParser.java diff --git a/bundles/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/LambdaBindingConstants.java b/bundles/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/LambdaBindingConstants.java index 873f22bda05c9..2d54c02792951 100644 --- a/bundles/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/LambdaBindingConstants.java +++ b/bundles/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/LambdaBindingConstants.java @@ -41,16 +41,16 @@ public class LambdaBindingConstants { public static final ThingTypeUID THING_TYPE_LAMBDAHEATING = new ThingTypeUID(BINDING_ID, LAMBDAHEATING); // Channel group ids - public static final String GROUP_GENERAL_AMBIENT = "Ambient"; - public static final String GROUP_GENERAL_EMANAGER = "EManager"; - public static final String GROUP_HEATPUMP = "Heatpump"; - public static final String GROUP_HEATPUMP_REG50 = "Heatpump-reg50"; - public static final String GROUP_BOILER = "Boiler"; - public static final String GROUP_BOILER_REG50 = "Boiler-reg50"; - public static final String GROUP_BUFFER = "Buffer"; - public static final String GROUP_BUFFER_REG50 = "Buffer-reg50"; - public static final String GROUP_HEATINGCIRCUIT = "Heatingcircuit"; - public static final String GROUP_HEATINGCIRCUIT_REG50 = "Heatingcircuit-reg50"; + public static final String GROUP_GENERAL_AMBIENT = "ambient-group"; + public static final String GROUP_GENERAL_EMANAGER = "emanager-group"; + public static final String GROUP_HEATPUMP = "heatpump-group"; + public static final String GROUP_HEATPUMP_REG50 = "heatpump-reg50-group"; + public static final String GROUP_BOILER = "boiler-group"; + public static final String GROUP_BOILER_REG50 = "boiler-reg50-group"; + public static final String GROUP_BUFFER = "buffer-group"; + public static final String GROUP_BUFFER_REG50 = "buffer-reg50-group"; + public static final String GROUP_HEATINGCIRCUIT = "heating-group"; + public static final String GROUP_HEATINGCIRCUIT_REG50 = "heating-reg50-group"; // List of all Channel ids in device information group // General Ambient diff --git a/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/i18n/lambda.properties b/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/i18n/lambda.properties index bd793b40e9866..0accbcf708585 100644 --- a/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/i18n/lambda.properties +++ b/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/i18n/lambda.properties @@ -40,12 +40,12 @@ thing-type.config.lambda-heatingcircuit.modbusconfig.refresh.description = Refre # channel group types -channel-group-type.modbus.ambient.label = General Ambient Group -channel-group-type.modbus.emanager.label = General E-Manager Group -channel-group-type.modbus.heatpump.label = Heatpump Group -channel-group-type.modbus.boiler.label = Boiler Group -channel-group-type.modbus.buffer.label = Buffer Group -channel-group-type.modbus.heatingcircuit.label = Heating Circuit Group +channel-group-type.modbus.ambient-type.label = General Ambient Group +channel-group-type.modbus.emanager-type.label = General E-Manager Group +channel-group-type.modbus.heatpump-type.label = Heatpump Group +channel-group-type.modbus.boiler-type.label = Boiler Group +channel-group-type.modbus.buffer-type.label = Buffer Group +channel-group-type.modbus.heatingcircuit-type.label = Heating Circuit Group # channel types diff --git a/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/boiler-channel-group-types.xml b/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/boiler-channel-group-types.xml index 09ef285ce3e91..4378677653966 100644 --- a/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/boiler-channel-group-types.xml +++ b/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/boiler-channel-group-types.xml @@ -4,7 +4,7 @@ xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0" xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd"> - + diff --git a/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/general-channel-types copy.xml b/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/general-channel-types copy.xml deleted file mode 100644 index e98d5dd9da804..0000000000000 --- a/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/general-channel-types copy.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - Number - - - - - - - - - - Number - - - - - - - - - - - - - Number:Temperature - - - - - - - Number:Temperature - - - - - - Number:Temperature - - - - - - Number - - - - - - - - - - Number - - - - - - - - - - - - - - Number:Power - - - - - - Number:Power - - - - - - Number:Power - - - - - - diff --git a/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/general-thing-types.xml b/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/general-thing-types.xml index eb08b43c47482..c400e8614d959 100644 --- a/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/general-thing-types.xml +++ b/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/general-thing-types.xml @@ -13,8 +13,8 @@ - - + + diff --git a/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/heating-channel-group-types.xml b/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/heating-channel-group-types.xml index 7218a67b9aa2d..676596ec38117 100644 --- a/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/heating-channel-group-types.xml +++ b/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/heating-channel-group-types.xml @@ -4,7 +4,7 @@ xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0" xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd"> - + diff --git a/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/heating-thing-types.xml b/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/heating-thing-types.xml index e21d115620185..9f7af873a7c60 100644 --- a/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/heating-thing-types.xml +++ b/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/heating-thing-types.xml @@ -13,7 +13,7 @@ - + diff --git a/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/heatpump-channel-group-types.xml b/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/heatpump-channel-group-types.xml index f38729fccc0b2..24731c612c735 100644 --- a/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/heatpump-channel-group-types.xml +++ b/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/heatpump-channel-group-types.xml @@ -4,7 +4,7 @@ xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0" xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd"> - + diff --git a/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/heatpump-thing-types..xml b/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/heatpump-thing-types..xml index aa358a628310f..2c088ff1c4a16 100644 --- a/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/heatpump-thing-types..xml +++ b/bundles/org.openhab.binding.modbus.lambda/src/main/resources/OH-INF/thing/heatpump-thing-types..xml @@ -13,7 +13,7 @@ - + diff --git a/bundles/org.openhab.binding.modbus.lambdageneral/NOTICE b/bundles/org.openhab.binding.modbus.lambdageneral/NOTICE deleted file mode 100644 index 38d625e349232..0000000000000 --- a/bundles/org.openhab.binding.modbus.lambdageneral/NOTICE +++ /dev/null @@ -1,13 +0,0 @@ -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.lambdageneral/README.md b/bundles/org.openhab.binding.modbus.lambdageneral/README.md deleted file mode 100644 index 0e4671e855052..0000000000000 --- a/bundles/org.openhab.binding.modbus.lambdageneral/README.md +++ /dev/null @@ -1,174 +0,0 @@ -# Lambda Heat Pump - -This extension adds support for the Lambda Heat Pump modbus protocol as provided by -https://lambda-wp.at/wp-content/uploads/2022/01/Modbus-Protokoll-und-Beschreibung.pdf - -A Lambda Heat Pump has to be reachable within your network. -If you plan to use the E-Manager part to hand over your PV excess to the heat pump ask Lambda support to -configure it to -E-Meter Kommunikationsart: ModBus Client -E-Meter Messpunkt: E-Eintrag - -Other configurations of the E-Manager are not supported (yet). - -Up to now only the following configuration is supported: -- only one heatpump(heatpump1) -- only one buffer for the heating (buffer1) -- only one buffer for the water heating (boiler1) - - -## 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 | ThingTypeID | Description | -| ------------------ | --------------------| --------------------------------------------------- | -| Lambda Heat Pump | lambda-heatpump | A lambda heat pump visible in the local network | - -## Discovery - -This extension does not support autodiscovery. The things need to be added manually. - -A typical bridge configuration would look like this: - -```java -Bridge modbus:tcp:bridge [ host="10.0.0.2", port=502, id=1 ] -``` - -## Thing Configuration - -You first need to set up a TCP Modbus bridge according to the Modbus documentation. -You then add the lambda heat pump as part of the modbus binding. -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 | 30 | 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. - -### General Ambient Group - -This group contains general operational information about the heat pump. - - -| Channel ID | Item Type | Read only | Unit | Description | -| -------------------------------- | ------------------ | --------- | -------- | ------------------------------------------------------------------------ | -| ambient-error-number | Number | true | [Nr] | Ambient Error Number (0 = No error) | -| ambient-operating-state | Number | true | [Nr] | Ambient Operating State (0 = OFF, 1 = AUTOMATIC, 2 = MANUAL, 3 = ERROR) | -| actual-ambient-temperature | Number:Temperature | false | [0.1 °C] | Actual Ambient Temperature (min = -50.0°C); max = 80.0° | -| average-ambient-temperature | Number:Temperature | true | [0.1 °C] | Arithmetic average temperature of the last 60 minutes | -| calculated-ambient-temperature | Number:Temperature | true | [0.1 °C] | Temperature for calculations in heat distribution modules | - -### General E-Manager Group - -This group contains parameters signaling the PV excess to the heat pump. - -| Channel ID | Item Type | Read only | Unit | Description | -| -------------------------------- | ------------------ | --------- | -------- | --------------------------------------------------------------------------------------- | -| emanager-error-number | Number | true | [Nr] | E-Manager Error Number (0 = No error) | -| emanager-operating-state | Number | true | [Nr] | E-Manager Operating State (0 = OFF, 1 = AUTOMATIC, 2 = MANUAL, 3 = ERROR 4 = OFFLINE | -| actual-power | Number:Power | false | [W] | Actual excess power -32768 W .. 32767 W | -| actual-power-consumption | Number:Power | true | [W] | Power consumption of heatpump 1 (only valid when Betriebsart: Automatik, 0 W otherwise) | -| power-consumption-setpoint | Number:Power | false | [W] | Power consumption setpoint for heat pump 1 | - - -### Heat Pump 1 Group - -This group contains general operational information about the heat pump itself. - -| Channel ID | Item Type | Read only | Unit | Description | -| -------------------------------| ------------------------- | --------- | ------------ | ----------------------------------------------------------------------- | -| heatpump1-error-state | Number | true | [Nr] | Error state (0 = NONE, 1 = MESSAGE, 2 = WARNING, 3 = ALARM, 4 = FAULT )| -| heatpump1-error-number | Number | true | [Nr] | Error number: scrolling through all active error number (1..99) | -| heatpump1-state | Number | true | [Nr] | State: See Modbus description manual of the manufacterer | -| heatpump1-operating-state | Number | true | [Nr] | Operating State: See Modbus description manual, link above | -| heatpump1-t-flow | Number:Temperature | true | [0.01°C] | Flow line termperature | -| heatpump1-t-return | Number:Temperature | true | [0.01°C] | Return line temperature | -| heatpump1-vol-sink | Number:VolumetricFlowRate | true | [0.01 l/min] | Volume flow heat sink | -| heatpump1-t-eqin | Number:Temperature | true | [0.01°C] | Energy source inlet temperature | -| heatpump1-t-eqout | Number:Temperature | true | [0.01°C] | Energy source outlet temperature | -| heatpump1-vol-source | Number:VolumetricFlowRate | true | [0.01 l/min] | Volume flow energy source | -| heatpump1-compressor-rating | Number | true | [0.01%] | Compressor unit rating | -| heatpump1-qp-heating | Number:Power | true | [0.1kW] | Actual heating capacity | -| heatpump1-fi-power-consumption | Number:Power | true | [W] | Frequency inverter actual power consumption | -| heatpump1-cop | Number | true | [0.01%] | Coefficient of performance | -| heatpump1-set-error-quit | Number | false | [Nr] | Set Error Quit (1 = Quit all active heat pump errors | - - -### Boiler 1 Group - -This group contains information about the boiler for the water for domestic use / tap water / washwater. - -| Channel ID | Item Type | Read only | Unit | Description | -| ---------------------------------- | ------------------ | --------- | -------- | --------------------------------------------------------------------| -| boiler1-error-number | Number | true | [Nr] | Boiler 1 Error Number(0 = No error) | -| boiler1-operating-state | Number | true | [Nr] | Boiler 1 Operating State: See Modbus description manual, link above | -| boiler1-actual-high-temperature | Number:Temperature | true | [0.1 °C] | Actual temperature boiler high sensor | -| boiler1-actual-low-temperature | Number:Temperature | true | [0.1 °C] | Actual temperature boiler low sensor | -| boiler1-maximum-boiler-temperature | Number:Temperature | false | [0.1 °C] | Setting for maximum boiler temperature (min = 25.0°C; max = 65.0°C) | - -### Buffer 1 Group - -This group contains information about the buffer for the heating circuit. - -| Channel ID | Item Type | Read only | Unit | Description | -| --------------------------------------- | ------------------ | --------- | -------- | -----------------------------------------------------------------------| -| buffer1-error-number | Number | true | [Nr] | Buffer 1 Error Number (0 = No error) | -| buffer1-operating-state | Number | true | [Nr] | Buffer 1 Operating State: See Modbus description manual, link above | -| buffer1-actual-high-temperature | Number:Temperature | true | [0.1 °C] | Actual temperature buffer high sensor | -| buffer1-actual-low-temperature | Number:Temperature | true | [0.1 °C] | Actual temperature buffer low sensor | -| buffer1-maximum-buffer-temperature | Number:Temperature | false | [0.1 °C] | Setting for maximum buffer temperature (min = 25.0°C; max = 65.0°C) | - - -### Heating Circuit 1 Group - -This group contains general operational information about the heating circuit 1. - -| Channel ID | Item Type | Read only | Unit | Description | -| ---------------------------------------------- | -------------------| --------- | ------------ | --------------------------------------------------------------------------------| -| heatingcircuit1-error-number | Number | true | [Nr] | Error Number (0 = No error) | -| heatingcircuit1-operating-state | Number | true | [Nr] | Operating State: See Modbus description manual, link above| | -| heatingcircuit1-flow-line-temperature | Number:Temperature | true | [Nr] | Actual temperature flow line sensor | -| heatingcircuit1-return-line-temperature | Number:Temperature | true | [Nr] | Actual temperature return line sensor | -| heatingcircuit1-room-device-temperature | Number:Temperature | true | [0.01°C] | Actual temperature room device sensor (min = -29.9°C; max = 99.9°C) | -| heatingcircuit1-setpoint-flow-line-temperature | Number:Temperature | true | [0.01°C] | Setpoint temperature flow line (min = 15.0°C; max = 65.0°C) | -| heatingcircuit1-operating-mode | Number | true | [Nr] | Operating Mode: See Modbus description manual, link above | -| heatingcircuit1-offset-flow-line-temperature | Number:Temperature | true | [0.01°C] | Setting for flow line temperature setpoint offset(min = -10.0K; max = 10.0K) | -| heatingcircuit1-room-heating-temperature | Number:Temperature | rue | [0.01°C] | Setting for heating mode room setpoint temperature(min = 15.0°C; max = 40.0 °C) | -| heatingcircuit1-room-cooling-temperature | Number:Temperature | true | [0.01 l/min] | Setting for cooling mode room setpoint temperature(min = 15.0°C; max = 40.0 °C) | - - - -## Full Example - -### Thing Configuration of Modbus Bridge -UID: modbus:tcp:Lambda_Bridge -label: Lambda Modbus Bridge -thingTypeUID: modbus:tcp -configuration: - rtuEncoded: false - connectMaxTries: 1 - reconnectAfterMillis: 0 - timeBetweenTransactionsMillis: 100 - port: 502 - timeBetweenReconnectMillis: 0 - connectTimeoutMillis: 10000 - host: 192.168.223.83 - afterConnectionDelayMillis: 0 - id: 1 - enableDiscovery: false - -### Example: Write PV excess to the Lambda Heat Pump -// PV_Battery.state and PV_Grid have to be provided by your PV inverter -// Mode of E-Manager has to be switched to AUTOMATIK in the Lambda Heat Pump App -var int P_Available = ((Lambda_EMgr_Power_Consumption_Value_as_Number.state as Number) - (PW_Battery.state as Number) - (PW_Grid.state as Number)).intValue - lambdahp_actual_power.sendCommand(P_Available) - - diff --git a/bundles/org.openhab.binding.modbus.lambdageneral/pom.xml b/bundles/org.openhab.binding.modbus.lambdageneral/pom.xml deleted file mode 100644 index 88a4c741bc256..0000000000000 --- a/bundles/org.openhab.binding.modbus.lambdageneral/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - 4.0.0 - - org.openhab.addons.bundles - org.openhab.addons.reactor.bundles - 4.3.0-SNAPSHOT - - - org.openhab.binding.modbus.lambdageneral - - openHAB Add-ons :: Bundles :: Lambda General Section Bundle - - - - org.openhab.addons.bundles - org.openhab.binding.modbus - ${project.version} - provided - - - - diff --git a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/LambdaGeneralBindingConstants.java b/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/LambdaGeneralBindingConstants.java deleted file mode 100644 index 41f67d7b07c7a..0000000000000 --- a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/LambdaGeneralBindingConstants.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambdageneral.internal; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.binding.modbus.ModbusBindingConstants; -import org.openhab.core.thing.ThingTypeUID; - -/** - * The {@link LambdaGeneralBindingConstants} class defines common - * constants, which are used across the whole binding. - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - */ -@NonNullByDefault -public class LambdaGeneralBindingConstants { - - private static final String BINDING_ID = ModbusBindingConstants.BINDING_ID; - - // List of all Thing Type UIDs - public static final ThingTypeUID THING_TYPE_LAMBDA_GENERAL = new ThingTypeUID(BINDING_ID, "lambdageneral"); - - // Channel group ids - public static final String GROUP_GENERAL_AMBIENT = "generalAmbient"; - public static final String GROUP_GENERAL_EMANAGER = "generalEManager"; - - // List of all Channel ids in device information group - // General Ambient - public static final String CHANNEL_AMBIENT_ERROR_NUMBER = "ambient-error-number"; - public static final String CHANNEL_AMBIENT_OPERATING_STATE = "ambient-operating-state"; - public static final String CHANNEL_ACTUAL_AMBIENT_TEMPERATURE = "actual-ambient-temperature"; - public static final String CHANNEL_AVERAGE_AMBIENT_TEMPERATURE = "average-ambient-temperature"; - public static final String CHANNEL_CALCULATED_AMBIENT_TEMPERATURE = "calculated-ambient-temperature"; - - // General E-manager - public static final String CHANNEL_EMANAGER_ERROR_NUMBER = "emanager-error-number"; - public static final String CHANNEL_EMANAGER_OPERATING_STATE = "emanager-operating-state"; - public static final String CHANNEL_ACTUAL_POWER = "actual-power"; - public static final String CHANNEL_ACTUAL_POWER_CONSUMPTION = "actual-power-consumption"; - public static final String CHANNEL_POWER_CONSUMPTION_SETPOINT = "power-consumption-setpoint"; -} diff --git a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/LambdaGeneralConfiguration.java b/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/LambdaGeneralConfiguration.java deleted file mode 100644 index a76202e05f8b0..0000000000000 --- a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/LambdaGeneralConfiguration.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambdageneral.internal; - -import org.eclipse.jdt.annotation.NonNullByDefault; - -/** - * The {@link LambdaGeneralConfiguration} class contains fields mapping - * thing configuration parameters. - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - */ -@NonNullByDefault -public class LambdaGeneralConfiguration { - /** - * Refresh interval in seconds - */ - private int refresh = 30; - - 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.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/LambdaGeneralHandlerFactory.java b/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/LambdaGeneralHandlerFactory.java deleted file mode 100644 index 05dd100174f91..0000000000000 --- a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/LambdaGeneralHandlerFactory.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambdageneral.internal; - -import static org.openhab.binding.modbus.lambdageneral.internal.LambdaGeneralBindingConstants.THING_TYPE_LAMBDA_GENERAL; - -import java.util.Set; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.eclipse.jdt.annotation.Nullable; -import org.openhab.binding.modbus.lambdageneral.internal.handler.LambdaGeneralHandler; -import org.openhab.core.thing.Thing; -import org.openhab.core.thing.ThingTypeUID; -import org.openhab.core.thing.binding.BaseThingHandlerFactory; -import org.openhab.core.thing.binding.ThingHandler; -import org.openhab.core.thing.binding.ThingHandlerFactory; -import org.osgi.service.component.annotations.Component; - -/** - * The {@link LambdaGeneralHandlerFactory} is responsible for creating things and thing - * handlers. - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - */ -@NonNullByDefault -@Component(configurationPid = "binding.lambdageneral", service = ThingHandlerFactory.class) -public class LambdaGeneralHandlerFactory extends BaseThingHandlerFactory { - - private static final Set SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_LAMBDA_GENERAL); - - @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_LAMBDA_GENERAL.equals(thingTypeUID)) { - return new LambdaGeneralHandler(thing); - } - - return null; - } -} diff --git a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/dto/AmbientBlock.java b/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/dto/AmbientBlock.java deleted file mode 100644 index 9bc1510a1973f..0000000000000 --- a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/dto/AmbientBlock.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambdageneral.internal.dto; - -/** - * Dto class for the Ambient Block - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - * - */ -public class AmbientBlock { - public int ambientErrorNumber; - public int ambientOperatingState; - public int actualAmbientTemperature; - public int averageAmbientTemperature; - public int calculatedAmbientTemperature; -} diff --git a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/dto/EManagerBlock.java b/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/dto/EManagerBlock.java deleted file mode 100644 index 366360099fa4d..0000000000000 --- a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/dto/EManagerBlock.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambdageneral.internal.dto; - -/** - * Dto class for the EManager Block - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - * - */ -public class EManagerBlock { - public int emanagerErrorNumber; - public int emanagerOperatingState; - public int actualPower; - public int actualPowerConsumption; - public int powerConsumptionSetpoint; -} diff --git a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/handler/LambdaGeneralException.java b/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/handler/LambdaGeneralException.java deleted file mode 100644 index 07983743faaaf..0000000000000 --- a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/handler/LambdaGeneralException.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambdageneral.internal.handler; - -import org.eclipse.jdt.annotation.NonNullByDefault; - -/** - * Thrown when the lambda handler sees an error. - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - */ -@SuppressWarnings("serial") -@NonNullByDefault -public class LambdaGeneralException extends Exception { - - public LambdaGeneralException() { - } - - public LambdaGeneralException(String message) { - super(message); - } -} diff --git a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/handler/LambdaGeneralHandler.java b/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/handler/LambdaGeneralHandler.java deleted file mode 100644 index 66bbf838870ac..0000000000000 --- a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/handler/LambdaGeneralHandler.java +++ /dev/null @@ -1,623 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambdageneral.internal.handler; - -import static org.openhab.binding.modbus.lambdageneral.internal.LambdaGeneralBindingConstants.*; -import static org.openhab.core.library.unit.SIUnits.CELSIUS; -import static org.openhab.core.library.unit.Units.*; - -import java.util.Optional; - -import javax.measure.Unit; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.eclipse.jdt.annotation.Nullable; -import org.openhab.binding.modbus.handler.EndpointNotInitializedException; -import org.openhab.binding.modbus.handler.ModbusEndpointThingHandler; -import org.openhab.binding.modbus.lambdageneral.internal.LambdaGeneralConfiguration; -import org.openhab.binding.modbus.lambdageneral.internal.dto.AmbientBlock; -import org.openhab.binding.modbus.lambdageneral.internal.dto.EManagerBlock; -import org.openhab.binding.modbus.lambdageneral.internal.parser.AmbientBlockParser; -import org.openhab.binding.modbus.lambdageneral.internal.parser.EManagerBlockParser; -import org.openhab.core.io.transport.modbus.AsyncModbusFailure; -import org.openhab.core.io.transport.modbus.ModbusCommunicationInterface; -import org.openhab.core.io.transport.modbus.ModbusReadFunctionCode; -import org.openhab.core.io.transport.modbus.ModbusReadRequestBlueprint; -import org.openhab.core.io.transport.modbus.ModbusRegisterArray; -import org.openhab.core.io.transport.modbus.ModbusWriteRegisterRequestBlueprint; -import org.openhab.core.io.transport.modbus.ModbusWriteRequestBlueprint; -import org.openhab.core.io.transport.modbus.PollTask; -import org.openhab.core.library.types.DecimalType; -import org.openhab.core.library.types.QuantityType; -import org.openhab.core.thing.Bridge; -import org.openhab.core.thing.ChannelUID; -import org.openhab.core.thing.Thing; -import org.openhab.core.thing.ThingStatus; -import org.openhab.core.thing.ThingStatusDetail; -import org.openhab.core.thing.ThingStatusInfo; -import org.openhab.core.thing.binding.BaseThingHandler; -import org.openhab.core.thing.binding.ThingHandler; -import org.openhab.core.types.Command; -import org.openhab.core.types.RefreshType; -import org.openhab.core.types.State; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The {@link LambdaGeneralHandler} 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 LambdaGeneralHandler extends BaseThingHandler { - - public abstract class AbstractBasePoller { - - private final Logger logger = LoggerFactory.getLogger(LambdaGeneralHandler.class); - - private volatile @Nullable PollTask pollTask; - - public synchronized void unregisterPollTask() { - PollTask task = pollTask; - if (task == null) { - return; - } - - ModbusCommunicationInterface mycomms = LambdaGeneralHandler.this.comms; - if (mycomms != null) { - mycomms.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"); - - ModbusCommunicationInterface mycomms = LambdaGeneralHandler.this.comms; - LambdaGeneralConfiguration myconfig = LambdaGeneralHandler.this.config; - if (myconfig == null || mycomms == null) { - throw new IllegalStateException("registerPollTask called without proper configuration"); - } - - ModbusReadRequestBlueprint request = new ModbusReadRequestBlueprint(getSlaveId(), readFunctionCode, address, - length, myconfig.getMaxTries()); - - long refreshMillis = myconfig.getRefreshMillis(); - - pollTask = mycomms.registerRegularPoll(request, refreshMillis, 1000, result -> { - result.getRegisters().ifPresent(this::handlePolledData); - if (getThing().getStatus() != ThingStatus.ONLINE) { - updateStatus(ThingStatus.ONLINE); - } - }, LambdaGeneralHandler.this::handleReadError); - } - - public synchronized void poll() { - PollTask task = pollTask; - ModbusCommunicationInterface mycomms = LambdaGeneralHandler.this.comms; - if (task != null && mycomms != null) { - mycomms.submitOneTimePoll(task.getRequest(), task.getResultCallback(), task.getFailureCallback()); - } - } - - protected abstract void handlePolledData(ModbusRegisterArray registers); - } - - /** - * Logger instance - */ - private final Logger logger = LoggerFactory.getLogger(LambdaGeneralHandler.class); - - /** - * Configuration instance - */ - protected @Nullable LambdaGeneralConfiguration config = null; - /** - * Parser used to convert incoming raw messages into system blocks - * private final SystemInfromationBlockParser systemInformationBlockParser = new SystemInfromationBlockParser(); - */ - /** - * Parsers used to convert incoming raw messages into state blocks - */ - private final AmbientBlockParser ambientBlockParser = new AmbientBlockParser(); - private final EManagerBlockParser emanagerBlockParser = new EManagerBlockParser(); - - /** - * These are the tasks used to poll the device - */ - private volatile @Nullable AbstractBasePoller ambientPoller = null; - private volatile @Nullable AbstractBasePoller emanagerPoller = null; - - /** - * Communication interface to the slave endpoint we're connecting to - */ - protected volatile @Nullable ModbusCommunicationInterface comms = null; - /** - * This is the slave id, we store this once initialization is complete - */ - private volatile int slaveId; - - /** - * Instances of this handler should get a reference to the modbus manager - * - * @param thing the thing to handle - */ - public LambdaGeneralHandler(Thing thing) { - super(thing); - } - - /** - * @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) { - // loggertrace("187 writeInt16: Es wird geschrieben, Adresse: {} Wert: {}", address, shortValue); - LambdaGeneralConfiguration myconfig = LambdaGeneralHandler.this.config; - ModbusCommunicationInterface mycomms = LambdaGeneralHandler.this.comms; - - if (myconfig == null || mycomms == null) { - throw new IllegalStateException("registerPollTask called without proper configuration"); - } - // big endian byte ordering - byte hi = (byte) (shortValue >> 8); - byte lo = (byte) shortValue; - ModbusRegisterArray data = new ModbusRegisterArray(hi, lo); - - // loggertrace("199 hi: {}, lo: {}", hi, lo); - ModbusWriteRegisterRequestBlueprint request = new ModbusWriteRegisterRequestBlueprint(slaveId, address, data, - true, myconfig.getMaxTries()); - - mycomms.submitOneTimeWrite(request, result -> { - if (hasConfigurationError()) { - return; - } - // loggertrace("Successful write, matching request {}", request); - LambdaGeneralHandler.this.updateStatus(ThingStatus.ONLINE); - }, failure -> { - LambdaGeneralHandler.this.handleWriteError(failure); - // loggertrace("Unsuccessful write, matching request {}", request); - }); - } - - /** - * @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 getScaled10Int16Value(Command command) throws LambdaException { - * if (command instanceof QuantityType quantityCommand) { - * QuantityType c = quantityCommand.toUnit(CELSIUS); - * if (c != null) { - * return (short) (c.doubleValue() * 10); - * } else { - * throw new LambdaException("Unsupported unit"); - * } - * } - * if (command instanceof DecimalType c) { - * return (short) (c.doubleValue() * 10); - * } - * throw new LambdaException("Unsupported command type"); - * } - * - * private short getScaled100Int16Value(Command command) throws LambdaException { - * if (command instanceof QuantityType quantityCommand) { - * QuantityType c = quantityCommand.toUnit(CELSIUS); - * if (c != null) { - * return (short) (c.doubleValue() * 100); - * } else { - * throw new LambdaException("Unsupported unit"); - * } - * } - * if (command instanceof DecimalType c) { - * return (short) (c.doubleValue() * 100); - * } - * throw new LambdaException("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 LambdaGeneralException { - if (command instanceof QuantityType quantityCommand) { - QuantityType c = quantityCommand.toUnit(WATT); - if (c != null) { - return c.shortValue(); - } else { - throw new LambdaGeneralException("Unsupported unit"); - } - } - if (command instanceof DecimalType c) { - return c.shortValue(); - } - throw new LambdaGeneralException("Unsupported command type"); - } - - private short getScaledInt16Value(Command command) throws LambdaGeneralException { - if (command instanceof QuantityType quantityCommand) { - QuantityType c = quantityCommand.toUnit(CELSIUS); - if (c != null) { - return (short) (c.doubleValue() * 10); - } else { - throw new LambdaGeneralException("Unsupported unit"); - } - } - if (command instanceof DecimalType c) { - return (short) (c.doubleValue() * 10); - } - throw new LambdaGeneralException("Unsupported command type"); - } - - /** - * Handle incoming commands. - */ - @Override - public void handleCommand(ChannelUID channelUID, Command command) { - // loggertrace("283 handleCommand, channelUID: {} command {} ", channelUID, command); - if (RefreshType.REFRESH == command) { - String groupId = channelUID.getGroupId(); - if (groupId != null) { - AbstractBasePoller poller; - switch (groupId) { - case GROUP_GENERAL_AMBIENT: - poller = ambientPoller; - break; - case GROUP_GENERAL_EMANAGER: - poller = emanagerPoller; - break; - - default: - poller = null; - break; - } - if (poller != null) { - // loggertrace("336 Es wird gepollt }"); - poller.poll(); - } - } - } else { - // loggertrace("341 handleCommand: Es wird geschrieben, GroupID: {}, command {}", channelUID.getGroupId(), - // command); - try { - - // loggertrace("345 vor EMANAGER"); - if (GROUP_GENERAL_EMANAGER.equals(channelUID.getGroupId())) { - - // loggertrace("330 im EMANAGER channelUID {} ", channelUID.getIdWithoutGroup()); - switch (channelUID.getIdWithoutGroup()) { - - case CHANNEL_ACTUAL_POWER: - - // loggertrace("336 command: {}", command); - writeInt16(102, getInt16Value(command)); - break; - - } - } - - } catch (LambdaGeneralException error) { - if (hasConfigurationError() || getThing().getStatus() == ThingStatus.OFFLINE) { - return; - } - String cls = error.getClass().getName(); - String msg = error.getMessage(); - - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, - String.format("Error with: %s: %s", cls, msg)); - } - } - } - - /** - * Initialization: Load the config object of the block Connect to the slave - * bridge Start the periodic polling - */ - @Override - public void initialize() { - config = getConfigAs(LambdaGeneralConfiguration.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 polling1 - */ - private void startUp() { - if (comms != null) { - return; - } - - ModbusEndpointThingHandler slaveEndpointThingHandler = getEndpointThingHandler(); - if (slaveEndpointThingHandler == null) { - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, "Bridge is offline"); - return; - } - - try { - slaveId = slaveEndpointThingHandler.getSlaveId(); - - comms = slaveEndpointThingHandler.getCommunicationInterface(); - } catch (EndpointNotInitializedException e) { - // this will be handled below as endpoint remains null - } - - if (comms == 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)); - return; - } - - if (config == null) { - logger.debug("Invalid comms/config/manager ref for stiebel eltron handler"); - return; - } - - if (ambientPoller == null) { - AbstractBasePoller poller = new AbstractBasePoller() { - @Override - protected void handlePolledData(ModbusRegisterArray registers) { - handlePolledAmbientData(registers); - } - }; - poller.registerPollTask(0, 5, ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS); - ambientPoller = poller; - } - - if (emanagerPoller == null) { - AbstractBasePoller poller = new AbstractBasePoller() { - @Override - protected void handlePolledData(ModbusRegisterArray registers) { - handlePolledEManagerData(registers); - } - }; - poller.registerPollTask(100, 5, ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS); - emanagerPoller = poller; - } - - updateStatus(ThingStatus.UNKNOWN); - } - - /** - * Dispose the binding correctly - */ - @Override - public void dispose() { - tearDown(); - } - - /** - * Unregister the poll tasks and release the endpoint reference - */ - private void tearDown() { - - AbstractBasePoller poller = ambientPoller; - if (poller != null) { - poller.unregisterPollTask(); - ambientPoller = null; - } - - poller = emanagerPoller; - if (poller != null) { - poller.unregisterPollTask(); - emanagerPoller = null; - } - - comms = null; - } - - /** - * 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 thingHandler) { - return thingHandler; - } else { - throw new IllegalStateException("Unexpected bridge handler: " + handler.toString()); - } - } - - /** - * Obsolete because of new getScaled below - * - * Returns value divided by the 10 - * - * @param value the value to alter - * @return the scaled value as a DecimalType - * - * - * protected State getScaled10(Number value, Unit unit) { - * // loggertrace("505 value: {}", value.intValue()); - * return QuantityType.valueOf(value.doubleValue() / 10, unit); - * } - * - * protected State getScaled100(Number value, Unit unit) { - * // loggertrace("505 value: {}", value.intValue()); - * return QuantityType.valueOf(value.doubleValue() / 100, unit); - * } - */ - protected State getScaled(Number value, Unit unit, Double pow) { - // loggertrace("505 value: {}", value.intValue()); - double factor = Math.pow(10, pow); - return QuantityType.valueOf(value.doubleValue() * factor, unit); - } - - protected State getUnscaled(Number value, Unit unit) { - return QuantityType.valueOf(value.doubleValue(), 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 QuantityType.valueOf(value, KILOWATT_HOUR); - } - - /** - * These methods are 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 handlePolledAmbientData(ModbusRegisterArray registers) { - // loggertrace("Ambient block received, size: {}", registers.size()); - - // Ambient group - AmbientBlock block = ambientBlockParser.parse(registers); - - updateState(channelUID(GROUP_GENERAL_AMBIENT, CHANNEL_AMBIENT_ERROR_NUMBER), - new DecimalType(block.ambientErrorNumber)); - updateState(channelUID(GROUP_GENERAL_AMBIENT, CHANNEL_AMBIENT_OPERATING_STATE), - new DecimalType(block.ambientOperatingState)); - updateState(channelUID(GROUP_GENERAL_AMBIENT, CHANNEL_ACTUAL_AMBIENT_TEMPERATURE), - getScaled(block.actualAmbientTemperature, CELSIUS, -1.0)); - updateState(channelUID(GROUP_GENERAL_AMBIENT, CHANNEL_AVERAGE_AMBIENT_TEMPERATURE), - getScaled(block.averageAmbientTemperature, CELSIUS, -1.0)); - updateState(channelUID(GROUP_GENERAL_AMBIENT, CHANNEL_CALCULATED_AMBIENT_TEMPERATURE), - getScaled(block.calculatedAmbientTemperature, CELSIUS, -1.0)); - resetCommunicationError(); - } - - protected void handlePolledEManagerData(ModbusRegisterArray registers) { - // loggertrace("EManager block received, size: {}", registers.size()); - - // EManager group - EManagerBlock block = emanagerBlockParser.parse(registers); - updateState(channelUID(GROUP_GENERAL_EMANAGER, CHANNEL_EMANAGER_ERROR_NUMBER), - new DecimalType(block.emanagerErrorNumber)); - updateState(channelUID(GROUP_GENERAL_EMANAGER, CHANNEL_EMANAGER_OPERATING_STATE), - new DecimalType(block.emanagerOperatingState)); - updateState(channelUID(GROUP_GENERAL_EMANAGER, CHANNEL_ACTUAL_POWER_CONSUMPTION), - getUnscaled(block.actualPowerConsumption, WATT)); - updateState(channelUID(GROUP_GENERAL_EMANAGER, CHANNEL_ACTUAL_POWER), getUnscaled(block.actualPower, WATT)); - updateState(channelUID(GROUP_GENERAL_EMANAGER, CHANNEL_POWER_CONSUMPTION_SETPOINT), - getUnscaled(block.powerConsumptionSetpoint, WATT)); - - resetCommunicationError(); - } - - /** - * @param bridgeStatusInfo - */ - @Override - public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { - super.bridgeStatusChanged(bridgeStatusInfo); - - if (bridgeStatusInfo.getStatus() == ThingStatus.ONLINE) { - startUp(); - } else if (bridgeStatusInfo.getStatus() == ThingStatus.OFFLINE) { - tearDown(); - } - } - - /** - * Handle errors received during communication - */ - 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 = 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 - * - * @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.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/parser/AbstractBaseParser.java b/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/parser/AbstractBaseParser.java deleted file mode 100644 index aeb92a30017ce..0000000000000 --- a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/parser/AbstractBaseParser.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambdageneral.internal.parser; - -import java.util.Objects; -import java.util.Optional; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.core.io.transport.modbus.ModbusBitUtilities; -import org.openhab.core.io.transport.modbus.ModbusConstants.ValueType; -import org.openhab.core.io.transport.modbus.ModbusRegisterArray; -import org.openhab.core.library.types.DecimalType; - -/** - * 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 -> ((double) 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 Objects.requireNonNull(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 Objects.requireNonNull(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 Objects.requireNonNull(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 Objects.requireNonNull(extractOptionalUInt32(raw, index).orElse(def)); - } -} diff --git a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/parser/AmbientBlockParser.java b/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/parser/AmbientBlockParser.java deleted file mode 100644 index 5dc7536f1f06e..0000000000000 --- a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/parser/AmbientBlockParser.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambdageneral.internal.parser; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.binding.modbus.lambdageneral.internal.dto.AmbientBlock; -import org.openhab.core.io.transport.modbus.ModbusRegisterArray; - -/** - * Parses lambda modbus data into an Ambient Block - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - * - */ -@NonNullByDefault -public class AmbientBlockParser extends AbstractBaseParser { - - public AmbientBlock parse(ModbusRegisterArray raw) { - AmbientBlock block = new AmbientBlock(); - block.ambientErrorNumber = extractUInt16(raw, 0, (short) 0); - block.ambientOperatingState = extractUInt16(raw, 1, (short) 0); - block.actualAmbientTemperature = extractUInt16(raw, 2, (short) 0); - block.averageAmbientTemperature = extractUInt16(raw, 3, (short) 0); - block.calculatedAmbientTemperature = extractUInt16(raw, 4, (short) 0); - return block; - } -} diff --git a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/parser/EManagerBlockParser.java b/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/parser/EManagerBlockParser.java deleted file mode 100644 index 3c7924950aa33..0000000000000 --- a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/java/org/openhab/binding/modbus/lambdageneral/internal/parser/EManagerBlockParser.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambdageneral.internal.parser; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.binding.modbus.lambdageneral.internal.dto.EManagerBlock; -import org.openhab.core.io.transport.modbus.ModbusRegisterArray; - -/** - * Parses inverter modbus data into an EManger Block - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - * - */ -@NonNullByDefault -public class EManagerBlockParser extends AbstractBaseParser { - - public EManagerBlock parse(ModbusRegisterArray raw) { - EManagerBlock block = new EManagerBlock(); - block.emanagerErrorNumber = extractUInt16(raw, 0, (short) 0); - block.emanagerOperatingState = extractUInt16(raw, 1, (short) 0); - block.actualPower = extractUInt16(raw, 2, (short) 0); - block.actualPowerConsumption = extractUInt16(raw, 3, (short) 0); - block.powerConsumptionSetpoint = extractUInt16(raw, 4, (short) 0); - - return block; - } -} diff --git a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/resources/OH-INF/config/config-descriptions.xml b/bundles/org.openhab.binding.modbus.lambdageneral/src/main/resources/OH-INF/config/config-descriptions.xml deleted file mode 100644 index 8b5de20997840..0000000000000 --- a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/resources/OH-INF/config/config-descriptions.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - Refresh interval in seconds. Use zero to disable automatic polling. - 30 - 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.lambdageneral/src/main/resources/OH-INF/i18n/lambda-general.properties b/bundles/org.openhab.binding.modbus.lambdageneral/src/main/resources/OH-INF/i18n/lambda-general.properties deleted file mode 100644 index d03b39c0df732..0000000000000 --- a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/resources/OH-INF/i18n/lambda-general.properties +++ /dev/null @@ -1,32 +0,0 @@ -# thing types - -thing-type.modbus.lambda-general.label = Lambda Heat Pump General section -thing-type.modbus.lambda-general.description = Lambda Heat Pump General section connected through modbus - -# thing types config - -thing-type.config.lambda-general.modbusconfig.maxTries.label = Maximum Tries When Reading -thing-type.config.lambda-general.modbusconfig.maxTries.description = Number of tries when reading data, if some of the reading fail. For single try, enter 1. -thing-type.config.lambda-general.modbusconfig.refresh.label = Refresh Interval -thing-type.config.lambda-general.modbusconfig.refresh.description = Refresh interval in seconds. Use zero to disable automatic polling. - -# channel group types - -channel-group-type.modbus.general-ambient.label = General Ambient Group -channel-group-type.modbus.general-emanager.label = General E-Manager Group - -# channel types - -# General Ambient -channel-type.modbus.ambient-error-number-type.label = Ambient Error Number -channel-type.modbus.ambient-operating-state-type.label = Ambient Operating State -channel-type.modbus.actual-ambient-temperature-type.label = Actual Ambient Temperature -channel-type.modbus.average-ambient-temperature-type.label = Average Ambient Temperature 1h -channel-type.modbus.calculated-ambient-temperature-type.label = Calculated Ambient Temperature - -# General E-Manager -channel-type.modbus.emanager-error-number-type.label = E-Manager Error Number -channel-type.modbus.emanager-operating-state-type.label = E-Manager Operating State -channel-type.modbus.actual-power-type.label = Actual Power (input or excess) -channel-type.modbus.actual-power-consumption-type.label = Actual Power Consumption - diff --git a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/resources/OH-INF/thing/lambda-general-channel-groups.xml b/bundles/org.openhab.binding.modbus.lambdageneral/src/main/resources/OH-INF/thing/lambda-general-channel-groups.xml deleted file mode 100644 index 8eba6e2ea2665..0000000000000 --- a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/resources/OH-INF/thing/lambda-general-channel-groups.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/resources/OH-INF/thing/lambda-general-channel-types.xml b/bundles/org.openhab.binding.modbus.lambdageneral/src/main/resources/OH-INF/thing/lambda-general-channel-types.xml deleted file mode 100644 index 2607a01b6fc72..0000000000000 --- a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/resources/OH-INF/thing/lambda-general-channel-types.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - Number - - - - - - - - - - Number - - - - - - - - - - - - - Number:Temperature - - - - - - Number:Temperature - - - - - - Number:Temperature - - - - - - Number - - - - - - - - - - Number - - - - - - - - - - - - - - Number:Power - - - - - - Number:Power - - - - - - Number:Power - - - - - diff --git a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/resources/OH-INF/thing/lambda-general-types.xml b/bundles/org.openhab.binding.modbus.lambdageneral/src/main/resources/OH-INF/thing/lambda-general-types.xml deleted file mode 100644 index 8e284fc83372e..0000000000000 --- a/bundles/org.openhab.binding.modbus.lambdageneral/src/main/resources/OH-INF/thing/lambda-general-types.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - Lambda Heat Pump General section connected through modbus - - - - - - - - - - - diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/NOTICE b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/NOTICE deleted file mode 100644 index 38d625e349232..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/NOTICE +++ /dev/null @@ -1,13 +0,0 @@ -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/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/README.md b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/README.md deleted file mode 100644 index 5bc3583040082..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/README.md +++ /dev/null @@ -1,189 +0,0 @@ -# Lambda Heat Pump - -This extension adds support for the Lambda Heat Pump modbus protocol as provided by - - -A Lambda Heat Pump has to be reachable within your network. -If you plan to use the E-Manager part to hand over your PV excess to the heat pump ask Lambda support to -configure it to -E-Meter Kommunikationsart: ModBus Client -E-Meter Messpunkt: E-Eintrag - -Other configurations of the E-Manager are not supported (yet). - -## 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 | ThingTypeID | Description | -| ---------------------- | --------------------| --------------------------------------- | -| Lambda General | lambda-general | General sections Ambient and E-Manager | -| Lambda Heatpump | lambda-heatpump | Heatpump section | -| Lambda Boiler | lambda-boiler | Boiler section | -| Lambda Buffer | lambda-buffer | Buffer section | -| Lambda Heating Circuit | lambda-heating | Heating circuit section | - -A Modbus Bridge has to be installed before installing the above mentioned things. -The binding supports installations with more than one Heat Pump, Boiler, Buffer, Heating Circuit. -For each of these parts you have to provide the Subindex of your thing in the configurations section, -usually using the User Interface. So if you have two Heating Circuits use 0 for the first and 1 for -the second Heating Circuit. -Handling of General System Settings (Base Adress 200) and Solar (Base Adress 4000) are not supported (yet). -Some of the registers noted RW in the manual are read only in the binding. - -## Discovery - -This extension does not support autodiscovery. The things need to be added manually. - -A typical modbus bridge configuration would look like this: - -```java -Bridge modbus:tcp:bridge [ host="10.0.0.2", port=502, id=1 ] -``` - -## Thing Configuration - -You first need to set up a TCP Modbus bridge according to the Modbus documentation. -You then add the things of the Lambda Heat Pump system as part of the modbus binding. -Things in this extension will use the selected bridge to connect to the device. - -The following parameters are valid for all things: - -| Parameter | Type | Required | Default if omitted | Description | -| --------- | ------- | -------- | ------------------ | -------------------------------------------------------------------------- | -| refresh | integer | no | 30 | 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. | - -The other things use another parameter Subindex to add one or more things of this type: - -| Parameter | Type | Required | Default if omitted | Description | -| --------- | ------- | -------- | ------------------ | -------------------------------------------------------------------------- | -| Subindex | integer | yes | 0 | Subindex for things of the same thing type, starting with 0 | - -| Thing Type | Range | -| ---------------------- | ------- | -| Lambda Heatpump | 0..2 | -| Lambda Boiler | 0..4 | -| Lambda Buffer | 0..4 | -| Lambda Heating Circuit | 0..11 | - -## Channels - -Channels within the things are grouped into channel groups. - -### Lambda General: General Ambient Group - -This group contains ambient temperatures for the heat pump system. - -| Channel ID | Item Type | Read only | Description | -| -------------------------------- | ------------------ | --------- | ------------------------------------------------------------------------ | -| ambient-error-number | Number | true | Ambient Error Number (0 = No error) | -| ambient-operating-state | Number | true | Ambient Operating State (0 = OFF, 1 = AUTOMATIC, 2 = MANUAL, 3 = ERROR) | -| actual-ambient-temperature | Number:Temperature | false | Actual Ambient Temperature (min = -50.0°C); max = 80.0° | -| average-ambient-temperature | Number:Temperature | true | Arithmetic average temperature of the last 60 minutes | -| calculated-ambient-temperature | Number:Temperature | true | Temperature for calculations in heat distribution modules | - -### Lambda General: General E-Manager Group - -This group contains parameters signaling the PV excess to the heat pump. - -| Channel ID | Item Type | Read only | Description | -| -------------------------------- | ------------------ | --------- | --------------------------------------------------------------------------------------- | -| emanager-error-number | Number | true | E-Manager Error Number (0 = No error) | -| emanager-operating-state | Number | true | E-Manager Operating State (0 = OFF, 1 = AUTOMATIC, 2 = MANUAL, 3 = ERROR 4 = OFFLINE | -| actual-power | Number:Power | false | Actual excess power -32768 W .. 32767 W | -| actual-power-consumption | Number:Power | true | Power consumption of heatpump (only valid when Betriebsart: Automatik, 0 W otherwise) | -| power-consumption-setpoint | Number:Power | false | Power consumption setpoint for heat pump 1 | - -### Labda Heat Pump: Heatpump Group - -This group contains general operational information about the heat pump itself. - -| Channel ID | Item Type | Read only | Description | -| -------------------------------| -------------------------| --------- | ----------------------------------------------------------------------- | -| heatpump-error-state | Number | true | Error state (0 = NONE, 1 = MESSAGE, 2 = WARNING, 3 = ALARM, 4 = FAULT) | -| heatpump-error-number | Number | true | Error number: scrolling through all active error numbers (1..99) | -| heatpump-state | Number | true | State: See Modbus description manual, link above | -| heatpump-operating-state | Number | true | Operating State: See Modbus description manual, link above | -| heatpump-t-flow | Number:Temperature | true | Flow line termperature | -| heatpump-t-return | Number:Temperature | true | Return line temperature | -| heatpump-vol-sink | Number:VolumetricFlowRate | true | Volume flow heat sink | -| heatpump-t-eqin | Number:Temperature | true | Energy source inlet temperature | -| heatpump-t-eqout | Number:Temperature | true | Energy source outlet temperature | -| heatpump-vol-source | Number:VolumetricFlowRate | true | Volume flow energy source | -| heatpump-compressor-rating | Number | true | Compressor unit rating | -| heatpump-qp-heating | Number:Power | true | Actual heating capacity | -| heatpump-fi-power-consumption | Number:Power | true | Frequency inverter actual power consumption | -| heatpump-cop | Number | true | Coefficient of performance | -| heatpump-vdae | Number:Energy | true | Accumulated electrical energy consumption of compressor unit | -| heatpump-vdaq | Number:Energy | true | Accumulated thermal energy output of compressor unit | -| heatpump-set-error-quit | Number | false | Set Error Quit (1 = Quit all active heat pump errors | - -### Lambda Boiler: Boiler Group - -This group contains information about the boiler for the water for domestic use / tap water / washwater. - -| Channel ID | Item Type | Read only | Description | -| --------------------------------- | ------------------ | --------- | ------------------------------------------------------------------ | -| boiler-error-number | Number | true | Boiler Error Number(0 = No error) | -| boiler-operating-state | Number | true | Boiler Operating State: See Modbus description manual, link above | -| boiler-actual-high-temperature | Number:Temperature | true | Actual temperature boiler high sensor | -| boiler-actual-low-temperature | Number:Temperature | true | Actual temperature boiler low sensor | -| boiler-maximum-boiler-temperature | Number:Temperature | false | Setting for maximum boiler temperature (min = 25.0°C; max = 65.0°C)| - -### Lambda Buffer: Buffer Group - -This group contains information about the buffer for the heating circuit. - -| Channel ID | Item Type | Read only | Description | -| -------------------------------------- | ------------------ | --------- | ---------------------------------------------------------------------- | -| buffer-error-number | Number | true | Buffer Error Number (0 = No error) | -| buffer-operating-state | Number | true | Buffer Operating State: See Modbus description manual, link above | -| buffer-actual-high-temperature | Number:Temperature | true | Actual temperature buffer high sensor | -| buffer-actual-low-temperature | Number:Temperature | true | Actual temperature buffer low sensor | -| buffer-maximum-buffer-temperature | Number:Temperature | false | Setting for maximum buffer temperature (min = 25.0°C; max = 65.0°C) | - -### Lambda Heating: Heating Circuit Group - -This group contains general operational information about the heating circuit. - -| Channel ID | Item Type | Read only | Description | -| --------------------------------------------- | -------------------| --------- | ------------------------------------------------------------------------------- | -| heatingcircuit-error-number | Number | true | Error Number (0 = No error) | -| heatingcircuit-operating-state | Number | true | Operating State: See Modbus description manual, link above| | -| heatingcircuit-flow-line-temperature | Number:Temperature | true | Actual temperature flow line sensor | -| heatingcircuit-return-line-temperature | Number:Temperature | true | Actual temperature return line sensor | -| heatingcircuit-room-device-temperature | Number:Temperature | true | Actual temperature room device sensor (min = -29.9°C; max = 99.9°C) | -| heatingcircuit-setpoint-flow-line-temperature | Number:Temperature | true | Setpoint temperature flow line (min = 15.0°C; max = 65.0°C) | -| heatingcircuit-operating-mode | Number | true | Operating Mode: See Modbus description manual, link above | -| heatingcircuit-offset-flow-line-temperature | Number:Temperature | true | Setting for flow line temperature setpoint offset(min = -10.0K; max = 10.0K) | -| heatingcircuit-room-heating-temperature | Number:Temperature | true | Setting for heating mode room setpoint temperature(min = 15.0°C; max = 40.0 °C) | -| heatingcircuit-room-cooling-temperature | Number:Temperature | true | Setting for cooling mode room setpoint temperature(min = 15.0°C; max = 40.0 °C) | - -## Full Example - -### Thing Configuration of Modbus Bridge -UID: modbus:tcp:Lambda_Bridge -label: Lambda Modbus Bridge -thingTypeUID: modbus:tcp -configuration: - rtuEncoded: false - connectMaxTries: 1 - reconnectAfterMillis: 0 - timeBetweenTransactionsMillis: 100 - port: 502 - timeBetweenReconnectMillis: 0 - connectTimeoutMillis: 10000 - host: 192.168.223.83 - afterConnectionDelayMillis: 0 - id: 1 - enableDiscovery: false - -### Example: Write PV excess to the Lambda Heat Pump -// PV_Battery.state and PV_Grid have to be provided by your PV inverter -// Mode of E-Manager has to be switched to AUTOMATIK in the Lambda Heat Pump App -var int P_Available = ((Lambda_EMgr_Power_Consumption_Value_as_Number.state as Number) - (PW_Battery.state as Number) - (PW_Grid.state as Number)).intValue - lambdahp_actual_power.sendCommand(P_Available) - - diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/pom.xml b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/pom.xml deleted file mode 100644 index e2582d6419e97..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - 4.0.0 - - org.openhab.addons.bundles - org.openhab.addons.reactor.bundles - 4.3.0-SNAPSHOT - - - org.openhab.binding.modbus.lambda - - openHAB Add-ons :: Bundles :: Lambda Bundle - - - - org.openhab.addons.bundles - org.openhab.binding.modbus - ${project.version} - provided - - - - diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/BoilerConfiguration.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/BoilerConfiguration.java deleted file mode 100644 index 419010eceff01..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/BoilerConfiguration.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal; - -import org.eclipse.jdt.annotation.NonNullByDefault; - -/** - * The {@link BoilerConfiguration} class contains fields mapping - * thing configuration parameters. - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - */ -@NonNullByDefault -public class BoilerConfiguration { - - /** - * Refresh interval in seconds - */ - private int refresh = 30; - - private int maxTries = 3; - // backwards compatibility and tests - - /** - * Subindex to calculate the base adress of the modbus registers - */ - private int subindex = 0; - - /** - * Gets refresh period in milliseconds - */ - public long getRefreshMillis() { - return refresh * 1000; - } - - public int getMaxTries() { - return maxTries; - } - - public void setMaxTries(int maxTries) { - this.maxTries = maxTries; - } - - public int getSubindex() { - return subindex; - } - - public void setSubindex(int subindex) { - this.subindex = subindex; - } -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/BufferConfiguration.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/BufferConfiguration.java deleted file mode 100644 index 309d310c95c47..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/BufferConfiguration.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal; - -import org.eclipse.jdt.annotation.NonNullByDefault; - -/** - * The {@link BufferConfiguration} class contains fields mapping - * thing configuration parameters. - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - */ -@NonNullByDefault -public class BufferConfiguration { - /** - * Refresh interval in seconds - */ - private int refresh = 30; - - private int maxTries = 3; - // backwards compatibility and tests - - /** - * Subindex to calculate the base adress of the modbus registers - */ - private int subindex = 0; - - /** - * Gets refresh period in milliseconds - */ - public long getRefreshMillis() { - return refresh * 1000; - } - - public int getMaxTries() { - return maxTries; - } - - public void setMaxTries(int maxTries) { - this.maxTries = maxTries; - } - - public int getSubindex() { - return subindex; - } - - public void setSubindex(int subindex) { - this.subindex = subindex; - } -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/GeneralConfiguration.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/GeneralConfiguration.java deleted file mode 100644 index e0fea1fa8dba6..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/GeneralConfiguration.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal; - -import org.eclipse.jdt.annotation.NonNullByDefault; - -/** - * The {@link GeneralConfiguration} class contains fields mapping - * thing configuration parameters. - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - */ -@NonNullByDefault -public class GeneralConfiguration { - /** - * Refresh interval in seconds - */ - private int refresh = 30; - - 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/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/HeatingCircuitConfiguration.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/HeatingCircuitConfiguration.java deleted file mode 100644 index 80e904f0cc36f..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/HeatingCircuitConfiguration.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal; - -import org.eclipse.jdt.annotation.NonNullByDefault; - -/** - * The {@link HeatingCircuitConfiguration} class contains fields mapping - * thing configuration parameters. - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - */ -@NonNullByDefault -public class HeatingCircuitConfiguration { - /** - * Refresh interval in seconds - */ - private int refresh = 30; - - private int maxTries = 3; - // backwards compatibility and tests - - /** - * Subindex to calculate the base adress of the modbus registers - */ - private int subindex = 0; - - /** - * Gets refresh period in milliseconds - */ - public long getRefreshMillis() { - return refresh * 1000; - } - - public int getMaxTries() { - return maxTries; - } - - public void setMaxTries(int maxTries) { - this.maxTries = maxTries; - } - - public int getSubindex() { - return subindex; - } - - public void setSubindex(int subindex) { - this.subindex = subindex; - } -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/HeatpumpConfiguration.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/HeatpumpConfiguration.java deleted file mode 100644 index 17118f7b2ae47..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/HeatpumpConfiguration.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal; - -import org.eclipse.jdt.annotation.NonNullByDefault; - -/** - * The {@link GeneralConfiguration} class contains fields mapping - * thing configuration parameters. - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - */ -@NonNullByDefault -public class HeatpumpConfiguration { - - /** - * Refresh interval in seconds - */ - private int refresh = 30; - - private int maxTries = 3; - - // backwards compatibility and tests - - /** - * Subindex to calculate the base adress of the modbus registers - */ - private int subindex = 0; - - /** - * Gets refresh period in milliseconds - */ - public long getRefreshMillis() { - return refresh * 1000; - } - - public int getMaxTries() { - return maxTries; - } - - public void setMaxTries(int maxTries) { - this.maxTries = maxTries; - } - - public int getSubindex() { - return subindex; - } - - public void setSubindex(int subindex) { - this.subindex = subindex; - } -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/LambdaBindingConstants.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/LambdaBindingConstants.java deleted file mode 100644 index 55e4eb58f3449..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/LambdaBindingConstants.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.binding.modbus.ModbusBindingConstants; -import org.openhab.core.thing.ThingTypeUID; - -/** - * The {@link LambdaBindingConstants} class defines common - * constants, which are used across the whole binding. - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - */ -@NonNullByDefault -public class LambdaBindingConstants { - - private static final String BINDING_ID = ModbusBindingConstants.BINDING_ID; - private static final String LAMBDAGENERAL = "lambda-general"; - private static final String LAMBDABOILER = "lambda-boiler"; - private static final String LAMBDABUFFER = "lambda-buffer"; - private static final String LAMBDAHEATPUMP = "lambda-heatpump"; - private static final String LAMBDAHEATING = "lambda-heating"; - - // List of all Thing Type UIDs - public static final ThingTypeUID THING_TYPE_LAMBDAGENERAL = new ThingTypeUID(BINDING_ID, LAMBDAGENERAL); - public static final ThingTypeUID THING_TYPE_LAMBDABOILER = new ThingTypeUID(BINDING_ID, LAMBDABOILER); - public static final ThingTypeUID THING_TYPE_LAMBDABUFFER = new ThingTypeUID(BINDING_ID, LAMBDABUFFER); - public static final ThingTypeUID THING_TYPE_LAMBDAHEATPUMP = new ThingTypeUID(BINDING_ID, LAMBDAHEATPUMP); - public static final ThingTypeUID THING_TYPE_LAMBDAHEATING = new ThingTypeUID(BINDING_ID, LAMBDAHEATING); - - // Channel group ids - public static final String GROUP_GENERAL_AMBIENT = "ambient"; - public static final String GROUP_GENERAL_EMANAGER = "emanager"; - public static final String GROUP_HEATPUMP = "heatpump"; - public static final String GROUP_HEATPUMP_REG50 = "heatpump-reg50"; - public static final String GROUP_BOILER = "boiler"; - public static final String GROUP_BOILER_REG50 = "boiler-reg50"; - public static final String GROUP_BUFFER = "buffer"; - public static final String GROUP_BUFFER_REG50 = "buffer-reg50"; - public static final String GROUP_HEATINGCIRCUIT = "heatingcircuit"; - public static final String GROUP_HEATINGCIRCUIT_REG50 = "heatingcircuit-reg50"; - - // List of all Channel ids in device information group - // General Ambient - public static final String CHANNEL_AMBIENT_ERROR_NUMBER = "ambient-error-number"; - public static final String CHANNEL_AMBIENT_OPERATING_STATE = "ambient-operating-state"; - public static final String CHANNEL_ACTUAL_AMBIENT_TEMPERATURE = "actual-ambient-temperature"; - public static final String CHANNEL_AVERAGE_AMBIENT_TEMPERATURE = "average-ambient-temperature"; - public static final String CHANNEL_CALCULATED_AMBIENT_TEMPERATURE = "calculated-ambient-temperature"; - - // General E-manager - public static final String CHANNEL_EMANAGER_ERROR_NUMBER = "emanager-error-number"; - public static final String CHANNEL_EMANAGER_OPERATING_STATE = "emanager-operating-state"; - public static final String CHANNEL_ACTUAL_POWER = "actual-power"; - public static final String CHANNEL_ACTUAL_POWER_CONSUMPTION = "actual-power-consumption"; - public static final String CHANNEL_POWER_CONSUMPTION_SETPOINT = "power-consumption-setpoint"; - - // Heatpump - public static final String CHANNEL_HEATPUMP_ERROR_STATE = "heatpump-error-state"; - public static final String CHANNEL_HEATPUMP_ERROR_NUMBER = "heatpump-error-number"; - public static final String CHANNEL_HEATPUMP_STATE = "heatpump-state"; - public static final String CHANNEL_HEATPUMP_OPERATING_STATE = "heatpump-operating-state"; - public static final String CHANNEL_HEATPUMP_T_FLOW = "heatpump-t-flow"; - public static final String CHANNEL_HEATPUMP_T_RETURN = "heatpump-t-return"; - public static final String CHANNEL_HEATPUMP_VOL_SINK = "heatpump-vol-sink"; - public static final String CHANNEL_HEATPUMP_T_EQIN = "heatpump-t-eqin"; - public static final String CHANNEL_HEATPUMP_T_EQOUT = "heatpump-t-eqout"; - public static final String CHANNEL_HEATPUMP_VOL_SOURCE = "heatpump-vol-source"; - public static final String CHANNEL_HEATPUMP_COMPRESSOR_RATING = "heatpump-compressor-rating"; - public static final String CHANNEL_HEATPUMP_QP_HEATING = "heatpump-qp-heating"; - public static final String CHANNEL_HEATPUMP_FI_POWER_CONSUMPTION = "heatpump-fi-power-consumption"; - public static final String CHANNEL_HEATPUMP_COP = "heatpump-cop"; - public static final String CHANNEL_HEATPUMP_VDAE = "heatpump-vdae"; - public static final String CHANNEL_HEATPUMP_VDAQ = "heatpump-vdaq"; - public static final String CHANNEL_HEATPUMP_SET_ERROR_QUIT = "heatpump-set-error-quit"; - - // Boiler - public static final String CHANNEL_BOILER_ERROR_NUMBER = "boiler-error-number"; - public static final String CHANNEL_BOILER_OPERATING_STATE = "boiler-operating-state"; - public static final String CHANNEL_BOILER_ACTUAL_HIGH_TEMPERATURE = "boiler-actual-high-temperature"; - public static final String CHANNEL_BOILER_ACTUAL_LOW_TEMPERATURE = "boiler-actual-low-temperature"; - public static final String CHANNEL_BOILER_MAXIMUM_BOILER_TEMPERATURE = "boiler-maximum-boiler-temperature"; - - // Buffer - public static final String CHANNEL_BUFFER_ERROR_NUMBER = "buffer-error-number"; - public static final String CHANNEL_BUFFER_OPERATING_STATE = "buffer-operating-state"; - public static final String CHANNEL_BUFFER_ACTUAL_HIGH_TEMPERATURE = "buffer-actual-high-temperature"; - public static final String CHANNEL_BUFFER_ACTUAL_LOW_TEMPERATURE = "buffer-actual-low-temperature"; - public static final String CHANNEL_BUFFER_MAXIMUM_BOILER_TEMPERATURE = "buffer-maximum-boiler-temperature"; - - // Heating Circuit - public static final String CHANNEL_HEATINGCIRCUIT_ERROR_NUMBER = "heatingcircuit-error-number"; - public static final String CHANNEL_HEATINGCIRCUIT_OPERATING_STATE = "heatingcircuit-operating-state"; - public static final String CHANNEL_HEATINGCIRCUIT_FLOW_LINE_TEMPERATURE = "heatingcircuit-flow-line-temperature"; - public static final String CHANNEL_HEATINGCIRCUIT_RETURN_LINE_TEMPERATURE = "heatingcircuit-return-line-temperature"; - public static final String CHANNEL_HEATINGCIRCUIT_ROOM_DEVICE_TEMPERATURE = "heatingcircuit-room-device-temperature"; - public static final String CHANNEL_HEATINGCIRCUIT_SETPOINT_FLOW_LINE_TEMPERATURE = "heatingcircuit-setpoint-flow-line-temperature"; - public static final String CHANNEL_HEATINGCIRCUIT_OPERATING_MODE = "heatingcircuit-operating-mode"; - // Heating Circuit Set - public static final String CHANNEL_HEATINGCIRCUIT_OFFSET_FLOW_LINE_TEMPERATURE = "heatingcircuit-offset-flow-line-temperature"; - public static final String CHANNEL_HEATINGCIRCUIT_ROOM_HEATING_TEMPERATURE = "heatingcircuit-room-heating-temperature"; - public static final String CHANNEL_HEATINGCIRCUIT_ROOM_COOLING_TEMPERATURE = "heatingcircuit-room-cooling-temperature"; -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/LambdaHandlerFactory.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/LambdaHandlerFactory.java deleted file mode 100644 index cd0264155303c..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/LambdaHandlerFactory.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal; - -import static org.openhab.binding.modbus.lambda.internal.LambdaBindingConstants.THING_TYPE_LAMBDABOILER; -import static org.openhab.binding.modbus.lambda.internal.LambdaBindingConstants.THING_TYPE_LAMBDABUFFER; -import static org.openhab.binding.modbus.lambda.internal.LambdaBindingConstants.THING_TYPE_LAMBDAGENERAL; -import static org.openhab.binding.modbus.lambda.internal.LambdaBindingConstants.THING_TYPE_LAMBDAHEATING; -import static org.openhab.binding.modbus.lambda.internal.LambdaBindingConstants.THING_TYPE_LAMBDAHEATPUMP; - -import java.util.Set; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.eclipse.jdt.annotation.Nullable; -import org.openhab.binding.modbus.lambda.internal.handler.BoilerHandler; -import org.openhab.binding.modbus.lambda.internal.handler.BufferHandler; -import org.openhab.binding.modbus.lambda.internal.handler.GeneralHandler; -import org.openhab.binding.modbus.lambda.internal.handler.HeatingCircuitHandler; -import org.openhab.binding.modbus.lambda.internal.handler.HeatpumpHandler; -import org.openhab.core.thing.Thing; -import org.openhab.core.thing.ThingTypeUID; -import org.openhab.core.thing.binding.BaseThingHandlerFactory; -import org.openhab.core.thing.binding.ThingHandler; -import org.openhab.core.thing.binding.ThingHandlerFactory; -import org.osgi.service.component.annotations.Component; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The {@link LambdaHandlerFactory} is responsible for creating things and thing - * handlers. - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - */ -@NonNullByDefault -@Component(configurationPid = "binding.lambda", service = ThingHandlerFactory.class) -public class LambdaHandlerFactory extends BaseThingHandlerFactory { - - private final Logger logger = LoggerFactory.getLogger(LambdaHandlerFactory.class); - - private static final Set SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_LAMBDAGENERAL, - THING_TYPE_LAMBDAHEATPUMP, THING_TYPE_LAMBDABOILER, THING_TYPE_LAMBDABUFFER, THING_TYPE_LAMBDAHEATING); - - @Override - public boolean supportsThingType(ThingTypeUID thingTypeUID) { - // logger.trace("Query LambdaHandlerFactory supportsThingType {} ?", thingTypeUID.toString()); - return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID); - } - - @Override - protected @Nullable ThingHandler createHandler(Thing thing) { - ThingTypeUID thingTypeUID = thing.getThingTypeUID(); - logger.trace("LambdaHandlerFactory ThingHandler searching of {}", thingTypeUID.toString()); - - if (THING_TYPE_LAMBDAGENERAL.equals(thingTypeUID)) { - logger.debug("LambdaHandlerFactory ThingHandler LAMBDAGENERAL found first place {}", - thingTypeUID.toString()); - return new GeneralHandler(thing); - } else if (THING_TYPE_LAMBDAHEATPUMP.equals(thingTypeUID)) { - logger.debug("LambdaHandlerFactory ThingHandler LAMBDABUFFER found 2. place {}", thingTypeUID.toString()); - return new HeatpumpHandler(thing); - } else if (THING_TYPE_LAMBDABUFFER.equals(thingTypeUID)) { - logger.debug("LambdaHandlerFactory ThingHandler LAMBDABUFFER found 3. place {}", thingTypeUID.toString()); - return new BufferHandler(thing); - } else if (THING_TYPE_LAMBDABOILER.equals(thingTypeUID)) { - logger.debug("LambdaHandlerFactory ThingHandler LAMBDABOILER found 4. place {}", thingTypeUID.toString()); - return new BoilerHandler(thing); - } else if (THING_TYPE_LAMBDAHEATING.equals(thingTypeUID)) { - logger.debug("LambdaHandlerFactory ThingHandler LAMBDAHEATING found 5. place {}", thingTypeUID.toString()); - return new HeatingCircuitHandler(thing); - } - return null; - } -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/AmbientBlock.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/AmbientBlock.java deleted file mode 100644 index cb765cdef0b45..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/AmbientBlock.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.dto; - -/** - * Dto class for the Ambient Block - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - * - */ -public class AmbientBlock { - public int ambientErrorNumber; - public int ambientOperatingState; - public int actualAmbientTemperature; - public int averageAmbientTemperature; - public int calculatedAmbientTemperature; -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/BoilerBlock.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/BoilerBlock.java deleted file mode 100644 index a47e35b6069bf..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/BoilerBlock.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.dto; - -/** - * Dto class for the Boiler Block - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - * - */ -public class BoilerBlock { - public int boilerErrorNumber; - public int boilerOperatingState; - public int boilerActualHighTemperature; - public int boilerActualLowTemperature; -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/BoilerReg50Block.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/BoilerReg50Block.java deleted file mode 100644 index 0073a81100c15..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/BoilerReg50Block.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.dto; - -/** - * Dto class for the BoilerReg50 Block - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - * - */ -public class BoilerReg50Block { - - public int boilerMaximumBoilerTemperature; -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/BufferBlock.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/BufferBlock.java deleted file mode 100644 index 7b7200c579f4b..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/BufferBlock.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.dto; - -/** - * Dto class for the Buffer Block - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - * - */ -public class BufferBlock { - public int bufferErrorNumber; - public int bufferOperatingState; - public int bufferActualHighTemperature; - public int bufferActualLowTemperature; -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/BufferReg50Block.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/BufferReg50Block.java deleted file mode 100644 index 86962b537f19b..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/BufferReg50Block.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.dto; - -/** - * Dto class for the BufferReg50 Block - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - * - */ -public class BufferReg50Block { - - public int bufferMaximumBufferTemperature; -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/EManagerBlock.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/EManagerBlock.java deleted file mode 100644 index a0298ac4dc888..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/EManagerBlock.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.dto; - -/** - * Dto class for the EManager Block - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - * - */ -public class EManagerBlock { - public int emanagerErrorNumber; - public int emanagerOperatingState; - public int actualPower; - public int actualPowerConsumption; - public int powerConsumptionSetpoint; -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/HeatingCircuitBlock.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/HeatingCircuitBlock.java deleted file mode 100644 index f5d0794789f20..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/HeatingCircuitBlock.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.dto; - -/** - * Dto class for the HeatingCircuit Block - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - * - */ -public class HeatingCircuitBlock { - - public int heatingcircuitErrorNumber; - public int heatingcircuitOperatingState; - public int heatingcircuitFlowLineTemperature; - public int heatingcircuitReturnLineTemperature; - public int heatingcircuitRoomDeviceTemperature; - public int heatingcircuitSetpointFlowLineTemperature; - public int heatingcircuitOperatingMode; -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/HeatingCircuitReg50Block.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/HeatingCircuitReg50Block.java deleted file mode 100644 index 92cf54747dc82..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/HeatingCircuitReg50Block.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.dto; - -/** - * Dto class for the HeatingCircuitReg50 Block - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - * - */ - -public class HeatingCircuitReg50Block { - public int heatingcircuitOffsetFlowLineTemperature; - public int heatingcircuitRoomHeatingTemperature; - public int heatingcircuitRoomCoolingTemperature; -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/HeatpumpBlock.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/HeatpumpBlock.java deleted file mode 100644 index a563ca36078df..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/HeatpumpBlock.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.dto; - -/** - * Dto class for the Heatpump Block - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - * - */ -public class HeatpumpBlock { - public int heatpumpErrorState; - public int heatpumpErrorNumber; - public int heatpumpState; - public int heatpumpOperatingState; - public int heatpumpTFlow; - public int heatpumpTReturn; - public int heatpumpVolSink; - public int heatpumpTEQin; - public int heatpumpTEQout; - public int heatpumpVolSource; - public int heatpumpCompressorRating; - public int heatpumpQpHeating; - public int heatpumpFIPowerConsumption; - public int heatpumpCOP; - public long heatpumpVdAE; - public long heatpumpVdAQ; -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/HeatpumpReg50Block.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/HeatpumpReg50Block.java deleted file mode 100644 index dbab7fcfa690e..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/dto/HeatpumpReg50Block.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.dto; - -/** - * Dto class for the Heatpump Block - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - * - */ -public class HeatpumpReg50Block { - - public int heatpumpSetErrorQuit; -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/BoilerHandler.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/BoilerHandler.java deleted file mode 100644 index e148b626e4a3f..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/BoilerHandler.java +++ /dev/null @@ -1,575 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.handler; - -import static org.openhab.binding.modbus.lambda.internal.LambdaBindingConstants.*; -import static org.openhab.core.library.unit.SIUnits.CELSIUS; -import static org.openhab.core.library.unit.Units.*; - -import java.util.Optional; - -import javax.measure.Unit; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.eclipse.jdt.annotation.Nullable; -import org.openhab.binding.modbus.handler.EndpointNotInitializedException; -import org.openhab.binding.modbus.handler.ModbusEndpointThingHandler; -import org.openhab.binding.modbus.lambda.internal.BoilerConfiguration; -import org.openhab.binding.modbus.lambda.internal.dto.BoilerBlock; -import org.openhab.binding.modbus.lambda.internal.dto.BoilerReg50Block; -import org.openhab.binding.modbus.lambda.internal.parser.BoilerBlockParser; -import org.openhab.binding.modbus.lambda.internal.parser.BoilerReg50BlockParser; -import org.openhab.core.io.transport.modbus.AsyncModbusFailure; -import org.openhab.core.io.transport.modbus.ModbusCommunicationInterface; -import org.openhab.core.io.transport.modbus.ModbusReadFunctionCode; -import org.openhab.core.io.transport.modbus.ModbusReadRequestBlueprint; -import org.openhab.core.io.transport.modbus.ModbusRegisterArray; -import org.openhab.core.io.transport.modbus.ModbusWriteRegisterRequestBlueprint; -import org.openhab.core.io.transport.modbus.ModbusWriteRequestBlueprint; -import org.openhab.core.io.transport.modbus.PollTask; -import org.openhab.core.library.types.DecimalType; -import org.openhab.core.library.types.QuantityType; -import org.openhab.core.thing.Bridge; -import org.openhab.core.thing.ChannelUID; -import org.openhab.core.thing.Thing; -import org.openhab.core.thing.ThingStatus; -import org.openhab.core.thing.ThingStatusDetail; -import org.openhab.core.thing.ThingStatusInfo; -import org.openhab.core.thing.binding.BaseThingHandler; -import org.openhab.core.thing.binding.ThingHandler; -import org.openhab.core.types.Command; -import org.openhab.core.types.RefreshType; -import org.openhab.core.types.State; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The {@link BoilerHandler} 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 BoilerHandler extends BaseThingHandler { - - public abstract class AbstractBasePoller { - - private final Logger logger = LoggerFactory.getLogger(BoilerHandler.class); - - private volatile @Nullable PollTask pollTask; - - public synchronized void unregisterPollTask() { - PollTask task = pollTask; - if (task == null) { - return; - } - - ModbusCommunicationInterface mycomms = BoilerHandler.this.comms; - if (mycomms != null) { - mycomms.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 Address: {}", address); - - ModbusCommunicationInterface mycomms = BoilerHandler.this.comms; - BoilerConfiguration myconfig = BoilerHandler.this.config; - if (myconfig == null || mycomms == null) { - throw new IllegalStateException("Boiler: registerPollTask called without proper configuration"); - } - - ModbusReadRequestBlueprint request = new ModbusReadRequestBlueprint(getSlaveId(), readFunctionCode, address, - length, myconfig.getMaxTries()); - - long refreshMillis = myconfig.getRefreshMillis(); - - pollTask = mycomms.registerRegularPoll(request, refreshMillis, 1000, result -> { - result.getRegisters().ifPresent(this::handlePolledData); - if (getThing().getStatus() != ThingStatus.ONLINE) { - updateStatus(ThingStatus.ONLINE); - } - }, BoilerHandler.this::handleReadError); - } - - public synchronized void poll() { - PollTask task = pollTask; - ModbusCommunicationInterface mycomms = BoilerHandler.this.comms; - if (task != null && mycomms != null) { - mycomms.submitOneTimePoll(task.getRequest(), task.getResultCallback(), task.getFailureCallback()); - } - } - - protected abstract void handlePolledData(ModbusRegisterArray registers); - } - - /** - * Logger instance - */ - private final Logger logger = LoggerFactory.getLogger(BoilerHandler.class); - - /** - * Configuration instance - */ - protected @Nullable BoilerConfiguration config = null; - /** - * Parser used to convert incoming raw messages into system blocks - * private final SystemInfromationBlockParser systemInformationBlockParser = new SystemInfromationBlockParser(); - */ - /** - * Parsers used to convert incoming raw messages into state blocks - */ - - private final BoilerBlockParser boilerBlockParser = new BoilerBlockParser(); - private final BoilerReg50BlockParser boilerReg50BlockParser = new BoilerReg50BlockParser(); - - /** - * These are the tasks used to poll the device - */ - - private volatile @Nullable AbstractBasePoller boilerPoller = null; - private volatile @Nullable AbstractBasePoller boilerReg50Poller = null; - - /** - * Communication interface to the slave endpoint we're connecting to - */ - protected volatile @Nullable ModbusCommunicationInterface comms = null; - /** - * This is the slave id, we store this once initialization is complete - */ - private volatile int slaveId; - - /** - * Instances of this handler should get a reference to the modbus manager - * - * @param thing the thing to handle - */ - public BoilerHandler(Thing thing) { - super(thing); - } - - /** - * @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) { - logger.trace("Boiler: writeInt16: Es wird geschrieben, Adresse: {} Wert: {}", address, shortValue); - BoilerConfiguration myconfig = BoilerHandler.this.config; - ModbusCommunicationInterface mycomms = BoilerHandler.this.comms; - - if (myconfig == null || mycomms == null) { - throw new IllegalStateException("registerPollTask called without proper configuration"); - } - // big endian byte ordering - byte hi = (byte) (shortValue >> 8); - byte lo = (byte) shortValue; - ModbusRegisterArray data = new ModbusRegisterArray(hi, lo); - - logger.trace("Boiler: 199 hi: {}, lo: {}", hi, lo); - ModbusWriteRegisterRequestBlueprint request = new ModbusWriteRegisterRequestBlueprint(slaveId, address, data, - true, myconfig.getMaxTries()); - - mycomms.submitOneTimeWrite(request, result -> { - if (hasConfigurationError()) { - return; - } - logger.trace("Boiler: Successful write, matching request {}", request); - BoilerHandler.this.updateStatus(ThingStatus.ONLINE); - }, failure -> { - BoilerHandler.this.handleWriteError(failure); - logger.trace("Boiler: Unsuccessful write, matching request {}", request); - }); - } - - /** - * @param command get the value of this command. - * @return short the value of the command as short - */ - private short getInt16Value(Command command) throws LambdaException { - if (command instanceof QuantityType quantityCommand) { - QuantityType c = quantityCommand.toUnit(WATT); - if (c != null) { - return c.shortValue(); - } else { - throw new LambdaException("Unsupported unit"); - } - } - if (command instanceof DecimalType c) { - return c.shortValue(); - } - throw new LambdaException("Unsupported command type"); - } - - private short getScaledInt16Value(Command command) throws LambdaException { - if (command instanceof QuantityType quantityCommand) { - QuantityType c = quantityCommand.toUnit(CELSIUS); - if (c != null) { - return (short) (c.doubleValue() * 10); - } else { - throw new LambdaException("Unsupported unit"); - } - } - if (command instanceof DecimalType c) { - return (short) (c.doubleValue() * 10); - } - throw new LambdaException("Unsupported command type"); - } - - /** - * Handle incoming commands. - */ - @Override - public void handleCommand(ChannelUID channelUID, Command command) { - logger.trace("Boiler: handleCommand, channelUID: {} command {} ", channelUID, command); - if (RefreshType.REFRESH == command) { - String groupId = channelUID.getGroupId(); - if (groupId != null) { - AbstractBasePoller poller; - switch (groupId) { - case GROUP_BOILER: - poller = boilerPoller; - break; - case GROUP_BOILER_REG50: - poller = boilerReg50Poller; - break; - - default: - poller = null; - break; - } - if (poller != null) { - logger.trace("Boiler: Es wird gepollt }"); - poller.poll(); - } - } - } else { - logger.trace("Boiler: handleCommand: Es wird geschrieben, GroupID: {}, command {}", channelUID.getGroupId(), - command); - try { - - if (GROUP_BOILER_REG50.equals(channelUID.getGroupId())) { - logger.trace("Boiler: im BOILER_REG50 channelUID {} ", channelUID.getIdWithoutGroup()); - - switch (channelUID.getIdWithoutGroup()) { - - case CHANNEL_BOILER_MAXIMUM_BOILER_TEMPERATURE: - - logger.trace("Boiler: command: {}", command); - writeInt16(2050, getScaledInt16Value(command)); - break; - - } - } - - } - - catch (LambdaException error) { - if (hasConfigurationError() || getThing().getStatus() == ThingStatus.OFFLINE) { - return; - } - String cls = error.getClass().getName(); - String msg = error.getMessage(); - - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, - String.format("Error with: %s: %s", cls, msg)); - } - } - } - - /** - * Initialization: Load the config object of the block Connect to the slave - * bridge Start the periodic polling - */ - @Override - public void initialize() { - config = getConfigAs(BoilerConfiguration.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 polling1 - */ - private void startUp() { - if (comms != null) { - return; - } - - ModbusEndpointThingHandler slaveEndpointThingHandler = getEndpointThingHandler(); - if (slaveEndpointThingHandler == null) { - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, "Bridge is offline"); - return; - } - - try { - slaveId = slaveEndpointThingHandler.getSlaveId(); - - comms = slaveEndpointThingHandler.getCommunicationInterface(); - } catch (EndpointNotInitializedException e) { - // this will be handled below as endpoint remains null - } - - if (comms == 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)); - return; - } - - if (config == null) { - logger.debug("Invalid comms/config/manager ref for lambda-boiler handler"); - return; - } - - BoilerConfiguration myconfig = BoilerHandler.this.config; - - int baseadress = 2000 + 100 * myconfig.getSubindex(); - - logger.debug("Boiler config.baseadress = {} ", baseadress); - - int reg50baseadress = baseadress + 50; - - logger.debug("BoilerReg50 baseadress = {} ", reg50baseadress); - - if (boilerPoller == null) { - AbstractBasePoller poller = new AbstractBasePoller() { - @Override - protected void handlePolledData(ModbusRegisterArray registers) { - handlePolledBoilerData(registers); - } - }; - - poller.registerPollTask(baseadress, 4, ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS); - boilerPoller = poller; - } - - if (boilerReg50Poller == null) { - AbstractBasePoller poller = new AbstractBasePoller() { - @Override - protected void handlePolledData(ModbusRegisterArray registers) { - handlePolledBoilerReg50Data(registers); - } - }; - - poller.registerPollTask(reg50baseadress, 1, ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS); - boilerReg50Poller = poller; - } - - updateStatus(ThingStatus.UNKNOWN); - } - - /** - * Dispose the binding correctly - */ - @Override - public void dispose() { - tearDown(); - } - - /** - * Unregister the poll tasks and release the endpoint reference - */ - private void tearDown() { - - AbstractBasePoller poller = boilerPoller; - - poller = boilerPoller; - if (poller != null) { - poller.unregisterPollTask(); - boilerPoller = null; - } - poller = boilerReg50Poller; - if (poller != null) { - poller.unregisterPollTask(); - boilerReg50Poller = null; - } - - comms = null; - } - - /** - * 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 thingHandler) { - return thingHandler; - } else { - throw new IllegalStateException("Unexpected bridge handler: " + handler.toString()); - } - } - - protected State getScaled(Number value, Unit unit, Double pow) { - // logger.trace("505 value: {}", value.intValue()); - double factor = Math.pow(10, pow); - return QuantityType.valueOf(value.doubleValue() * factor, unit); - } - - protected State getUnscaled(Number value, Unit unit) { - return QuantityType.valueOf(value.doubleValue(), 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 QuantityType.valueOf(value, KILOWATT_HOUR); - } - - /** - * These methods are 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 handlePolledBoilerData(ModbusRegisterArray registers) { - // logger.trace("Boiler block received, size: {}", registers.size()); - - BoilerBlock block = boilerBlockParser.parse(registers); - - // Boiler group - updateState(channelUID(GROUP_BOILER, CHANNEL_BOILER_ERROR_NUMBER), new DecimalType(block.boilerErrorNumber)); - updateState(channelUID(GROUP_BOILER, CHANNEL_BOILER_OPERATING_STATE), - new DecimalType(block.boilerOperatingState)); - updateState(channelUID(GROUP_BOILER, CHANNEL_BOILER_ACTUAL_HIGH_TEMPERATURE), - getScaled(block.boilerActualHighTemperature, CELSIUS, -1.0)); - updateState(channelUID(GROUP_BOILER, CHANNEL_BOILER_ACTUAL_LOW_TEMPERATURE), - getScaled(block.boilerActualLowTemperature, CELSIUS, -1.0)); - resetCommunicationError(); - } - - protected void handlePolledBoilerReg50Data(ModbusRegisterArray registers) { - // logger.trace("BoilerReg50 block received, size: {}", registers.size()); - - BoilerReg50Block block = boilerReg50BlockParser.parse(registers); - - // BoilerReg50 group - updateState(channelUID(GROUP_BOILER_REG50, CHANNEL_BOILER_MAXIMUM_BOILER_TEMPERATURE), - getScaled(block.boilerMaximumBoilerTemperature, CELSIUS, -1.0)); - resetCommunicationError(); - } - - /** - * @param bridgeStatusInfo - */ - @Override - public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { - super.bridgeStatusChanged(bridgeStatusInfo); - - if (bridgeStatusInfo.getStatus() == ThingStatus.ONLINE) { - startUp(); - } else if (bridgeStatusInfo.getStatus() == ThingStatus.OFFLINE) { - tearDown(); - } - } - - /** - * Handle errors received during communication - */ - 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 = 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 - * - * @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/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/BufferHandler.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/BufferHandler.java deleted file mode 100644 index f809497d17dab..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/BufferHandler.java +++ /dev/null @@ -1,541 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.handler; - -import static org.openhab.binding.modbus.lambda.internal.LambdaBindingConstants.*; -import static org.openhab.core.library.unit.SIUnits.CELSIUS; -import static org.openhab.core.library.unit.Units.*; - -import java.util.Optional; - -import javax.measure.Unit; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.eclipse.jdt.annotation.Nullable; -import org.openhab.binding.modbus.handler.EndpointNotInitializedException; -import org.openhab.binding.modbus.handler.ModbusEndpointThingHandler; -import org.openhab.binding.modbus.lambda.internal.BufferConfiguration; -import org.openhab.binding.modbus.lambda.internal.dto.BufferBlock; -import org.openhab.binding.modbus.lambda.internal.dto.BufferReg50Block; -import org.openhab.binding.modbus.lambda.internal.parser.BufferBlockParser; -import org.openhab.binding.modbus.lambda.internal.parser.BufferReg50BlockParser; -import org.openhab.core.io.transport.modbus.AsyncModbusFailure; -import org.openhab.core.io.transport.modbus.ModbusCommunicationInterface; -import org.openhab.core.io.transport.modbus.ModbusReadFunctionCode; -import org.openhab.core.io.transport.modbus.ModbusReadRequestBlueprint; -import org.openhab.core.io.transport.modbus.ModbusRegisterArray; -import org.openhab.core.io.transport.modbus.ModbusWriteRegisterRequestBlueprint; -import org.openhab.core.io.transport.modbus.ModbusWriteRequestBlueprint; -import org.openhab.core.io.transport.modbus.PollTask; -import org.openhab.core.library.types.DecimalType; -import org.openhab.core.library.types.QuantityType; -import org.openhab.core.thing.Bridge; -import org.openhab.core.thing.ChannelUID; -import org.openhab.core.thing.Thing; -import org.openhab.core.thing.ThingStatus; -import org.openhab.core.thing.ThingStatusDetail; -import org.openhab.core.thing.ThingStatusInfo; -import org.openhab.core.thing.binding.BaseThingHandler; -import org.openhab.core.thing.binding.ThingHandler; -import org.openhab.core.types.Command; -import org.openhab.core.types.RefreshType; -import org.openhab.core.types.State; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The {@link BufferHandler} 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 BufferHandler extends BaseThingHandler { - - public abstract class AbstractBasePoller { - - private final Logger logger = LoggerFactory.getLogger(BufferHandler.class); - - private volatile @Nullable PollTask pollTask; - - public synchronized void unregisterPollTask() { - PollTask task = pollTask; - if (task == null) { - return; - } - - ModbusCommunicationInterface mycomms = BufferHandler.this.comms; - if (mycomms != null) { - mycomms.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 Address: {}", address); - - ModbusCommunicationInterface mycomms = BufferHandler.this.comms; - BufferConfiguration myconfig = BufferHandler.this.config; - if (myconfig == null || mycomms == null) { - throw new IllegalStateException("registerPollTask called without proper configuration"); - } - - ModbusReadRequestBlueprint request = new ModbusReadRequestBlueprint(getSlaveId(), readFunctionCode, address, - length, myconfig.getMaxTries()); - - long refreshMillis = myconfig.getRefreshMillis(); - - pollTask = mycomms.registerRegularPoll(request, refreshMillis, 1000, result -> { - result.getRegisters().ifPresent(this::handlePolledData); - if (getThing().getStatus() != ThingStatus.ONLINE) { - updateStatus(ThingStatus.ONLINE); - } - }, BufferHandler.this::handleReadError); - } - - public synchronized void poll() { - PollTask task = pollTask; - ModbusCommunicationInterface mycomms = BufferHandler.this.comms; - if (task != null && mycomms != null) { - mycomms.submitOneTimePoll(task.getRequest(), task.getResultCallback(), task.getFailureCallback()); - } - } - - protected abstract void handlePolledData(ModbusRegisterArray registers); - } - - /** - * Logger instance - */ - private final Logger logger = LoggerFactory.getLogger(BufferHandler.class); - - /** - * Configuration instance - */ - protected @Nullable BufferConfiguration config = null; - /** - * Parser used to convert incoming raw messages into system blocks - * private final SystemInfromationBlockParser systemInformationBlockParser = new SystemInfromationBlockParser(); - */ - /** - * Parsers used to convert incoming raw messages into state blocks - */ - - private final BufferBlockParser bufferBlockParser = new BufferBlockParser(); - private final BufferReg50BlockParser bufferReg50BlockParser = new BufferReg50BlockParser(); - - /** - * These are the tasks used to poll the device - */ - private volatile @Nullable AbstractBasePoller bufferPoller = null; - private volatile @Nullable AbstractBasePoller bufferReg50Poller = null; - /** - * Communication interface to the slave endpoint we're connecting to - */ - protected volatile @Nullable ModbusCommunicationInterface comms = null; - /** - * This is the slave id, we store this once initialization is complete - */ - private volatile int slaveId; - - /** - * Instances of this handler should get a reference to the modbus manager - * - * @param thing the thing to handle - */ - public BufferHandler(Thing thing) { - super(thing); - } - - /** - * @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) { - // loggertrace("187 writeInt16: Es wird geschrieben, Adresse: {} Wert: {}", address, shortValue); - BufferConfiguration myconfig = BufferHandler.this.config; - ModbusCommunicationInterface mycomms = BufferHandler.this.comms; - - if (myconfig == null || mycomms == null) { - throw new IllegalStateException("registerPollTask called without proper configuration"); - } - // big endian byte ordering - byte hi = (byte) (shortValue >> 8); - byte lo = (byte) shortValue; - ModbusRegisterArray data = new ModbusRegisterArray(hi, lo); - - // loggertrace("199 hi: {}, lo: {}", hi, lo); - ModbusWriteRegisterRequestBlueprint request = new ModbusWriteRegisterRequestBlueprint(slaveId, address, data, - true, myconfig.getMaxTries()); - - mycomms.submitOneTimeWrite(request, result -> { - if (hasConfigurationError()) { - return; - } - // loggertrace("Successful write, matching request {}", request); - BufferHandler.this.updateStatus(ThingStatus.ONLINE); - }, failure -> { - BufferHandler.this.handleWriteError(failure); - // loggertrace("Unsuccessful write, matching request {}", request); - }); - } - - /** - * @param command get the value of this command. - * @return short the value of the command as short - */ - private short getInt16Value(Command command) throws LambdaException { - if (command instanceof QuantityType quantityCommand) { - QuantityType c = quantityCommand.toUnit(WATT); - if (c != null) { - return c.shortValue(); - } else { - throw new LambdaException("Unsupported unit"); - } - } - if (command instanceof DecimalType c) { - return c.shortValue(); - } - throw new LambdaException("Unsupported command type"); - } - - private short getScaledInt16Value(Command command) throws LambdaException { - if (command instanceof QuantityType quantityCommand) { - QuantityType c = quantityCommand.toUnit(CELSIUS); - if (c != null) { - return (short) (c.doubleValue() * 10); - } else { - throw new LambdaException("Unsupported unit"); - } - } - if (command instanceof DecimalType c) { - return (short) (c.doubleValue() * 10); - } - throw new LambdaException("Unsupported command type"); - } - - /** - * Handle incoming commands. - */ - @Override - public void handleCommand(ChannelUID channelUID, Command command) { - // loggertrace("283 handleCommand, channelUID: {} command {} ", channelUID, command); - if (RefreshType.REFRESH == command) { - String groupId = channelUID.getGroupId(); - if (groupId != null) { - AbstractBasePoller poller; - switch (groupId) { - - case GROUP_BUFFER: - poller = bufferPoller; - break; - case GROUP_BUFFER_REG50: - poller = bufferReg50Poller; - break; - default: - poller = null; - break; - } - if (poller != null) { - // loggertrace("Es wird gepollt }"); - poller.poll(); - } - } - } - } - - /** - * Initialization: Load the config object of the block Connect to the slave - * bridge Start the periodic polling - */ - @Override - public void initialize() { - config = getConfigAs(BufferConfiguration.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 polling1 - */ - private void startUp() { - if (comms != null) { - return; - } - - ModbusEndpointThingHandler slaveEndpointThingHandler = getEndpointThingHandler(); - if (slaveEndpointThingHandler == null) { - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, "Bridge is offline"); - return; - } - - try { - slaveId = slaveEndpointThingHandler.getSlaveId(); - - comms = slaveEndpointThingHandler.getCommunicationInterface(); - } catch (EndpointNotInitializedException e) { - // this will be handled below as endpoint remains null - } - - if (comms == 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)); - return; - } - - if (config == null) { - logger.debug("Invalid comms/config/manager ref for Buffer handler"); - return; - } - - BufferConfiguration myconfig = BufferHandler.this.config; - - int baseadress = 3000 + 100 * myconfig.getSubindex(); - logger.debug("Buffer config.baseadress = {} ", baseadress); - - int reg50baseadress = baseadress + 50; - logger.debug("BufferrMT baseadress = {} ", reg50baseadress); - - if (bufferPoller == null) { - AbstractBasePoller poller = new AbstractBasePoller() { - @Override - protected void handlePolledData(ModbusRegisterArray registers) { - handlePolledBufferData(registers); - } - }; - - poller.registerPollTask(baseadress, 4, ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS); - - bufferPoller = poller; - } - if (bufferReg50Poller == null) { - AbstractBasePoller poller = new AbstractBasePoller() { - @Override - protected void handlePolledData(ModbusRegisterArray registers) { - handlePolledBufferReg50Data(registers); - } - }; - - poller.registerPollTask(reg50baseadress, 1, ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS); - bufferReg50Poller = poller; - } - - updateStatus(ThingStatus.UNKNOWN); - } - - /** - * Dispose the binding correctly - */ - @Override - public void dispose() { - tearDown(); - } - - /** - * Unregister the poll tasks and release the endpoint reference - */ - private void tearDown() { - - AbstractBasePoller poller = bufferPoller; - - poller = bufferPoller; - if (poller != null) { - poller.unregisterPollTask(); - bufferPoller = null; - } - poller = bufferReg50Poller; - if (poller != null) { - poller.unregisterPollTask(); - bufferReg50Poller = null; - } - - comms = null; - } - - /** - * 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 thingHandler) { - return thingHandler; - } else { - throw new IllegalStateException("Unexpected bridge handler: " + handler.toString()); - } - } - - protected State getScaled(Number value, Unit unit, Double pow) { - // loggertrace("505 value: {}", value.intValue()); - double factor = Math.pow(10, pow); - return QuantityType.valueOf(value.doubleValue() * factor, unit); - } - - protected State getUnscaled(Number value, Unit unit) { - return QuantityType.valueOf(value.doubleValue(), 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 QuantityType.valueOf(value, KILOWATT_HOUR); - } - - /** - * These methods are 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 handlePolledBufferData(ModbusRegisterArray registers) { - // loggertrace("Buffer block received, size: {}", registers.size()); - - BufferBlock block = bufferBlockParser.parse(registers); - - // Buffer group - updateState(channelUID(GROUP_BUFFER, CHANNEL_BUFFER_ERROR_NUMBER), new DecimalType(block.bufferErrorNumber)); - updateState(channelUID(GROUP_BUFFER, CHANNEL_BUFFER_OPERATING_STATE), - new DecimalType(block.bufferOperatingState)); - updateState(channelUID(GROUP_BUFFER, CHANNEL_BUFFER_ACTUAL_HIGH_TEMPERATURE), - getScaled(block.bufferActualHighTemperature, CELSIUS, -1.0)); - updateState(channelUID(GROUP_BUFFER, CHANNEL_BUFFER_ACTUAL_LOW_TEMPERATURE), - getScaled(block.bufferActualLowTemperature, CELSIUS, -1.0)); - resetCommunicationError(); - } - - protected void handlePolledBufferReg50Data(ModbusRegisterArray registers) { - // loggertrace("BufferReg50 block received, size: {}", registers.size()); - - BufferReg50Block block = bufferReg50BlockParser.parse(registers); - - // BufferReg50 group - updateState(channelUID(GROUP_BUFFER_REG50, CHANNEL_BUFFER_MAXIMUM_BOILER_TEMPERATURE), - getScaled(block.bufferMaximumBufferTemperature, CELSIUS, -1.0)); - resetCommunicationError(); - } - - /** - * @param bridgeStatusInfo - */ - @Override - public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { - super.bridgeStatusChanged(bridgeStatusInfo); - - if (bridgeStatusInfo.getStatus() == ThingStatus.ONLINE) { - startUp(); - } else if (bridgeStatusInfo.getStatus() == ThingStatus.OFFLINE) { - tearDown(); - } - } - - /** - * Handle errors received during communication - */ - 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 = 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 - * - * @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/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/GeneralHandler.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/GeneralHandler.java deleted file mode 100644 index a17e608b5ace4..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/GeneralHandler.java +++ /dev/null @@ -1,568 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.handler; - -import static org.openhab.binding.modbus.lambda.internal.LambdaBindingConstants.*; -import static org.openhab.core.library.unit.SIUnits.CELSIUS; -import static org.openhab.core.library.unit.Units.*; - -import java.util.Optional; - -import javax.measure.Unit; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.eclipse.jdt.annotation.Nullable; -import org.openhab.binding.modbus.handler.EndpointNotInitializedException; -import org.openhab.binding.modbus.handler.ModbusEndpointThingHandler; -import org.openhab.binding.modbus.lambda.internal.GeneralConfiguration; -import org.openhab.binding.modbus.lambda.internal.dto.AmbientBlock; -import org.openhab.binding.modbus.lambda.internal.dto.EManagerBlock; -import org.openhab.binding.modbus.lambda.internal.parser.AmbientBlockParser; -import org.openhab.binding.modbus.lambda.internal.parser.EManagerBlockParser; -import org.openhab.core.io.transport.modbus.AsyncModbusFailure; -import org.openhab.core.io.transport.modbus.ModbusCommunicationInterface; -import org.openhab.core.io.transport.modbus.ModbusReadFunctionCode; -import org.openhab.core.io.transport.modbus.ModbusReadRequestBlueprint; -import org.openhab.core.io.transport.modbus.ModbusRegisterArray; -import org.openhab.core.io.transport.modbus.ModbusWriteRegisterRequestBlueprint; -import org.openhab.core.io.transport.modbus.ModbusWriteRequestBlueprint; -import org.openhab.core.io.transport.modbus.PollTask; -import org.openhab.core.library.types.DecimalType; -import org.openhab.core.library.types.QuantityType; -import org.openhab.core.thing.Bridge; -import org.openhab.core.thing.ChannelUID; -import org.openhab.core.thing.Thing; -import org.openhab.core.thing.ThingStatus; -import org.openhab.core.thing.ThingStatusDetail; -import org.openhab.core.thing.ThingStatusInfo; -import org.openhab.core.thing.binding.BaseThingHandler; -import org.openhab.core.thing.binding.ThingHandler; -import org.openhab.core.types.Command; -import org.openhab.core.types.RefreshType; -import org.openhab.core.types.State; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The {@link GeneralHandler} 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 GeneralHandler extends BaseThingHandler { - - public abstract class AbstractBasePoller { - - private final Logger logger = LoggerFactory.getLogger(GeneralHandler.class); - - private volatile @Nullable PollTask pollTask; - - public synchronized void unregisterPollTask() { - PollTask task = pollTask; - if (task == null) { - return; - } - - ModbusCommunicationInterface mycomms = GeneralHandler.this.comms; - if (mycomms != null) { - mycomms.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 Address: {}", address); - - ModbusCommunicationInterface mycomms = GeneralHandler.this.comms; - GeneralConfiguration myconfig = GeneralHandler.this.config; - if (myconfig == null || mycomms == null) { - throw new IllegalStateException("registerPollTask called without proper configuration"); - } - - ModbusReadRequestBlueprint request = new ModbusReadRequestBlueprint(getSlaveId(), readFunctionCode, address, - length, myconfig.getMaxTries()); - - long refreshMillis = myconfig.getRefreshMillis(); - - pollTask = mycomms.registerRegularPoll(request, refreshMillis, 1000, result -> { - result.getRegisters().ifPresent(this::handlePolledData); - if (getThing().getStatus() != ThingStatus.ONLINE) { - updateStatus(ThingStatus.ONLINE); - } - }, GeneralHandler.this::handleReadError); - } - - public synchronized void poll() { - PollTask task = pollTask; - ModbusCommunicationInterface mycomms = GeneralHandler.this.comms; - if (task != null && mycomms != null) { - mycomms.submitOneTimePoll(task.getRequest(), task.getResultCallback(), task.getFailureCallback()); - } - } - - protected abstract void handlePolledData(ModbusRegisterArray registers); - } - - /** - * Logger instance - */ - private final Logger logger = LoggerFactory.getLogger(GeneralHandler.class); - - /** - * Configuration instance - */ - protected @Nullable GeneralConfiguration config = null; - /** - * Parser used to convert incoming raw messages into system blocks - * private final SystemInfromationBlockParser systemInformationBlockParser = new SystemInfromationBlockParser(); - */ - /** - * Parsers used to convert incoming raw messages into state blocks - */ - private final AmbientBlockParser ambientBlockParser = new AmbientBlockParser(); - private final EManagerBlockParser emanagerBlockParser = new EManagerBlockParser(); - - /** - * These are the tasks used to poll the device - */ - private volatile @Nullable AbstractBasePoller ambientPoller = null; - private volatile @Nullable AbstractBasePoller emanagerPoller = null; - - /** - * Communication interface to the slave endpoint we're connecting to - */ - protected volatile @Nullable ModbusCommunicationInterface comms = null; - /** - * This is the slave id, we store this once initialization is complete - */ - private volatile int slaveId; - - /** - * Instances of this handler should get a reference to the modbus manager - * - * @param thing the thing to handle - */ - public GeneralHandler(Thing thing) { - super(thing); - } - - /** - * @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) { - // loggertrace("187 writeInt16: Es wird geschrieben, Adresse: {} Wert: {}", address, shortValue); - GeneralConfiguration myconfig = GeneralHandler.this.config; - ModbusCommunicationInterface mycomms = GeneralHandler.this.comms; - - if (myconfig == null || mycomms == null) { - throw new IllegalStateException("registerPollTask called without proper configuration"); - } - // big endian byte ordering - byte hi = (byte) (shortValue >> 8); - byte lo = (byte) shortValue; - ModbusRegisterArray data = new ModbusRegisterArray(hi, lo); - - // loggertrace("199 hi: {}, lo: {}", hi, lo); - ModbusWriteRegisterRequestBlueprint request = new ModbusWriteRegisterRequestBlueprint(slaveId, address, data, - true, myconfig.getMaxTries()); - - mycomms.submitOneTimeWrite(request, result -> { - if (hasConfigurationError()) { - return; - } - // loggertrace("Successful write, matching request {}", request); - GeneralHandler.this.updateStatus(ThingStatus.ONLINE); - }, failure -> { - GeneralHandler.this.handleWriteError(failure); - // loggertrace("Unsuccessful write, matching request {}", request); - }); - } - - /** - * @param command get the value of this command. - * @return short the value of the command as short - */ - private short getInt16Value(Command command) throws LambdaException { - if (command instanceof QuantityType quantityCommand) { - QuantityType c = quantityCommand.toUnit(WATT); - if (c != null) { - return c.shortValue(); - } else { - throw new LambdaException("Unsupported unit"); - } - } - if (command instanceof DecimalType c) { - return c.shortValue(); - } - throw new LambdaException("Unsupported command type"); - } - - private short getScaledInt16Value(Command command) throws LambdaException { - if (command instanceof QuantityType quantityCommand) { - QuantityType c = quantityCommand.toUnit(CELSIUS); - if (c != null) { - return (short) (c.doubleValue() * 10); - } else { - throw new LambdaException("Unsupported unit"); - } - } - if (command instanceof DecimalType c) { - return (short) (c.doubleValue() * 10); - } - throw new LambdaException("Unsupported command type"); - } - - /** - * Handle incoming commands. - */ - @Override - public void handleCommand(ChannelUID channelUID, Command command) { - // loggertrace("283 handleCommand, channelUID: {} command {} ", channelUID, command); - if (RefreshType.REFRESH == command) { - String groupId = channelUID.getGroupId(); - if (groupId != null) { - AbstractBasePoller poller; - switch (groupId) { - case GROUP_GENERAL_AMBIENT: - poller = ambientPoller; - break; - case GROUP_GENERAL_EMANAGER: - poller = emanagerPoller; - break; - default: - poller = null; - break; - } - if (poller != null) { - // loggertrace("336 Es wird gepollt }"); - poller.poll(); - } - } - } else { - // loggertrace("341 handleCommand: Es wird geschrieben, GroupID: {}, command {}", channelUID.getGroupId(), - // command); - try { - - // loggertrace("345 vor EMANAGER"); - if (GROUP_GENERAL_EMANAGER.equals(channelUID.getGroupId())) { - - // loggertrace("330 im EMANAGER channelUID {} ", channelUID.getIdWithoutGroup()); - switch (channelUID.getIdWithoutGroup()) { - - case CHANNEL_ACTUAL_POWER: - - // loggertrace("336 command: {}", command); - writeInt16(102, getInt16Value(command)); - break; - - } - } - - } catch (LambdaException error) { - if (hasConfigurationError() || getThing().getStatus() == ThingStatus.OFFLINE) { - return; - } - String cls = error.getClass().getName(); - String msg = error.getMessage(); - - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, - String.format("Error with: %s: %s", cls, msg)); - } - } - } - - /** - * Initialization: Load the config object of the block Connect to the slave - * bridge Start the periodic polling - */ - @Override - public void initialize() { - config = getConfigAs(GeneralConfiguration.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 polling1 - */ - private void startUp() { - if (comms != null) { - return; - } - - ModbusEndpointThingHandler slaveEndpointThingHandler = getEndpointThingHandler(); - if (slaveEndpointThingHandler == null) { - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, "Bridge is offline"); - return; - } - - try { - slaveId = slaveEndpointThingHandler.getSlaveId(); - - comms = slaveEndpointThingHandler.getCommunicationInterface(); - } catch (EndpointNotInitializedException e) { - // this will be handled below as endpoint remains null - } - - if (comms == 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)); - return; - } - - if (config == null) { - logger.debug("Invalid comms/config/manager ref for lambda general handler"); - return; - } - - if (ambientPoller == null) { - AbstractBasePoller poller = new AbstractBasePoller() { - @Override - protected void handlePolledData(ModbusRegisterArray registers) { - handlePolledAmbientData(registers); - } - }; - poller.registerPollTask(0, 5, ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS); - ambientPoller = poller; - } - - if (emanagerPoller == null) { - AbstractBasePoller poller = new AbstractBasePoller() { - @Override - protected void handlePolledData(ModbusRegisterArray registers) { - handlePolledEManagerData(registers); - } - }; - poller.registerPollTask(100, 5, ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS); - emanagerPoller = poller; - } - - updateStatus(ThingStatus.UNKNOWN); - } - - /** - * Dispose the binding correctly - */ - @Override - public void dispose() { - tearDown(); - } - - /** - * Unregister the poll tasks and release the endpoint reference - */ - private void tearDown() { - - AbstractBasePoller poller = ambientPoller; - if (poller != null) { - poller.unregisterPollTask(); - ambientPoller = null; - } - - poller = emanagerPoller; - if (poller != null) { - poller.unregisterPollTask(); - emanagerPoller = null; - } - - comms = null; - } - - /** - * 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 thingHandler) { - return thingHandler; - } else { - throw new IllegalStateException("Unexpected bridge handler: " + handler.toString()); - } - } - - protected State getScaled(Number value, Unit unit, Double pow) { - // loggertrace("505 value: {}", value.intValue()); - double factor = Math.pow(10, pow); - return QuantityType.valueOf(value.doubleValue() * factor, unit); - } - - protected State getUnscaled(Number value, Unit unit) { - return QuantityType.valueOf(value.doubleValue(), 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 QuantityType.valueOf(value, KILOWATT_HOUR); - } - - /** - * These methods are 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 handlePolledAmbientData(ModbusRegisterArray registers) { - // loggertrace("Ambient block received, size: {}", registers.size()); - - // Ambient group - AmbientBlock block = ambientBlockParser.parse(registers); - - updateState(channelUID(GROUP_GENERAL_AMBIENT, CHANNEL_AMBIENT_ERROR_NUMBER), - new DecimalType(block.ambientErrorNumber)); - updateState(channelUID(GROUP_GENERAL_AMBIENT, CHANNEL_AMBIENT_OPERATING_STATE), - new DecimalType(block.ambientOperatingState)); - updateState(channelUID(GROUP_GENERAL_AMBIENT, CHANNEL_ACTUAL_AMBIENT_TEMPERATURE), - getScaled(block.actualAmbientTemperature, CELSIUS, -1.0)); - updateState(channelUID(GROUP_GENERAL_AMBIENT, CHANNEL_AVERAGE_AMBIENT_TEMPERATURE), - getScaled(block.averageAmbientTemperature, CELSIUS, -1.0)); - updateState(channelUID(GROUP_GENERAL_AMBIENT, CHANNEL_CALCULATED_AMBIENT_TEMPERATURE), - getScaled(block.calculatedAmbientTemperature, CELSIUS, -1.0)); - resetCommunicationError(); - } - - protected void handlePolledEManagerData(ModbusRegisterArray registers) { - // loggertrace("EManager block received, size: {}", registers.size()); - - // EManager group - EManagerBlock block = emanagerBlockParser.parse(registers); - updateState(channelUID(GROUP_GENERAL_EMANAGER, CHANNEL_EMANAGER_ERROR_NUMBER), - new DecimalType(block.emanagerErrorNumber)); - updateState(channelUID(GROUP_GENERAL_EMANAGER, CHANNEL_EMANAGER_OPERATING_STATE), - new DecimalType(block.emanagerOperatingState)); - updateState(channelUID(GROUP_GENERAL_EMANAGER, CHANNEL_ACTUAL_POWER_CONSUMPTION), - getUnscaled(block.actualPowerConsumption, WATT)); - updateState(channelUID(GROUP_GENERAL_EMANAGER, CHANNEL_ACTUAL_POWER), getUnscaled(block.actualPower, WATT)); - updateState(channelUID(GROUP_GENERAL_EMANAGER, CHANNEL_POWER_CONSUMPTION_SETPOINT), - getUnscaled(block.powerConsumptionSetpoint, WATT)); - - resetCommunicationError(); - } - - /** - * @param bridgeStatusInfo - */ - @Override - public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { - super.bridgeStatusChanged(bridgeStatusInfo); - - if (bridgeStatusInfo.getStatus() == ThingStatus.ONLINE) { - startUp(); - } else if (bridgeStatusInfo.getStatus() == ThingStatus.OFFLINE) { - tearDown(); - } - } - - /** - * Handle errors received during communication - */ - 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 = 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 - * - * @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/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/HeatingCircuitHandler.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/HeatingCircuitHandler.java deleted file mode 100644 index baf03565d5132..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/HeatingCircuitHandler.java +++ /dev/null @@ -1,652 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.handler; - -import static org.openhab.binding.modbus.lambda.internal.LambdaBindingConstants.*; -import static org.openhab.core.library.unit.SIUnits.CELSIUS; -import static org.openhab.core.library.unit.Units.*; - -import java.util.Optional; - -import javax.measure.Unit; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.eclipse.jdt.annotation.Nullable; -import org.openhab.binding.modbus.handler.EndpointNotInitializedException; -import org.openhab.binding.modbus.handler.ModbusEndpointThingHandler; -import org.openhab.binding.modbus.lambda.internal.HeatingCircuitConfiguration; -import org.openhab.binding.modbus.lambda.internal.dto.HeatingCircuitBlock; -import org.openhab.binding.modbus.lambda.internal.dto.HeatingCircuitReg50Block; -import org.openhab.binding.modbus.lambda.internal.parser.HeatingCircuitBlockParser; -import org.openhab.binding.modbus.lambda.internal.parser.HeatingCircuitReg50BlockParser; -import org.openhab.core.io.transport.modbus.AsyncModbusFailure; -import org.openhab.core.io.transport.modbus.ModbusCommunicationInterface; -import org.openhab.core.io.transport.modbus.ModbusReadFunctionCode; -import org.openhab.core.io.transport.modbus.ModbusReadRequestBlueprint; -import org.openhab.core.io.transport.modbus.ModbusRegisterArray; -import org.openhab.core.io.transport.modbus.ModbusWriteRegisterRequestBlueprint; -import org.openhab.core.io.transport.modbus.ModbusWriteRequestBlueprint; -import org.openhab.core.io.transport.modbus.PollTask; -import org.openhab.core.library.types.DecimalType; -import org.openhab.core.library.types.QuantityType; -import org.openhab.core.thing.Bridge; -import org.openhab.core.thing.ChannelUID; -import org.openhab.core.thing.Thing; -import org.openhab.core.thing.ThingStatus; -import org.openhab.core.thing.ThingStatusDetail; -import org.openhab.core.thing.ThingStatusInfo; -import org.openhab.core.thing.binding.BaseThingHandler; -import org.openhab.core.thing.binding.ThingHandler; -import org.openhab.core.types.Command; -import org.openhab.core.types.RefreshType; -import org.openhab.core.types.State; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The {@link HeatingCircuitHandler} 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 HeatingCircuitHandler extends BaseThingHandler { - - public abstract class AbstractBasePoller { - - private final Logger logger = LoggerFactory.getLogger(HeatingCircuitHandler.class); - - private volatile @Nullable PollTask pollTask; - - public synchronized void unregisterPollTask() { - PollTask task = pollTask; - if (task == null) { - return; - } - - ModbusCommunicationInterface mycomms = HeatingCircuitHandler.this.comms; - if (mycomms != null) { - mycomms.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 Address: {}", address); - - ModbusCommunicationInterface mycomms = HeatingCircuitHandler.this.comms; - HeatingCircuitConfiguration myconfig = HeatingCircuitHandler.this.config; - if (myconfig == null || mycomms == null) { - throw new IllegalStateException("registerPollTask called without proper configuration"); - } - - ModbusReadRequestBlueprint request = new ModbusReadRequestBlueprint(getSlaveId(), readFunctionCode, address, - length, myconfig.getMaxTries()); - - long refreshMillis = myconfig.getRefreshMillis(); - - pollTask = mycomms.registerRegularPoll(request, refreshMillis, 1000, result -> { - result.getRegisters().ifPresent(this::handlePolledData); - if (getThing().getStatus() != ThingStatus.ONLINE) { - updateStatus(ThingStatus.ONLINE); - } - }, HeatingCircuitHandler.this::handleReadError); - } - - public synchronized void poll() { - PollTask task = pollTask; - ModbusCommunicationInterface mycomms = HeatingCircuitHandler.this.comms; - if (task != null && mycomms != null) { - mycomms.submitOneTimePoll(task.getRequest(), task.getResultCallback(), task.getFailureCallback()); - } - } - - protected abstract void handlePolledData(ModbusRegisterArray registers); - } - - /** - * Logger instance - */ - private final Logger logger = LoggerFactory.getLogger(HeatingCircuitHandler.class); - - /** - * Configuration instance - */ - protected @Nullable HeatingCircuitConfiguration config = null; - /** - * Parser used to convert incoming raw messages into system blocks - * private final SystemInfromationBlockParser systemInformationBlockParser = new SystemInfromationBlockParser(); - */ - /** - * Parsers used to convert incoming raw messages into state blocks - */ - - private final HeatingCircuitBlockParser heatingBlockParser = new HeatingCircuitBlockParser(); - private final HeatingCircuitReg50BlockParser heatingReg50BlockParser = new HeatingCircuitReg50BlockParser(); - - /** - * These are the tasks used to poll the device - */ - - private volatile @Nullable AbstractBasePoller heatingPoller = null; - private volatile @Nullable AbstractBasePoller heatingReg50Poller = null; - /** - * Communication interface to the slave endpoint we're connecting to - */ - protected volatile @Nullable ModbusCommunicationInterface comms = null; - /** - * This is the slave id, we store this once initialization is complete - */ - private volatile int slaveId; - - /** - * Instances of this handler should get a reference to the modbus manager - * - * @param thing the thing to handle - */ - public HeatingCircuitHandler(Thing thing) { - super(thing); - } - - /** - * @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) { - // loggertrace("187 writeInt16: Es wird geschrieben, Adresse: {} Wert: {}", address, shortValue); - HeatingCircuitConfiguration myconfig = HeatingCircuitHandler.this.config; - - ModbusCommunicationInterface mycomms = HeatingCircuitHandler.this.comms; - - if (myconfig == null || mycomms == null) { - throw new IllegalStateException("registerPollTask called without proper configuration"); - } - // big endian byte ordering - byte hi = (byte) (shortValue >> 8); - byte lo = (byte) shortValue; - ModbusRegisterArray data = new ModbusRegisterArray(hi, lo); - - // loggertrace("199 hi: {}, lo: {}", hi, lo); - ModbusWriteRegisterRequestBlueprint request = new ModbusWriteRegisterRequestBlueprint(slaveId, address, data, - true, myconfig.getMaxTries()); - - mycomms.submitOneTimeWrite(request, result -> { - if (hasConfigurationError()) { - return; - } - // loggertrace("Successful write, matching request {}", request); - HeatingCircuitHandler.this.updateStatus(ThingStatus.ONLINE); - }, failure -> { - HeatingCircuitHandler.this.handleWriteError(failure); - // loggertrace("Unsuccessful write, matching request {}", request); - }); - } - - /** - * @param command get the value of this command. - * @return short the value of the command as short - */ - private short getInt16Value(Command command) throws LambdaException { - if (command instanceof QuantityType quantityCommand) { - QuantityType c = quantityCommand.toUnit(WATT); - if (c != null) { - return c.shortValue(); - } else { - throw new LambdaException("Unsupported unit"); - } - } - if (command instanceof DecimalType c) { - return c.shortValue(); - } - throw new LambdaException("Unsupported command type"); - } - - private short getScaledInt16Value(Command command) throws LambdaException { - if (command instanceof QuantityType quantityCommand) { - QuantityType c = quantityCommand.toUnit(CELSIUS); - if (c != null) { - return (short) (c.doubleValue() * 10); - } else { - throw new LambdaException("Unsupported unit"); - } - } - if (command instanceof DecimalType c) { - return (short) (c.doubleValue() * 10); - } - throw new LambdaException("Unsupported command type"); - } - - /** - * Handle incoming commands. - */ - @Override - public void handleCommand(ChannelUID channelUID, Command command) { - // loggertrace("283 handleCommand, channelUID: {} command {} ", channelUID, command); - if (RefreshType.REFRESH == command) { - String groupId = channelUID.getGroupId(); - if (groupId != null) { - AbstractBasePoller poller; - switch (groupId) { - case GROUP_HEATINGCIRCUIT: - poller = heatingPoller; - break; - case GROUP_HEATINGCIRCUIT_REG50: - poller = heatingReg50Poller; - break; - default: - poller = null; - break; - } - if (poller != null) { - // loggertrace("336 Es wird gepollt }"); - poller.poll(); - } - } - } else { - // loggertrace("341 handleCommand: Es wird geschrieben, GroupID: {}, command {}", channelUID.getGroupId(), - // command); - try { - - // loggertrace("345 vor EMANAGER"); - if (GROUP_GENERAL_EMANAGER.equals(channelUID.getGroupId())) { - - // loggertrace("330 im EMANAGER channelUID {} ", channelUID.getIdWithoutGroup()); - switch (channelUID.getIdWithoutGroup()) { - - case CHANNEL_ACTUAL_POWER: - - // loggertrace("336 command: {}", command); - writeInt16(102, getInt16Value(command)); - break; - - } - } - - if (GROUP_HEATINGCIRCUIT.equals(channelUID.getGroupId())) { - // loggertrace("387 im HEATINGCIRCUI1 channelUID {} ", channelUID.getIdWithoutGroup()); - - switch (channelUID.getIdWithoutGroup()) { - - case CHANNEL_HEATINGCIRCUIT_ROOM_DEVICE_TEMPERATURE: - // loggertrace("393 command: {}", command); - writeInt16(5004, getScaledInt16Value(command)); - break; - case CHANNEL_HEATINGCIRCUIT_SETPOINT_FLOW_LINE_TEMPERATURE: - // loggertrace("393 command: {}", command); - writeInt16(5005, getScaledInt16Value(command)); - break; - case CHANNEL_HEATINGCIRCUIT_OPERATING_MODE: - // loggertrace("403 command: {}", command); - writeInt16(5006, getInt16Value(command)); - break; - - } - } - - if (GROUP_HEATINGCIRCUIT_REG50.equals(channelUID.getGroupId())) { - // loggertrace("411 im HEATINGCIRCUI1 channelUID {} ", channelUID.getIdWithoutGroup()); - - switch (channelUID.getIdWithoutGroup()) { - - case CHANNEL_HEATINGCIRCUIT_OFFSET_FLOW_LINE_TEMPERATURE: - - // loggertrace("418 command: {}", command); - writeInt16(5050, getScaledInt16Value(command)); - break; - case CHANNEL_HEATINGCIRCUIT_ROOM_HEATING_TEMPERATURE: - - // loggertrace("233 command: {}", command); - writeInt16(5051, getScaledInt16Value(command)); - break; - case CHANNEL_HEATINGCIRCUIT_ROOM_COOLING_TEMPERATURE: - - // loggertrace("427 command: {}", command); - writeInt16(5052, getScaledInt16Value(command)); - break; - - } - - } - - if (GROUP_HEATPUMP_REG50.equals(channelUID.getGroupId())) { - // loggertrace("439 im GROUP_HEATPUMP_REG50 channelUID {} ", channelUID.getIdWithoutGroup()); - - switch (channelUID.getIdWithoutGroup()) { - - case CHANNEL_HEATPUMP_SET_ERROR_QUIT: - - // loggertrace("445 Heatpumpseterrorquit command: {}", command); - writeInt16(1050, getScaledInt16Value(command)); - break; - - } - } - } catch (LambdaException error) { - if (hasConfigurationError() || getThing().getStatus() == ThingStatus.OFFLINE) { - return; - } - String cls = error.getClass().getName(); - String msg = error.getMessage(); - - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, - String.format("Error with: %s: %s", cls, msg)); - } - } - } - - /** - * Initialization: Load the config object of the block Connect to the slave - * bridge Start the periodic polling - */ - @Override - public void initialize() { - config = getConfigAs(HeatingCircuitConfiguration.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 polling1 - */ - private void startUp() { - if (comms != null) { - return; - } - - ModbusEndpointThingHandler slaveEndpointThingHandler = getEndpointThingHandler(); - if (slaveEndpointThingHandler == null) { - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, "Bridge is offline"); - return; - } - - try { - slaveId = slaveEndpointThingHandler.getSlaveId(); - - comms = slaveEndpointThingHandler.getCommunicationInterface(); - } catch (EndpointNotInitializedException e) { - // this will be handled below as endpoint remains null - } - - if (comms == 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)); - return; - } - - if (config == null) { - logger.debug("Invalid comms/config/manager ref for lambda heatpump handler"); - return; - } - - HeatingCircuitConfiguration myconfig = HeatingCircuitHandler.this.config; - - int baseadress = 5000 + 100 * myconfig.getSubindex(); - int subind = myconfig.getSubindex(); - - logger.debug("Heating Circuit Baseadress = {} ", baseadress); - logger.debug("Heating Circuit Subindex vorher = {} ", subind); - // myconfig.setSubindex(3); - // subind = myconfig.getSubindex(); - // logger.debug("Heating Circuit Subindex nachher = {} ", subind); - - int reg50baseadress = baseadress + 50; - logger.debug("Heating Circuit Reg 50 Baseadress = {} ", reg50baseadress); - - if (heatingPoller == null) { - AbstractBasePoller poller = new AbstractBasePoller() { - @Override - protected void handlePolledData(ModbusRegisterArray registers) { - handlePolledHeatingData(registers); - } - }; - - poller.registerPollTask(baseadress, 7, ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS); - // loggertrace("Poller Heating erzeugt"); - heatingPoller = poller; - } - if (heatingReg50Poller == null) { - AbstractBasePoller poller = new AbstractBasePoller() { - @Override - protected void handlePolledData(ModbusRegisterArray registers) { - handlePolledHeatingReg50Data(registers); - } - }; - - poller.registerPollTask(reg50baseadress, 3, ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS); - // loggertrace("Poller HeatingReg50 erzeugt"); - heatingReg50Poller = poller; - } - - updateStatus(ThingStatus.UNKNOWN); - } - - /** - * Dispose the binding correctly - */ - @Override - public void dispose() { - tearDown(); - } - - /** - * Unregister the poll tasks and release the endpoint reference - */ - private void tearDown() { - - AbstractBasePoller poller = heatingPoller; - if (poller != null) { - logger.debug("Unregistering heatingcircuitPoller from ModbusManager"); - poller.unregisterPollTask(); - heatingPoller = null; - } - - poller = heatingReg50Poller; - if (poller != null) { - logger.debug("Unregistering heatingReg50Poller from ModbusManager"); - poller.unregisterPollTask(); - heatingReg50Poller = null; - } - comms = null; - } - - /** - * 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 thingHandler) { - return thingHandler; - } else { - throw new IllegalStateException("Unexpected bridge handler: " + handler.toString()); - } - } - - protected State getScaled(Number value, Unit unit, Double pow) { - // loggertrace("505 value: {}", value.intValue()); - double factor = Math.pow(10, pow); - return QuantityType.valueOf(value.doubleValue() * factor, unit); - } - - protected State getUnscaled(Number value, Unit unit) { - return QuantityType.valueOf(value.doubleValue(), 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 QuantityType.valueOf(value, KILOWATT_HOUR); - } - - /** - * These methods are 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 handlePolledHeatingData(ModbusRegisterArray registers) { - // loggertrace("Heating block received, size: {}", registers.size()); - - HeatingCircuitBlock block = heatingBlockParser.parse(registers); - - // HeatingCircuit1 group - - updateState(channelUID(GROUP_HEATINGCIRCUIT, CHANNEL_HEATINGCIRCUIT_ERROR_NUMBER), - new DecimalType(block.heatingcircuitErrorNumber)); - updateState(channelUID(GROUP_HEATINGCIRCUIT, CHANNEL_HEATINGCIRCUIT_OPERATING_STATE), - new DecimalType(block.heatingcircuitOperatingState)); - updateState(channelUID(GROUP_HEATINGCIRCUIT, CHANNEL_HEATINGCIRCUIT_FLOW_LINE_TEMPERATURE), - getScaled(block.heatingcircuitFlowLineTemperature, CELSIUS, -1.0)); - updateState(channelUID(GROUP_HEATINGCIRCUIT, CHANNEL_HEATINGCIRCUIT_RETURN_LINE_TEMPERATURE), - getScaled(block.heatingcircuitReturnLineTemperature, CELSIUS, -1.0)); - updateState(channelUID(GROUP_HEATINGCIRCUIT, CHANNEL_HEATINGCIRCUIT_ROOM_DEVICE_TEMPERATURE), - getScaled(block.heatingcircuitRoomDeviceTemperature, CELSIUS, -1.0)); - updateState(channelUID(GROUP_HEATINGCIRCUIT, CHANNEL_HEATINGCIRCUIT_SETPOINT_FLOW_LINE_TEMPERATURE), - getScaled(block.heatingcircuitSetpointFlowLineTemperature, CELSIUS, -1.0)); - updateState(channelUID(GROUP_HEATINGCIRCUIT, CHANNEL_HEATINGCIRCUIT_OPERATING_MODE), - new DecimalType(block.heatingcircuitOperatingMode)); - - resetCommunicationError(); - } - - protected void handlePolledHeatingReg50Data(ModbusRegisterArray registers) { - // loggertrace("HeatingCircuitReg50 block received, size: {}", registers.size()); - - HeatingCircuitReg50Block block = heatingReg50BlockParser.parse(registers); - - // HeatingCircuit1Settting group - - updateState(channelUID(GROUP_HEATINGCIRCUIT_REG50, CHANNEL_HEATINGCIRCUIT_OFFSET_FLOW_LINE_TEMPERATURE), - getScaled(block.heatingcircuitOffsetFlowLineTemperature, CELSIUS, -1.0)); - updateState(channelUID(GROUP_HEATINGCIRCUIT_REG50, CHANNEL_HEATINGCIRCUIT_ROOM_HEATING_TEMPERATURE), - getScaled(block.heatingcircuitRoomHeatingTemperature, CELSIUS, -1.0)); - updateState(channelUID(GROUP_HEATINGCIRCUIT_REG50, CHANNEL_HEATINGCIRCUIT_ROOM_COOLING_TEMPERATURE), - getScaled(block.heatingcircuitRoomCoolingTemperature, CELSIUS, -1.0)); - resetCommunicationError(); - } - - /** - * @param bridgeStatusInfo - */ - @Override - public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { - super.bridgeStatusChanged(bridgeStatusInfo); - - if (bridgeStatusInfo.getStatus() == ThingStatus.ONLINE) { - startUp(); - } else if (bridgeStatusInfo.getStatus() == ThingStatus.OFFLINE) { - tearDown(); - } - } - - /** - * Handle errors received during communication - */ - 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 = 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 - * - * @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/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/HeatpumpHandler.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/HeatpumpHandler.java deleted file mode 100644 index 46c36f4fc9ab6..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/HeatpumpHandler.java +++ /dev/null @@ -1,596 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.handler; - -import static org.openhab.binding.modbus.lambda.internal.LambdaBindingConstants.*; -import static org.openhab.core.library.unit.SIUnits.CELSIUS; -import static org.openhab.core.library.unit.Units.*; - -import java.util.Optional; - -import javax.measure.Unit; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.eclipse.jdt.annotation.Nullable; -import org.openhab.binding.modbus.handler.EndpointNotInitializedException; -import org.openhab.binding.modbus.handler.ModbusEndpointThingHandler; -import org.openhab.binding.modbus.lambda.internal.HeatpumpConfiguration; -import org.openhab.binding.modbus.lambda.internal.dto.HeatpumpBlock; -import org.openhab.binding.modbus.lambda.internal.dto.HeatpumpReg50Block; -import org.openhab.binding.modbus.lambda.internal.parser.HeatpumpBlockParser; -import org.openhab.binding.modbus.lambda.internal.parser.HeatpumpReg50BlockParser; -import org.openhab.core.io.transport.modbus.AsyncModbusFailure; -import org.openhab.core.io.transport.modbus.ModbusCommunicationInterface; -import org.openhab.core.io.transport.modbus.ModbusReadFunctionCode; -import org.openhab.core.io.transport.modbus.ModbusReadRequestBlueprint; -import org.openhab.core.io.transport.modbus.ModbusRegisterArray; -import org.openhab.core.io.transport.modbus.ModbusWriteRegisterRequestBlueprint; -import org.openhab.core.io.transport.modbus.ModbusWriteRequestBlueprint; -import org.openhab.core.io.transport.modbus.PollTask; -import org.openhab.core.library.types.DecimalType; -import org.openhab.core.library.types.QuantityType; -import org.openhab.core.thing.Bridge; -import org.openhab.core.thing.ChannelUID; -import org.openhab.core.thing.Thing; -import org.openhab.core.thing.ThingStatus; -import org.openhab.core.thing.ThingStatusDetail; -import org.openhab.core.thing.ThingStatusInfo; -import org.openhab.core.thing.binding.BaseThingHandler; -import org.openhab.core.thing.binding.ThingHandler; -import org.openhab.core.types.Command; -import org.openhab.core.types.RefreshType; -import org.openhab.core.types.State; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The {@link HeatpumpHandler} 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 HeatpumpHandler extends BaseThingHandler { - - public abstract class AbstractBasePoller { - - private final Logger logger = LoggerFactory.getLogger(HeatpumpHandler.class); - - private volatile @Nullable PollTask pollTask; - - public synchronized void unregisterPollTask() { - PollTask task = pollTask; - if (task == null) { - return; - } - - ModbusCommunicationInterface mycomms = HeatpumpHandler.this.comms; - if (mycomms != null) { - mycomms.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 Address: {}", address); - - ModbusCommunicationInterface mycomms = HeatpumpHandler.this.comms; - HeatpumpConfiguration myconfig = HeatpumpHandler.this.config; - - if (myconfig == null || mycomms == null) { - throw new IllegalStateException("registerPollTask called without proper configuration"); - } - - ModbusReadRequestBlueprint request = new ModbusReadRequestBlueprint(getSlaveId(), readFunctionCode, address, - length, myconfig.getMaxTries()); - - long refreshMillis = myconfig.getRefreshMillis(); - - pollTask = mycomms.registerRegularPoll(request, refreshMillis, 1000, result -> { - result.getRegisters().ifPresent(this::handlePolledData); - if (getThing().getStatus() != ThingStatus.ONLINE) { - updateStatus(ThingStatus.ONLINE); - } - }, HeatpumpHandler.this::handleReadError); - } - - public synchronized void poll() { - PollTask task = pollTask; - ModbusCommunicationInterface mycomms = HeatpumpHandler.this.comms; - if (task != null && mycomms != null) { - mycomms.submitOneTimePoll(task.getRequest(), task.getResultCallback(), task.getFailureCallback()); - } - } - - protected abstract void handlePolledData(ModbusRegisterArray registers); - } - - /** - * Logger instance - */ - private final Logger logger = LoggerFactory.getLogger(HeatpumpHandler.class); - - /** - * Configuration instance - */ - protected @Nullable HeatpumpConfiguration config = null; - /** - * Parser used to convert incoming raw messages into system blocks - * private final SystemInfromationBlockParser systemInformationBlockParser = new SystemInfromationBlockParser(); - */ - /** - * Parsers used to convert incoming raw messages into state blocks - */ - - private final HeatpumpBlockParser heatpumpBlockParser = new HeatpumpBlockParser(); - private final HeatpumpReg50BlockParser heatpumpReg50BlockParser = new HeatpumpReg50BlockParser(); - - /** - * These are the tasks used to poll the device - */ - private volatile @Nullable AbstractBasePoller heatpumpPoller = null; - private volatile @Nullable AbstractBasePoller heatpumpreg50Poller = null; - - /** - * Communication interface to the slave endpoint we're connecting to - */ - protected volatile @Nullable ModbusCommunicationInterface comms = null; - /** - * This is the slave id, we store this once initialization is complete - */ - private volatile int slaveId; - - /** - * Instances of this handler should get a reference to the modbus manager - * - * @param thing the thing to handle - */ - public HeatpumpHandler(Thing thing) { - super(thing); - } - - /** - * @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) { - // loggertrace("187 writeInt16: Es wird geschrieben, Adresse: {} Wert: {}", address, shortValue); - HeatpumpConfiguration myconfig = HeatpumpHandler.this.config; - ModbusCommunicationInterface mycomms = HeatpumpHandler.this.comms; - - if (myconfig == null || mycomms == null) { - throw new IllegalStateException("registerPollTask called without proper configuration"); - } - // big endian byte ordering - byte hi = (byte) (shortValue >> 8); - byte lo = (byte) shortValue; - ModbusRegisterArray data = new ModbusRegisterArray(hi, lo); - - // loggertrace("199 hi: {}, lo: {}", hi, lo); - ModbusWriteRegisterRequestBlueprint request = new ModbusWriteRegisterRequestBlueprint(slaveId, address, data, - true, myconfig.getMaxTries()); - - mycomms.submitOneTimeWrite(request, result -> { - if (hasConfigurationError()) { - return; - } - // loggertrace("Successful write, matching request {}", request); - HeatpumpHandler.this.updateStatus(ThingStatus.ONLINE); - }, failure -> { - HeatpumpHandler.this.handleWriteError(failure); - // loggertrace("Unsuccessful write, matching request {}", request); - }); - } - - /** - * @param command get the value of this command. - * @return short the value of the command as short - */ - private short getInt16Value(Command command) throws LambdaException { - if (command instanceof QuantityType quantityCommand) { - QuantityType c = quantityCommand.toUnit(WATT); - if (c != null) { - return c.shortValue(); - } else { - throw new LambdaException("Unsupported unit"); - } - } - if (command instanceof DecimalType c) { - return c.shortValue(); - } - throw new LambdaException("Unsupported command type"); - } - - private short getScaledInt16Value(Command command) throws LambdaException { - if (command instanceof QuantityType quantityCommand) { - QuantityType c = quantityCommand.toUnit(CELSIUS); - if (c != null) { - return (short) (c.doubleValue() * 10); - } else { - throw new LambdaException("Unsupported unit"); - } - } - if (command instanceof DecimalType c) { - return (short) (c.doubleValue() * 10); - } - throw new LambdaException("Unsupported command type"); - } - - /** - * Handle incoming commands. - */ - @Override - public void handleCommand(ChannelUID channelUID, Command command) { - logger.trace("283 handleCommand, channelUID: {} command {} ", channelUID, command); - if (RefreshType.REFRESH == command) { - String groupId = channelUID.getGroupId(); - if (groupId != null) { - AbstractBasePoller poller; - switch (groupId) { - case GROUP_HEATPUMP: - poller = heatpumpPoller; - break; - case GROUP_HEATPUMP_REG50: - poller = heatpumpreg50Poller; - break; - default: - poller = null; - break; - } - if (poller != null) { - logger.trace("HeatpumpHandler Es wird gepollt }"); - poller.poll(); - } - } - } else { - // loggertrace("341 handleCommand: Es wird geschrieben, GroupID: {}, command {}", channelUID.getGroupId(), - // command); - try { - - if (GROUP_HEATPUMP_REG50.equals(channelUID.getGroupId())) { - // loggertrace("439 im GROUP_HEATPUMP_REG50 channelUID {} ", channelUID.getIdWithoutGroup()); - - switch (channelUID.getIdWithoutGroup()) { - - case CHANNEL_HEATPUMP_SET_ERROR_QUIT: - - // loggertrace("445 Heatpumpseterrorquit command: {}", command); - writeInt16(1050, getScaledInt16Value(command)); - break; - - } - } - } catch (LambdaException error) { - if (hasConfigurationError() || getThing().getStatus() == ThingStatus.OFFLINE) { - return; - } - String cls = error.getClass().getName(); - String msg = error.getMessage(); - - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, - String.format("Error with: %s: %s", cls, msg)); - } - } - } - - /** - * Initialization: Load the config object of the block Connect to the slave - * bridge Start the periodic polling - */ - @Override - public void initialize() { - config = getConfigAs(HeatpumpConfiguration.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 polling1 - */ - private void startUp() { - if (comms != null) { - return; - } - - ModbusEndpointThingHandler slaveEndpointThingHandler = getEndpointThingHandler(); - if (slaveEndpointThingHandler == null) { - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, "Bridge is offline"); - return; - } - - try { - slaveId = slaveEndpointThingHandler.getSlaveId(); - - comms = slaveEndpointThingHandler.getCommunicationInterface(); - } catch (EndpointNotInitializedException e) { - // this will be handled below as endpoint remains null - } - - if (comms == 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)); - return; - } - - if (config == null) { - logger.debug("Invalid comms/config/manager ref for lambda heatpump handler"); - return; - } - - HeatpumpConfiguration myconfig = HeatpumpHandler.this.config; - - int baseadress = 1000 + 100 * myconfig.getSubindex(); - - logger.debug("Heatpump config.baseadress = {} ", baseadress); - - int reg50baseadress = baseadress + 50; - - logger.debug("HeatpumpReg50 baseadress = {} ", reg50baseadress); - - if (heatpumpPoller == null) { - AbstractBasePoller poller = new AbstractBasePoller() { - @Override - protected void handlePolledData(ModbusRegisterArray registers) { - handlePolledHeatpumpData(registers); - } - }; - - poller.registerPollTask(baseadress, 24, ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS); - // loggertrace("Poller Heatpump erzeugt"); - heatpumpPoller = poller; - } - - if (heatpumpreg50Poller == null) { - AbstractBasePoller poller = new AbstractBasePoller() { - @Override - protected void handlePolledData(ModbusRegisterArray registers) { - handlePolledHeatpumpReg50Data(registers); - } - }; - - poller.registerPollTask(reg50baseadress, 1, ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS); - // loggertrace("Poller GROUP_HEATPUMP_REG50 erzeugt"); - heatpumpreg50Poller = poller; - } - - updateStatus(ThingStatus.UNKNOWN); - } - - /** - * Dispose the binding correctly - */ - @Override - public void dispose() { - tearDown(); - } - - /** - * Unregister the poll tasks and release the endpoint reference - */ - private void tearDown() { - - AbstractBasePoller poller = heatpumpPoller; - if (poller != null) { - poller.unregisterPollTask(); - heatpumpPoller = null; - } - - poller = heatpumpreg50Poller; - if (poller != null) { - poller.unregisterPollTask(); - heatpumpreg50Poller = null; - } - - comms = null; - } - - /** - * 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 thingHandler) { - return thingHandler; - } else { - throw new IllegalStateException("Unexpected bridge handler: " + handler.toString()); - } - } - - protected State getScaled(Number value, Unit unit, Double pow) { - // loggertrace("505 value: {}", value.intValue()); - double factor = Math.pow(10, pow); - return QuantityType.valueOf(value.doubleValue() * factor, unit); - } - - protected State getUnscaled(Number value, Unit unit) { - return QuantityType.valueOf(value.doubleValue(), 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 QuantityType.valueOf(value, KILOWATT_HOUR); - } - - /** - * These methods are 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 handlePolledHeatpumpData(ModbusRegisterArray registers) { - // loggertrace("Heatpump block received, size: {}", registers.size()); - - HeatpumpBlock block = heatpumpBlockParser.parse(registers); - - // Heatpump group - updateState(channelUID(GROUP_HEATPUMP, CHANNEL_HEATPUMP_ERROR_STATE), - new DecimalType(block.heatpumpErrorState)); - updateState(channelUID(GROUP_HEATPUMP, CHANNEL_HEATPUMP_ERROR_NUMBER), - new DecimalType(block.heatpumpErrorNumber)); - updateState(channelUID(GROUP_HEATPUMP, CHANNEL_HEATPUMP_OPERATING_STATE), - new DecimalType(block.heatpumpOperatingState)); - updateState(channelUID(GROUP_HEATPUMP, CHANNEL_HEATPUMP_STATE), new DecimalType(block.heatpumpState)); - updateState(channelUID(GROUP_HEATPUMP, CHANNEL_HEATPUMP_T_FLOW), getScaled(block.heatpumpTFlow, CELSIUS, -2.0)); - updateState(channelUID(GROUP_HEATPUMP, CHANNEL_HEATPUMP_T_RETURN), - getScaled(block.heatpumpTReturn, CELSIUS, -2.0)); - updateState(channelUID(GROUP_HEATPUMP, CHANNEL_HEATPUMP_VOL_SINK), - getScaled(block.heatpumpVolSink, LITRE_PER_MINUTE, -2.0)); - updateState(channelUID(GROUP_HEATPUMP, CHANNEL_HEATPUMP_T_EQIN), getScaled(block.heatpumpTEQin, CELSIUS, -2.0)); - updateState(channelUID(GROUP_HEATPUMP, CHANNEL_HEATPUMP_T_EQOUT), - getScaled(block.heatpumpTEQout, CELSIUS, -2.0)); - updateState(channelUID(GROUP_HEATPUMP, CHANNEL_HEATPUMP_VOL_SOURCE), - getScaled(block.heatpumpVolSource, LITRE_PER_MINUTE, -2.0)); - updateState(channelUID(GROUP_HEATPUMP, CHANNEL_HEATPUMP_COMPRESSOR_RATING), - getScaled(block.heatpumpCompressorRating, PERCENT, -2.0)); - updateState(channelUID(GROUP_HEATPUMP, CHANNEL_HEATPUMP_QP_HEATING), - getScaled(block.heatpumpQpHeating, WATT, 2.0)); - updateState(channelUID(GROUP_HEATPUMP, CHANNEL_HEATPUMP_FI_POWER_CONSUMPTION), - getUnscaled(block.heatpumpFIPowerConsumption, WATT)); - - updateState(channelUID(GROUP_HEATPUMP, CHANNEL_HEATPUMP_COP), getScaled(block.heatpumpCOP, PERCENT, -2.0)); - updateState(channelUID(GROUP_HEATPUMP, CHANNEL_HEATPUMP_VDAE), - getScaled(block.heatpumpVdAE, KILOWATT_HOUR, -3.0)); - updateState(channelUID(GROUP_HEATPUMP, CHANNEL_HEATPUMP_VDAQ), - getScaled(block.heatpumpVdAQ, KILOWATT_HOUR, -3.0)); - - resetCommunicationError(); - } - - protected void handlePolledHeatpumpReg50Data(ModbusRegisterArray registers) { - // loggertrace("HeatpumpReg50 block received, size: {}", registers.size()); - - HeatpumpReg50Block block = heatpumpReg50BlockParser.parse(registers); - - // Heatpump group - updateState(channelUID(GROUP_HEATPUMP_REG50, CHANNEL_HEATPUMP_SET_ERROR_QUIT), - new DecimalType(block.heatpumpSetErrorQuit)); - resetCommunicationError(); - } - - /** - * @param bridgeStatusInfo - */ - @Override - public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { - super.bridgeStatusChanged(bridgeStatusInfo); - - if (bridgeStatusInfo.getStatus() == ThingStatus.ONLINE) { - startUp(); - } else if (bridgeStatusInfo.getStatus() == ThingStatus.OFFLINE) { - tearDown(); - } - } - - /** - * Handle errors received during communication - */ - 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 = 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 - * - * @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/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/LambdaException.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/LambdaException.java deleted file mode 100644 index be60f36f74332..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/handler/LambdaException.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.handler; - -import org.eclipse.jdt.annotation.NonNullByDefault; - -/** - * Thrown when the lambda-heatpump handler sees an error. - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - */ -@SuppressWarnings("serial") -@NonNullByDefault -public class LambdaException extends Exception { - - public LambdaException() { - } - - public LambdaException(String message) { - super(message); - } -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/AbstractBaseParser.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/AbstractBaseParser.java deleted file mode 100644 index 56f5150c73fb3..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/AbstractBaseParser.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.parser; - -import java.util.Objects; -import java.util.Optional; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.core.io.transport.modbus.ModbusBitUtilities; -import org.openhab.core.io.transport.modbus.ModbusConstants.ValueType; -import org.openhab.core.io.transport.modbus.ModbusRegisterArray; -import org.openhab.core.library.types.DecimalType; - -/** - * 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 -> ((double) 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 Objects.requireNonNull(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 Objects.requireNonNull(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 Objects.requireNonNull(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 Objects.requireNonNull(extractOptionalUInt32(raw, index).orElse(def)); - } -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/AmbientBlockParser.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/AmbientBlockParser.java deleted file mode 100644 index 3d221a6f60847..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/AmbientBlockParser.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.parser; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.binding.modbus.lambda.internal.dto.AmbientBlock; -import org.openhab.core.io.transport.modbus.ModbusRegisterArray; - -/** - * Parses labmda modbus data into an Ambient Block - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - * - */ -@NonNullByDefault -public class AmbientBlockParser extends AbstractBaseParser { - - public AmbientBlock parse(ModbusRegisterArray raw) { - AmbientBlock block = new AmbientBlock(); - block.ambientErrorNumber = extractUInt16(raw, 0, (short) 0); - block.ambientOperatingState = extractUInt16(raw, 1, (short) 0); - block.actualAmbientTemperature = extractUInt16(raw, 2, (short) 0); - block.averageAmbientTemperature = extractUInt16(raw, 3, (short) 0); - block.calculatedAmbientTemperature = extractUInt16(raw, 4, (short) 0); - return block; - } -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/BoilerBlockParser.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/BoilerBlockParser.java deleted file mode 100644 index 4b0114d72c0df..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/BoilerBlockParser.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.parser; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.binding.modbus.lambda.internal.dto.BoilerBlock; -import org.openhab.core.io.transport.modbus.ModbusRegisterArray; - -/** - * Parses lambda modbus data into a Boiler Block - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - * - */ -@NonNullByDefault -public class BoilerBlockParser extends AbstractBaseParser { - - public BoilerBlock parse(ModbusRegisterArray raw) { - BoilerBlock block = new BoilerBlock(); - block.boilerErrorNumber = extractUInt16(raw, 0, (short) 0); - block.boilerOperatingState = extractUInt16(raw, 1, (short) 0); - block.boilerActualHighTemperature = extractUInt16(raw, 2, (short) 0); - block.boilerActualLowTemperature = extractUInt16(raw, 3, (short) 0); - return block; - } -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/BoilerReg50BlockParser.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/BoilerReg50BlockParser.java deleted file mode 100644 index 4e7fc93755782..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/BoilerReg50BlockParser.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.parser; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.binding.modbus.lambda.internal.dto.BoilerReg50Block; -import org.openhab.core.io.transport.modbus.ModbusRegisterArray; - -/** - * Parses inv modbus data into an Mt Block - - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - * - */ -@NonNullByDefault -public class BoilerReg50BlockParser extends AbstractBaseParser { - - public BoilerReg50Block parse(ModbusRegisterArray raw) { - BoilerReg50Block block = new BoilerReg50Block(); - block.boilerMaximumBoilerTemperature = extractUInt16(raw, 0, (short) 0); - return block; - } -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/BufferBlockParser.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/BufferBlockParser.java deleted file mode 100644 index 148424a5d381e..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/BufferBlockParser.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.parser; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.binding.modbus.lambda.internal.dto.BufferBlock; -import org.openhab.core.io.transport.modbus.ModbusRegisterArray; - -/** - * Parses lambda modbus data into a Buffer Block - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - * - */ -@NonNullByDefault -public class BufferBlockParser extends AbstractBaseParser { - - public BufferBlock parse(ModbusRegisterArray raw) { - BufferBlock block = new BufferBlock(); - block.bufferErrorNumber = extractUInt16(raw, 0, (short) 0); - block.bufferOperatingState = extractUInt16(raw, 1, (short) 0); - block.bufferActualHighTemperature = extractUInt16(raw, 2, (short) 0); - block.bufferActualLowTemperature = extractUInt16(raw, 3, (short) 0); - return block; - } -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/BufferReg50BlockParser.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/BufferReg50BlockParser.java deleted file mode 100644 index bbf0b067cfe6e..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/BufferReg50BlockParser.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.parser; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.binding.modbus.lambda.internal.dto.BufferReg50Block; -import org.openhab.core.io.transport.modbus.ModbusRegisterArray; - -/** - * Parses lambda modbus data into an Mt Block - - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - * - */ -@NonNullByDefault -public class BufferReg50BlockParser extends AbstractBaseParser { - - public BufferReg50Block parse(ModbusRegisterArray raw) { - BufferReg50Block block = new BufferReg50Block(); - block.bufferMaximumBufferTemperature = extractUInt16(raw, 0, (short) 0); - return block; - } -} diff --git a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/EManagerBlockParser.java b/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/EManagerBlockParser.java deleted file mode 100644 index 3c2b2c649c061..0000000000000 --- a/bundles/org.openhab.binding.modbus.stiebeleltron/src/main/java/org/openhab/binding/modbus/stiebeleltron/internal/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/EManagerBlockParser.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.lambda.internal.parser; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.binding.modbus.lambda.internal.dto.EManagerBlock; -import org.openhab.core.io.transport.modbus.ModbusRegisterArray; - -/** - * Parses inverter modbus data into an EManger Block - * - * @author Paul Frank - Initial contribution - * @author Christian Koch - modified for lambda heat pump based on stiebeleltron binding for modbus - * - */ -@NonNullByDefault -public class EManagerBlockParser extends AbstractBaseParser { - - public EManagerBlock parse(ModbusRegisterArray raw) { - EManagerBlock block = new EManagerBlock(); - block.emanagerErrorNumber = extractUInt16(raw, 0, (short) 0); - block.emanagerOperatingState = extractUInt16(raw, 1, (short) 0); - block.actualPower = extractUInt16(raw, 2, (short) 0); - block.actualPowerConsumption = extractUInt16(raw, 3, (short) 0); - block.powerConsumptionSetpoint = extractUInt16(raw, 4, (short) 0); - - return block; - } -}