From 6b2462ca2296656972cc8df79d9d622109c26aae Mon Sep 17 00:00:00 2001 From: "Philipp S." <16479847+nixoso@users.noreply.github.com> Date: Sun, 8 Sep 2024 14:48:26 +0200 Subject: [PATCH] [fenecon] Initial contribution (#17174) * Initial implementation of the FENECON Binding Signed-off-by: Philipp Schneider --- CODEOWNERS | 1 + bom/openhab-addons/pom.xml | 5 + bundles/org.openhab.binding.fenecon/NOTICE | 13 ++ bundles/org.openhab.binding.fenecon/README.md | 160 +++++++++++++++ bundles/org.openhab.binding.fenecon/pom.xml | 17 ++ .../src/main/feature/feature.xml | 9 + .../internal/FeneconBindingConstants.java | 75 +++++++ .../internal/FeneconConfiguration.java | 29 +++ .../fenecon/internal/FeneconHandler.java | 189 ++++++++++++++++++ .../internal/FeneconHandlerFactory.java | 64 ++++++ .../fenecon/internal/api/BatteryPower.java | 39 ++++ .../internal/api/FeneconController.java | 125 ++++++++++++ .../fenecon/internal/api/FeneconResponse.java | 24 +++ .../fenecon/internal/api/GridPower.java | 38 ++++ .../binding/fenecon/internal/api/State.java | 43 ++++ .../FeneconAuthenticationException.java | 30 +++ .../FeneconCommunicationException.java | 34 ++++ .../internal/exception/FeneconException.java | 42 ++++ .../src/main/resources/OH-INF/addon/addon.xml | 11 + .../resources/OH-INF/i18n/fenecon.properties | 57 ++++++ .../resources/OH-INF/thing/thing-types.xml | 177 ++++++++++++++++ .../internal/FeneconBindingConstantsTest.java | 48 +++++ .../internal/api/BatteryPowerTest.java | 44 ++++ .../fenecon/internal/api/GridPowerTest.java | 44 ++++ .../fenecon/internal/api/StateTest.java | 63 ++++++ bundles/pom.xml | 1 + 26 files changed, 1382 insertions(+) create mode 100644 bundles/org.openhab.binding.fenecon/NOTICE create mode 100644 bundles/org.openhab.binding.fenecon/README.md create mode 100644 bundles/org.openhab.binding.fenecon/pom.xml create mode 100644 bundles/org.openhab.binding.fenecon/src/main/feature/feature.xml create mode 100644 bundles/org.openhab.binding.fenecon/src/main/java/org/openhab/binding/fenecon/internal/FeneconBindingConstants.java create mode 100644 bundles/org.openhab.binding.fenecon/src/main/java/org/openhab/binding/fenecon/internal/FeneconConfiguration.java create mode 100644 bundles/org.openhab.binding.fenecon/src/main/java/org/openhab/binding/fenecon/internal/FeneconHandler.java create mode 100644 bundles/org.openhab.binding.fenecon/src/main/java/org/openhab/binding/fenecon/internal/FeneconHandlerFactory.java create mode 100644 bundles/org.openhab.binding.fenecon/src/main/java/org/openhab/binding/fenecon/internal/api/BatteryPower.java create mode 100644 bundles/org.openhab.binding.fenecon/src/main/java/org/openhab/binding/fenecon/internal/api/FeneconController.java create mode 100644 bundles/org.openhab.binding.fenecon/src/main/java/org/openhab/binding/fenecon/internal/api/FeneconResponse.java create mode 100644 bundles/org.openhab.binding.fenecon/src/main/java/org/openhab/binding/fenecon/internal/api/GridPower.java create mode 100644 bundles/org.openhab.binding.fenecon/src/main/java/org/openhab/binding/fenecon/internal/api/State.java create mode 100644 bundles/org.openhab.binding.fenecon/src/main/java/org/openhab/binding/fenecon/internal/exception/FeneconAuthenticationException.java create mode 100644 bundles/org.openhab.binding.fenecon/src/main/java/org/openhab/binding/fenecon/internal/exception/FeneconCommunicationException.java create mode 100644 bundles/org.openhab.binding.fenecon/src/main/java/org/openhab/binding/fenecon/internal/exception/FeneconException.java create mode 100644 bundles/org.openhab.binding.fenecon/src/main/resources/OH-INF/addon/addon.xml create mode 100644 bundles/org.openhab.binding.fenecon/src/main/resources/OH-INF/i18n/fenecon.properties create mode 100644 bundles/org.openhab.binding.fenecon/src/main/resources/OH-INF/thing/thing-types.xml create mode 100644 bundles/org.openhab.binding.fenecon/src/test/java/org/openhab/binding/fenecon/internal/FeneconBindingConstantsTest.java create mode 100644 bundles/org.openhab.binding.fenecon/src/test/java/org/openhab/binding/fenecon/internal/api/BatteryPowerTest.java create mode 100644 bundles/org.openhab.binding.fenecon/src/test/java/org/openhab/binding/fenecon/internal/api/GridPowerTest.java create mode 100644 bundles/org.openhab.binding.fenecon/src/test/java/org/openhab/binding/fenecon/internal/api/StateTest.java diff --git a/CODEOWNERS b/CODEOWNERS index 8395b0fea8c..2c497dafe73 100755 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -112,6 +112,7 @@ /bundles/org.openhab.binding.exec/ @kgoderis /bundles/org.openhab.binding.feed/ @openhab/add-ons-maintainers /bundles/org.openhab.binding.feican/ @Hilbrand +/bundles/org.openhab.binding.fenecon/ @nixoso /bundles/org.openhab.binding.fineoffsetweatherstation/ @Andy2003 /bundles/org.openhab.binding.flicbutton/ @pfink /bundles/org.openhab.binding.fmiweather/ @ssalonen diff --git a/bom/openhab-addons/pom.xml b/bom/openhab-addons/pom.xml index ead89e39d03..d9d76b04fe2 100644 --- a/bom/openhab-addons/pom.xml +++ b/bom/openhab-addons/pom.xml @@ -551,6 +551,11 @@ org.openhab.binding.feican ${project.version} + + org.openhab.addons.bundles + org.openhab.binding.fenecon + ${project.version} + org.openhab.addons.bundles org.openhab.binding.fineoffsetweatherstation diff --git a/bundles/org.openhab.binding.fenecon/NOTICE b/bundles/org.openhab.binding.fenecon/NOTICE new file mode 100644 index 00000000000..38d625e3492 --- /dev/null +++ b/bundles/org.openhab.binding.fenecon/NOTICE @@ -0,0 +1,13 @@ +This content is produced and maintained by the openHAB project. + +* Project home: https://www.openhab.org + +== Declared Project Licenses + +This program and the accompanying materials are made available under the terms +of the Eclipse Public License 2.0 which is available at +https://www.eclipse.org/legal/epl-2.0/. + +== Source Code + +https://github.com/openhab/openhab-addons diff --git a/bundles/org.openhab.binding.fenecon/README.md b/bundles/org.openhab.binding.fenecon/README.md new file mode 100644 index 00000000000..a2369af5769 --- /dev/null +++ b/bundles/org.openhab.binding.fenecon/README.md @@ -0,0 +1,160 @@ +# FENECON Binding + +The FENECON Binding integrates the [FENECON energy storage system](https://fenecon.de/) device into the openHAB system via [REST-API](https://docs.fenecon.de/_/de/fems/fems-app/OEM_App_REST_JSON.html). + +With the binding, it is possible to request status information from FENECON Home to allow you home automation decisions based on the current energy management. + +This makes it possible, for example, to switch on other consumers such as the dishwasher or washing machine in the case of power overproduction. + +## Supported Things + +Currently only one Thing is supported: The `home-device` connection to the FENECON energy storage system. + +This Binding was tested with an [FENECON HOME 10](https://fenecon.de/fenecon-home-10/) device. + +## Discovery + +Auto-discovery is not supported. + +## Thing Configuration + +The FENECON Thing only needs to be configured with the `hostname`, all other parameters are optional and prefilled with the suitable default values: + +| Parameter | Description | +|-----------------|----------------------------------------------------------------------------------| +| hostname | Hostname or IP address of the FENECON device, e.g. 192.168.1.11 | +| password | Password of the FENECON device. The password for guest access is set by default. | +| port | Port of the FENECON device. Default: 8084 | +| refreshInterval | Interval the device is polled in sec. Default 30 seconds | + +## Channels + +The FENECON binding currently only provides access to read out the values from the energy storage system. + +| Channel | Type | Read/Write | Description | +|-------------------------------|----------------------|------------|-----------------------------------------------------------------------------| +| state | String | R | FENECON system state: Ok, Info, Warning or Fault | +| last-update | DateTime | R | Last successful update via REST-API from the FENECON system | +| ess-soc | Number:Dimensionless | R | Battery state of charge in percent | +| charger-power | Number:Power | R | Current charger power of energy storage system in watt. | +| discharger-power | Number:Power | R | Current discharger power of energy storage system in watt. | +| emergency-power-mode | Switch | R | Indicates if there is grid power is off and the emergency power mode is on. | +| production-active-power | Number:Power | R | Current active power producer load in watt. | +| production-max-active-power | Number:Power | R | Maximum active production power in watt that was measured. | +| export-to-grid-power | Number:Power | R | Current export power to grid in watt. | +| exported-to-grid-energy | Number:Energy | R | Total energy exported to the grid in watt per hour. | +| consumption-active-power | Number:Power | R | Current active power consumer load in watt. | +| consumption-max-active-power | Number:Power | R | Maximum active consumption power in watt that was measured. | +| consumption-active-power-l1 | Number:Power | R | Current active power consumer load in watt on phase 1. | +| consumption-active-power-l2 | Number:Power | R | Current active power consumer load in watt on phase 2. | +| consumption-active-power-l3 | Number:Power | R | Current active power consumer load in watt on phase 3. | +| import-from-grid-power | Number:Power | R | Current import power from grid in watt. | +| imported-from-grid-energy | Number:Energy | R | Total energy imported from the grid in watt per hour. | + +## Full Example + +### fenecon.things + +```java +Thing fenecon:home-device:local "FENECON Home" [hostname="192.168.1.11", refreshInterval=5] +``` + +### demo.items + +```java +// Sitemap Items +Group Home "MyHome" ["Indoor"] +Group GF "GroundFloor" (Home) ["GroundFloor"] +// Utility room +Group GF_UtilityRoom "Utility room" (Home, GF) ["Room"] +Group GF_UtilityRoomSolar "Utility room solar" (GF_UtilityRoom) ["Inverter"] + +// FENECON items +String EssState (GF_UtilityRoomSolar) ["Status"] {channel="fenecon:home-device:local:state"} +DateTime LastFeneconUpdate