From 2e1fbdd86f17a912149ecfc55dd9f6efc6fae41b Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Thu, 12 May 2022 19:31:45 +0200 Subject: [PATCH] [evcc] Initial contribution (#12611) Signed-off-by: Florian Hotze --- CODEOWNERS | 1 + bom/openhab-addons/pom.xml | 5 + bundles/org.openhab.binding.evcc/NOTICE | 13 + bundles/org.openhab.binding.evcc/README.md | 171 +++++++ bundles/org.openhab.binding.evcc/pom.xml | 17 + .../src/main/feature/feature.xml | 9 + .../evcc/internal/EvccBindingConstants.java | 131 +++++ .../evcc/internal/EvccConfiguration.java | 34 ++ .../binding/evcc/internal/EvccHandler.java | 448 ++++++++++++++++++ .../evcc/internal/EvccHandlerFactory.java | 55 +++ .../binding/evcc/internal/api/EvccAPI.java | 122 +++++ .../evcc/internal/api/EvccApiException.java | 34 ++ .../evcc/internal/api/dto/Loadpoint.java | 316 ++++++++++++ .../binding/evcc/internal/api/dto/Result.java | 140 ++++++ .../binding/evcc/internal/api/dto/Status.java | 31 ++ .../main/resources/OH-INF/binding/binding.xml | 9 + .../resources/OH-INF/i18n/evcc.properties | 111 +++++ .../resources/OH-INF/i18n/evcc_de.properties | 111 +++++ .../resources/OH-INF/thing/thing-types.xml | 327 +++++++++++++ bundles/pom.xml | 1 + 20 files changed, 2086 insertions(+) create mode 100644 bundles/org.openhab.binding.evcc/NOTICE create mode 100644 bundles/org.openhab.binding.evcc/README.md create mode 100644 bundles/org.openhab.binding.evcc/pom.xml create mode 100644 bundles/org.openhab.binding.evcc/src/main/feature/feature.xml create mode 100644 bundles/org.openhab.binding.evcc/src/main/java/org/openhab/binding/evcc/internal/EvccBindingConstants.java create mode 100644 bundles/org.openhab.binding.evcc/src/main/java/org/openhab/binding/evcc/internal/EvccConfiguration.java create mode 100644 bundles/org.openhab.binding.evcc/src/main/java/org/openhab/binding/evcc/internal/EvccHandler.java create mode 100644 bundles/org.openhab.binding.evcc/src/main/java/org/openhab/binding/evcc/internal/EvccHandlerFactory.java create mode 100644 bundles/org.openhab.binding.evcc/src/main/java/org/openhab/binding/evcc/internal/api/EvccAPI.java create mode 100644 bundles/org.openhab.binding.evcc/src/main/java/org/openhab/binding/evcc/internal/api/EvccApiException.java create mode 100644 bundles/org.openhab.binding.evcc/src/main/java/org/openhab/binding/evcc/internal/api/dto/Loadpoint.java create mode 100644 bundles/org.openhab.binding.evcc/src/main/java/org/openhab/binding/evcc/internal/api/dto/Result.java create mode 100644 bundles/org.openhab.binding.evcc/src/main/java/org/openhab/binding/evcc/internal/api/dto/Status.java create mode 100644 bundles/org.openhab.binding.evcc/src/main/resources/OH-INF/binding/binding.xml create mode 100644 bundles/org.openhab.binding.evcc/src/main/resources/OH-INF/i18n/evcc.properties create mode 100644 bundles/org.openhab.binding.evcc/src/main/resources/OH-INF/i18n/evcc_de.properties create mode 100644 bundles/org.openhab.binding.evcc/src/main/resources/OH-INF/thing/thing-types.xml diff --git a/CODEOWNERS b/CODEOWNERS index 07176c04242..110ba738a9b 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -90,6 +90,7 @@ /bundles/org.openhab.binding.enturno/ @klocsson /bundles/org.openhab.binding.epsonprojector/ @mlobstein /bundles/org.openhab.binding.etherrain/ @dfad1469 +/bundles/org.openhab.binding.evcc/ @florian-h05 /bundles/org.openhab.binding.evohome/ @Nebula83 /bundles/org.openhab.binding.exec/ @kgoderis /bundles/org.openhab.binding.feed/ @svilenvul diff --git a/bom/openhab-addons/pom.xml b/bom/openhab-addons/pom.xml index e4b65e93f82..3218cb7841b 100644 --- a/bom/openhab-addons/pom.xml +++ b/bom/openhab-addons/pom.xml @@ -441,6 +441,11 @@ org.openhab.binding.etherrain ${project.version} + + org.openhab.addons.bundles + org.openhab.binding.evcc + ${project.version} + org.openhab.addons.bundles org.openhab.binding.evohome diff --git a/bundles/org.openhab.binding.evcc/NOTICE b/bundles/org.openhab.binding.evcc/NOTICE new file mode 100644 index 00000000000..38d625e3492 --- /dev/null +++ b/bundles/org.openhab.binding.evcc/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.evcc/README.md b/bundles/org.openhab.binding.evcc/README.md new file mode 100644 index 00000000000..8b83a6d3b5b --- /dev/null +++ b/bundles/org.openhab.binding.evcc/README.md @@ -0,0 +1,171 @@ +# evcc Binding + +This binding integrates [evcc - electric vehicle charging control](https://evcc.io), a project that provides a control center for electric vehicle charging. + +evcc controls your wallbox(es) with multiple charging modes and allows you to charge your ev with your photovoltaik's excess current. +To provide an intelligent charging control, evcc supports over 30 wallboxes and over 20 energy meters/home energy management systems from many manufacturers as well as electric vehicles from over 20 car manufacturers. +Furthermore, evcc calculates your money savings. + +This binding enables openHAB to retrieve status data from your evcc installation and to control the charging process. +For more advanced features like calculated savings, you have to visit the web UI of evcc. + +## Supported Things + +- `device`: A running evcc installation. + +## Discovery + +No auto discovery supported. + +## Thing Configuration + +### `device` Thing Configuration + +| Parameter | Type | Description | Advanced | Required | +|-----------------|--------|----------------------------------------------------------|----------|----------| +| url | String | URL of evcc web UI, e.g. *https://demo.evcc.io* | No | Yes | +| refreshInterval | Number | Interval the status is polled in seconds (minimum is 15) | Yes | No | + +Default value for *refreshInterval* is 60 seconds. + +## Channels + +### General channels + +Those channels exist only once. +Please note that some of them are only available when evcc is properly configured. + +| Channel | Type | Read/Write | Description | +|----------------------------|----------------------|------------|--------------------------------------------------------------------------------------------------------------| +| general#batteryPower | Number:Power | R | Current power from battery. | +| general#batterySoC | Number:Dimensionless | R | Current State of Charge of battery. | +| general#batteryPrioritySoC | Number:Dimensionless | R | State of State of Charge for which the battery has priority over charging the ev when charging mode is "pv". | +| general#gridPower | Number:Power | R | Current power from grid (negative means feed-in) | +| general#homePower | Number:Power | R | Current power taken by home. | +| general#pvPower | Number:Power | R | Current power from photovoltaik. | + + +### Loadpoint channels + +Those channels exist per configured loadpoint. +Please note that you have to replace *N* with your loadpoint number. + +| Channel | Type | Read/Write | Description | +|-------------------------------------|------------------------|------------|-----------------------------------------------------------------------------------------------------| +| loadpointN#activePhases | Number | R | Current number of active phases while charging | +| loadpointN#chargeCurrent | Number:ElectricCurrent | R | Current amperage per connected phase while charging | +| loadpointN#chargeDuration | Number:Time | R | Charging duration | +| loadpointN#chargeRemainingDuration | Number:Time | R | Remaining duration until target SoC is reached | +| loadpointN#chargeRemainingEnergy | Number:Energy | R | Remaining energy until target SoC is reached | +| loadpointN#chargePower | Number:Power | R | Current power of charging | +| loadpointN#chargedEnergy | Number:Energy | R | Energy charged since plugged-in | +| loadpointN#charging | Switch | R | Loadpoint is currently charging | +| loadpointN#enabled | Switch | R | Charging enabled (mode is not "off") | +| loadpointN#hasVehicle | Switch | R | Whether vehicle is configured for loadpoint | +| loadpointN#maxCurrent | Number:ElectricCurrent | RW | Maximum amperage per connected phase with which the car should be charged | +| loadpointN#minCurrent | Number:ElectricCurrent | RW | Minimum amperage per connected phase with which the car should be charged | +| loadpointN#minSoC | Number:Dimensionless | RW | Charge immediately with maximum power up to the defined SoC, if the charge mode is not set to "off" | +| loadpointN#mode | String | RW | Charging mode: "off", "now", "minpv", "pv" | +| loadpointN#phases | Number | RW | The maximum number of phases which can be used | +| loadpointN#targetSoC | Number:Dimensionless | RW | Until which state of charge (SoC) should the vehicle be charged | +| loadpointN#targetTime | DateTime | RW | When the target SoC should be reached | +| loadpointN#targetTimeEnabled | Switch | RW | Target time for charging enabled | +| loadpointN#title | String | R | Title of loadpoint | +| loadpointN#vehicleConnected | Switch | R | Whether vehicle is connected to loadpoint | +| loadpointN#vehicleConnectedDuration | Number:Time | R | Duration the vehicle is connected to loadpoint | +| loadpointN#vehicleCapacity | Number:Energy | R | Capacity of EV battery | +| loadpointN#vehicleOdometer | Number:Length | R | Total distance travelled by EV | +| loadpointN#vehiclePresent | Switch | R | Whether evcc is able to get data from vehicle | +| loadpointN#vehicleRange | Number:Length | R | Battery range for EV | +| loadpointN#vehicleSoC | Number:Dimensionless | R | Current State of Charge of EV | +| loadpointN#vehicleTitle | String | R | Name of EV | + +## Full Example + +### Thing(s) + +``` +Thing evcc:device:demo "evcc Demo" [url="https://demo.evcc.io", refreshInterval=60] +``` + +### Items + +``` +// General +Number:Power evcc_demo_batteryPower "Battery Power [%.1f kW]" {channel="evcc:device:demo:general#batteryPower"} +Number:Dimensionless evcc_demo_batterySoC "Battery SoC [%d %%]" {channel="evcc:device:demo:general#batterySoC"} +Number:Dimensionless evcc_demo_batteryPrioritySoC "Battery Priority SoC [%d %%]" {channel="evcc:device:demo:general#batteryPrioritySoC"} +Number:Power evcc_demo_gridPower "Grid Power [%.1f kW]" {channel="evcc:device:demo:general#gridPower"} +Number:Power evcc_demo_homePower "Home Power [%.1f kW]" {channel="evcc:device:demo:general#homePower"} +Number:Power evcc_demo_pvPower "PV Power [%.1f kW]" {channel="evcc:device:demo:general#pvPower"} + +// Loadpoint +Number evcc_demo_loadpoint0_activePhases "Active Phases [%d]" {channel="evcc:device:demo:loadpoint0#activePhases"} +Number:ElectricCurrent evcc_demo_loadpoint0_chargeCurrent "Charging current [%.0f A]" {channel="evcc:device:demo:loadpoint0#chargeCurrent"} +Number:Time evcc_demo_loadpoint0_chargeDuration "Charging duration [%1$tH:%1$tM]"