From 36cff511b946c8976ad29ea5537bc114581a29c9 Mon Sep 17 00:00:00 2001 From: Catalin Sanda Date: Sat, 4 Jan 2025 22:05:43 +0200 Subject: [PATCH] Fix issue openhab/openhab-addons#17959 where new channels could not be added in the Web UI (#18016) Signed-off-by: Catalin Sanda --- .../solarman/internal/SolarmanLoggerMode.java | 3 ++ .../modbus/SolarmanProtocolFactory.java | 2 +- .../OH-INF/config/datetime-channel-config.xml | 46 ---------------- .../OH-INF/config/dynamic-channel-config.xml | 32 ++++++------ .../OH-INF/config/number-channel-config.xml | 46 ---------------- .../OH-INF/config/string-channel-config.xml | 46 ---------------- .../resources/OH-INF/i18n/solarman.properties | 52 ++++++++++++------- .../main/resources/OH-INF/thing/channels.xml | 10 ++-- .../resources/OH-INF/thing/thing-types.xml | 2 +- .../internal/DefinitionParserTest.java | 8 +-- 10 files changed, 65 insertions(+), 182 deletions(-) delete mode 100644 bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/config/datetime-channel-config.xml delete mode 100644 bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/config/number-channel-config.xml delete mode 100644 bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/config/string-channel-config.xml diff --git a/bundles/org.openhab.binding.solarman/src/main/java/org/openhab/binding/solarman/internal/SolarmanLoggerMode.java b/bundles/org.openhab.binding.solarman/src/main/java/org/openhab/binding/solarman/internal/SolarmanLoggerMode.java index d3e59724635..df8526cb2ab 100644 --- a/bundles/org.openhab.binding.solarman/src/main/java/org/openhab/binding/solarman/internal/SolarmanLoggerMode.java +++ b/bundles/org.openhab.binding.solarman/src/main/java/org/openhab/binding/solarman/internal/SolarmanLoggerMode.java @@ -12,9 +12,12 @@ */ package org.openhab.binding.solarman.internal; +import org.eclipse.jdt.annotation.NonNullByDefault; + /** * @author Peter Kretz - Initial contribution */ +@NonNullByDefault public enum SolarmanLoggerMode { V5MODBUS, RAWMODBUS diff --git a/bundles/org.openhab.binding.solarman/src/main/java/org/openhab/binding/solarman/internal/modbus/SolarmanProtocolFactory.java b/bundles/org.openhab.binding.solarman/src/main/java/org/openhab/binding/solarman/internal/modbus/SolarmanProtocolFactory.java index 823cbfaab2e..8434937aa88 100644 --- a/bundles/org.openhab.binding.solarman/src/main/java/org/openhab/binding/solarman/internal/modbus/SolarmanProtocolFactory.java +++ b/bundles/org.openhab.binding.solarman/src/main/java/org/openhab/binding/solarman/internal/modbus/SolarmanProtocolFactory.java @@ -16,7 +16,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.binding.solarman.internal.SolarmanLoggerConfiguration; /** - * @author Peter Kretz - Added RAW Modbus for LAN Stick + * @author Peter Kretz - Initial contribution */ @NonNullByDefault public class SolarmanProtocolFactory { diff --git a/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/config/datetime-channel-config.xml b/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/config/datetime-channel-config.xml deleted file mode 100644 index 435e457bf8e..00000000000 --- a/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/config/datetime-channel-config.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - The unit of measurement used for this channel - true - - - - The scaling factor, the final value will be scaled by this - true - - - - The type of measurement. See explanation for possible values - true - - - - - - - - - - - - - - - The offset subtracted from the measurement - true - - - - Comma separated list of registers to read for the measurement - true - - - - diff --git a/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/config/dynamic-channel-config.xml b/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/config/dynamic-channel-config.xml index 326437b10c8..2d5dd0734d0 100644 --- a/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/config/dynamic-channel-config.xml +++ b/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/config/dynamic-channel-config.xml @@ -8,38 +8,38 @@ The unit of measurement used for this channel - true + false The scaling factor, the final value will be scaled by this - true + false - + The type of measurement. See explanation for possible values - true + false - - - - - - - - - + + + + + + + + + The offset subtracted from the measurement - true + false - + Comma separated list of registers to read for the measurement - true + false diff --git a/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/config/number-channel-config.xml b/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/config/number-channel-config.xml deleted file mode 100644 index 593853d90a5..00000000000 --- a/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/config/number-channel-config.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - The unit of measurement used for this channel - true - - - - The scaling factor, the final value will be scaled by this - true - - - - The type of measurement. See explanation for possible values - true - - - - - - - - - - - - - - - The offset subtracted from the measurement - true - - - - Comma separated list of registers to read for the measurement - true - - - - diff --git a/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/config/string-channel-config.xml b/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/config/string-channel-config.xml deleted file mode 100644 index 92ba342efe1..00000000000 --- a/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/config/string-channel-config.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - The unit of measurement used for this channel - true - - - - The scaling factor, the final value will be scaled by this - true - - - - The type of measurement. See explanation for possible values - true - - - - - - - - - - - - - - - The offset subtracted from the measurement - true - - - - Comma separated list of registers to read for the measurement - true - - - - diff --git a/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/i18n/solarman.properties b/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/i18n/solarman.properties index 58f7dfd6e41..4a10aee7f2d 100644 --- a/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/i18n/solarman.properties +++ b/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/i18n/solarman.properties @@ -27,7 +27,10 @@ thing-type.config.solarman.logger.inverterType.option.sofar_hyd3k-6k-es = SOFAR thing-type.config.solarman.logger.inverterType.option.sofar_lsw3 = SOFAR Inverters (sofar_lsw3) thing-type.config.solarman.logger.inverterType.option.sofar_wifikit = SOFAR WifiKit (sofar_wifikit) thing-type.config.solarman.logger.inverterType.option.solis_1p8k-5g = SOLIS 1P8K-5G (solis_1p8k-5g) +thing-type.config.solarman.logger.inverterType.option.solis_3p-4g = SOLIS Three-Phase Inverter 4G Series (solis_3p-4g) +thing-type.config.solarman.logger.inverterType.option.solis_s6-gr1p = SOLIS Single-Phase Inverter S6-GR1P (solis_s6-gr1p) thing-type.config.solarman.logger.inverterType.option.solis_hybrid = SOLIS Hybrid Inverter (solis_hybrid) +thing-type.config.solarman.logger.inverterType.option.hyd-zss-hp-3k-6k = ZCS Azzurro Hybrid HP 3K-6K Inverters (hyd-zss-hp-3k-6k) thing-type.config.solarman.logger.inverterType.option.zcs_azzurro-ktl-v3 = ZCS Azzurro KTL-V3 Inverters (zcs_azzurro-ktl-v3) thing-type.config.solarman.logger.port.label = Port thing-type.config.solarman.logger.port.description = Port of the Solarman logger (default 8899). @@ -35,13 +38,43 @@ thing-type.config.solarman.logger.refreshInterval.label = Refresh Interval thing-type.config.solarman.logger.refreshInterval.description = Interval to query the logger (default 60). thing-type.config.solarman.logger.serialNumber.label = Serial Number thing-type.config.solarman.logger.serialNumber.description = Serial number of the Solarman logger. +thing-type.config.solarman.logger.solarmanLoggerMode.label = Logger Mode +thing-type.config.solarman.logger.solarmanLoggerMode.description = Use RAW Modbus for LAN Stick LSE-3 and V5 NODBUS for most Wifi Sticks. If your Wifi stick uses Raw Modbus choose RAW. If you do not use this advanced option, V5 MODBUS will be the default. +thing-type.config.solarman.logger.solarmanLoggerMode.option.V5MODBUS = V5 Modbus +thing-type.config.solarman.logger.solarmanLoggerMode.option.RAWMODBUS = RAW Modbus # channel types channel-type.solarman.datetime.label = Datetime Value +channel-type.solarman.datetime.description = Channel used to represent a datetime value channel-type.solarman.dynamic.label = Dynamic Channel +channel-type.solarman.dynamic.description = Channel used to represent a dynamic value channel-type.solarman.number.label = Number Value +channel-type.solarman.number.description = Channel used to represent a numeric value channel-type.solarman.string.label = Text Value +channel-type.solarman.string.description = Channel used to represent a string value + +# channel types config + +channel-type-config.config.solarman.dynamic-channel.offset.label = Offset +channel-type-config.config.solarman.dynamic-channel.offset.description = The offset subtracted from the measurement +channel-type-config.config.solarman.dynamic-channel.registers.label = Registers +channel-type-config.config.solarman.dynamic-channel.registers.description = Comma separated list of registers to read for the measurement +channel-type-config.config.solarman.dynamic-channel.rule.label = Rule +channel-type-config.config.solarman.dynamic-channel.rule.description = The type of measurement. See explanation for possible values +channel-type-config.config.solarman.dynamic-channel.rule.option.1 = Unsigned Short (Rule 1) +channel-type-config.config.solarman.dynamic-channel.rule.option.2 = Signed Short (Rule 2) +channel-type-config.config.solarman.dynamic-channel.rule.option.3 = Unsigned Integer (Rule 3) +channel-type-config.config.solarman.dynamic-channel.rule.option.4 = Signed Integer (Rule 4) +channel-type-config.config.solarman.dynamic-channel.rule.option.5 = Text (Rule 5) +channel-type-config.config.solarman.dynamic-channel.rule.option.6 = Bytes (Rule 6) +channel-type-config.config.solarman.dynamic-channel.rule.option.7 = Version (Rule 7) +channel-type-config.config.solarman.dynamic-channel.rule.option.8 = Date Time (Rule 8) +channel-type-config.config.solarman.dynamic-channel.rule.option.9 = Time (Rule 9) +channel-type-config.config.solarman.dynamic-channel.scale.label = Scale +channel-type-config.config.solarman.dynamic-channel.scale.description = The scaling factor, the final value will be scaled by this +channel-type-config.config.solarman.dynamic-channel.uom.label = Unit of Measurement +channel-type-config.config.solarman.dynamic-channel.uom.description = The unit of measurement used for this channel # channel types config @@ -64,25 +97,6 @@ channel-type-config.config.solarman.datetime-channel.scale.label = Scale channel-type-config.config.solarman.datetime-channel.scale.description = The scaling factor, the final value will be scaled by this channel-type-config.config.solarman.datetime-channel.uom.label = Unit of Measurement channel-type-config.config.solarman.datetime-channel.uom.description = The unit of measurement used for this channel -channel-type-config.config.solarman.dynamic-channel.offset.label = Offset -channel-type-config.config.solarman.dynamic-channel.offset.description = The offset subtracted from the measurement -channel-type-config.config.solarman.dynamic-channel.registers.label = Registers -channel-type-config.config.solarman.dynamic-channel.registers.description = Comma separated list of registers to read for the measurement -channel-type-config.config.solarman.dynamic-channel.rule.label = Rule -channel-type-config.config.solarman.dynamic-channel.rule.description = The type of measurement. See explanation for possible values -channel-type-config.config.solarman.dynamic-channel.rule.option.1 = Unsigned Short -channel-type-config.config.solarman.dynamic-channel.rule.option.2 = Signed Short -channel-type-config.config.solarman.dynamic-channel.rule.option.3 = Unsigned Integer -channel-type-config.config.solarman.dynamic-channel.rule.option.4 = Signed Integer -channel-type-config.config.solarman.dynamic-channel.rule.option.5 = Text -channel-type-config.config.solarman.dynamic-channel.rule.option.6 = Bytes -channel-type-config.config.solarman.dynamic-channel.rule.option.7 = Version -channel-type-config.config.solarman.dynamic-channel.rule.option.8 = Date Time -channel-type-config.config.solarman.dynamic-channel.rule.option.9 = Time -channel-type-config.config.solarman.dynamic-channel.scale.label = Scale -channel-type-config.config.solarman.dynamic-channel.scale.description = The scaling factor, the final value will be scaled by this -channel-type-config.config.solarman.dynamic-channel.uom.label = Unit of Measurement -channel-type-config.config.solarman.dynamic-channel.uom.description = The unit of measurement used for this channel channel-type-config.config.solarman.number-channel.offset.label = Offset channel-type-config.config.solarman.number-channel.offset.description = The offset subtracted from the measurement channel-type-config.config.solarman.number-channel.registers.label = Registers diff --git a/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/thing/channels.xml index b8e1d752fe7..7a2af4f2701 100644 --- a/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/thing/channels.xml @@ -7,24 +7,28 @@ String - + Channel used to represent a string value + Number - + Channel used to represent a numeric value + DateTime - + Channel used to represent a datetime value + String + Channel used to represent a dynamic value diff --git a/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/thing/thing-types.xml index 57046c17c7f..c2134ebd93c 100644 --- a/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.solarman/src/main/resources/OH-INF/thing/thing-types.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd"> - + This thing allows communication with Solarman (IGEN-Tech) v5 based solar inverter data loggers over the local network. Compatible with inverters from manufacturers such as Deye, Sofar, Solis, ZCS Azzurro, and KStar. diff --git a/bundles/org.openhab.binding.solarman/src/test/java/org/openhab/binding/solarman/internal/DefinitionParserTest.java b/bundles/org.openhab.binding.solarman/src/test/java/org/openhab/binding/solarman/internal/DefinitionParserTest.java index 6e2e5d08a81..80ce2c685fb 100644 --- a/bundles/org.openhab.binding.solarman/src/test/java/org/openhab/binding/solarman/internal/DefinitionParserTest.java +++ b/bundles/org.openhab.binding.solarman/src/test/java/org/openhab/binding/solarman/internal/DefinitionParserTest.java @@ -98,7 +98,8 @@ public class DefinitionParserTest { } private static List scanDirectory(String directoryPath) throws IOException, URISyntaxException { - URL url = Objects.requireNonNull(DefinitionParserTest.class.getClassLoader()).getResource(directoryPath); + URL url = Objects.requireNonNull( + Objects.requireNonNull(DefinitionParserTest.class.getClassLoader()).getResource(directoryPath)); Path directory = Paths.get(url.toURI()); if (!Files.isDirectory(directory)) { @@ -106,9 +107,8 @@ public class DefinitionParserTest { } try (Stream stream = Files.list(directory)) { - List files = stream.filter(file -> file.getFileName().toString().endsWith(YAML_EXTENSION)) - .map(file -> directoryPath + "/" + file.getFileName().toString()).toList(); - return files; + return stream.filter(file -> file.getFileName().toString().endsWith(YAML_EXTENSION)) + .map(file -> directoryPath + "/" + file.getFileName()).toList(); } } }