From e69a65d8e78a197cd02e75c68aa96994578cf354 Mon Sep 17 00:00:00 2001 From: Bernd Weymann Date: Sat, 1 May 2021 18:14:54 +0200 Subject: [PATCH] [BMW ConnectedDrive] initial contribution (#8576) Signed-off-by: Bernd Weymann Signed-off-by: Norbert Truchsess --- CODEOWNERS | 1 + bom/openhab-addons/pom.xml | 5 + .../NOTICE | 13 + .../README.md | 964 ++++++++++++++++++ .../doc/AwayImage.png | Bin 0 -> 215730 bytes .../doc/CarStatusImages.png | Bin 0 -> 471157 bytes .../doc/ChargingImage.png | Bin 0 -> 192764 bytes .../doc/CheckControlImage.png | Bin 0 -> 345125 bytes .../doc/ServiceOptions.png | Bin 0 -> 34617 bytes .../doc/UnlockedImage.png | Bin 0 -> 353189 bytes .../doc/panel.png | Bin 0 -> 1317196 bytes .../doc/properties.png | Bin 0 -> 55473 bytes .../doc/range-radius.png | Bin 0 -> 758058 bytes .../pom.xml | 17 + .../src/main/feature/feature.xml | 9 + .../internal/ConnectedDriveConfiguration.java | 40 + .../internal/ConnectedDriveConstants.java | 200 ++++ .../ConnectedDriveHandlerFactory.java | 76 ++ .../internal/VehicleConfiguration.java | 57 ++ .../action/BMWConnectedDriveActions.java | 406 ++++++++ .../internal/discovery/VehicleDiscovery.java | 181 ++++ .../internal/dto/Destination.java | 60 ++ .../internal/dto/DestinationContainer.java | 24 + .../internal/dto/NetworkError.java | 38 + .../internal/dto/auth/AuthResponse.java | 29 + .../internal/dto/charge/ChargeProfile.java | 24 + .../internal/dto/charge/ChargingWindow.java | 23 + .../internal/dto/charge/Timer.java | 35 + .../internal/dto/charge/WeeklyPlanner.java | 30 + .../internal/dto/compat/CBSMessageCompat.java | 28 + .../internal/dto/compat/CCMMessageCompat.java | 26 + .../dto/compat/VehicleAttributes.java | 142 +++ .../compat/VehicleAttributesContainer.java | 23 + .../internal/dto/compat/VehicleMessages.java | 26 + .../internal/dto/discovery/Dealer.java | 27 + .../internal/dto/discovery/Vehicle.java | 58 ++ .../dto/discovery/VehiclesContainer.java | 24 + .../internal/dto/remote/ExecutionStatus.java | 24 + .../dto/remote/ExecutionStatusContainer.java | 22 + .../internal/dto/statistics/AllTrips.java | 31 + .../dto/statistics/AllTripsContainer.java | 22 + .../statistics/CommunityChargeCycleEntry.java | 26 + .../CommunityEletricDistanceEntry.java | 25 + .../dto/statistics/CommunityPowerEntry.java | 25 + .../internal/dto/statistics/LastTrip.java | 36 + .../dto/statistics/LastTripContainer.java | 22 + .../internal/dto/status/CBSMessage.java | 68 ++ .../internal/dto/status/CCMMessage.java | 30 + .../internal/dto/status/Doors.java | 29 + .../internal/dto/status/Position.java | 36 + .../internal/dto/status/VehicleStatus.java | 73 ++ .../dto/status/VehicleStatusContainer.java | 22 + .../internal/dto/status/Windows.java | 29 + .../BMWConnectedDriveOptionProvider.java | 41 + .../handler/ByteResponseCallback.java | 26 + .../handler/ConnectedDriveBridgeHandler.java | 213 ++++ .../internal/handler/ConnectedDriveProxy.java | 324 ++++++ .../handler/RemoteServiceHandler.java | 199 ++++ .../internal/handler/ResponseCallback.java | 26 + .../handler/StringResponseCallback.java | 27 + .../internal/handler/Token.java | 55 + .../handler/VehicleChannelHandler.java | 515 ++++++++++ .../internal/handler/VehicleHandler.java | 793 ++++++++++++++ .../internal/handler/simulation/Injector.java | 43 + .../internal/utils/BimmerConstants.java | 65 ++ .../internal/utils/ChargeProfileUtils.java | 136 +++ .../internal/utils/ChargeProfileWrapper.java | 299 ++++++ .../internal/utils/Constants.java | 96 ++ .../internal/utils/Converter.java | 298 ++++++ .../internal/utils/HTTPConstants.java | 44 + .../internal/utils/ImageProperties.java | 49 + .../internal/utils/RemoteServiceUtils.java | 51 + .../internal/utils/VehicleStatusUtils.java | 141 +++ .../main/resources/OH-INF/binding/binding.xml | 9 + .../resources/OH-INF/config/bridge-config.xml | 28 + .../resources/OH-INF/config/thing-config.xml | 45 + .../i18n/bmwconnecteddrive_de.properties | 266 +++++ .../OH-INF/thing/bridge-connected-drive.xml | 12 + .../OH-INF/thing/charge-channel-groups.xml | 49 + .../OH-INF/thing/charge-channel-types.xml | 208 ++++ .../thing/check-control-channel-types.xml | 19 + .../OH-INF/thing/check-control-group.xml | 15 + .../OH-INF/thing/conv-range-channel-group.xml | 16 + .../thing/destination-channel-types.xml | 14 + .../OH-INF/thing/destination-group.xml | 14 + .../thing/door-status-channel-types.xml | 66 ++ .../OH-INF/thing/doors-status-group.xml | 24 + .../OH-INF/thing/ev-last-trip-group.xml | 18 + .../OH-INF/thing/ev-lifetime-group.xml | 16 + .../OH-INF/thing/ev-range-channel-group.xml | 16 + .../OH-INF/thing/ev-vehicle-status-group.xml | 21 + .../OH-INF/thing/hybrid-last-trip-group.xml | 19 + .../OH-INF/thing/hybrid-lifetime-group.xml | 17 + .../thing/hybrid-range-channel-group.xml | 20 + .../OH-INF/thing/image-channel-group.xml | 15 + .../OH-INF/thing/image-channel-types.xml | 28 + .../OH-INF/thing/last-trip-channel-types.xml | 45 + .../OH-INF/thing/lifetime-channel-types.xml | 34 + .../OH-INF/thing/location-channel-group.xml | 14 + .../OH-INF/thing/location-channel-types.xml | 15 + .../OH-INF/thing/range-channel-types.xml | 51 + .../thing/remote-services-channel-group.xml | 14 + .../thing/remote-services-channel-types.xml | 15 + .../OH-INF/thing/service-channel-types.xml | 24 + .../resources/OH-INF/thing/service-group.xml | 16 + .../main/resources/OH-INF/thing/thing-bev.xml | 34 + .../resources/OH-INF/thing/thing-bev_rex.xml | 34 + .../resources/OH-INF/thing/thing-conv.xml | 31 + .../resources/OH-INF/thing/thing-phev.xml | 34 + .../thing/vehicle-status-channel-types.xml | 51 + .../OH-INF/thing/vehicle-status-group.xml | 19 + .../internal/discovery/DiscoveryTest.java | 99 ++ .../internal/dto/ChargeProfileTest.java | 44 + .../internal/dto/ConnectedDriveTest.java | 57 ++ .../internal/dto/DestinationTest.java | 50 + .../internal/dto/LastTripTest.java | 43 + .../internal/dto/LifetimeWrapper.java | 186 ++++ .../internal/dto/RemoteStatusTest.java | 43 + .../internal/dto/StatusWrapper.java | 517 ++++++++++ .../internal/dto/TripWrapper.java | 172 ++++ .../internal/dto/VehicleStatusTest.java | 76 ++ .../internal/handler/AllTripTests.java | 136 +++ .../internal/handler/AuthTest.java | 75 ++ .../internal/handler/ChargeProfileTest.java | 120 +++ .../internal/handler/ConfigurationTest.java | 47 + .../internal/handler/ErrorResponseTest.java | 78 ++ .../internal/handler/FingerprintTest.java | 64 ++ .../internal/handler/LastTripTests.java | 136 +++ .../internal/handler/SimulationTest.java | 33 + .../internal/handler/VehicleTests.java | 418 ++++++++ .../internal/util/FileReader.java | 48 + .../internal/util/LocaleTest.java | 82 ++ .../resources/api/vehicle/efficiency.json | 85 ++ .../resources/api/vehicle/navigation.json | 12 + .../src/test/resources/api/vehicle/test.json | 107 ++ .../resources/api/vehicle/vehicle-ccm.json | 117 +++ .../test/resources/api/vehicle/vehicle.json | 108 ++ .../resources/api/vehicle/webapi-status.json | 76 ++ .../resources/responses/530E/all-trips.json | 40 + .../responses/530E/charge-profile.json | 42 + .../resources/responses/530E/discovery.json | 46 + .../resources/responses/530E/last-trip.json | 18 + .../test/resources/responses/530E/status.json | 72 ++ .../responses/F11/vehicle-status.json | 46 + .../test/resources/responses/F15/status.json | 66 ++ .../resources/responses/F31/status-318i.json | 67 ++ .../test/resources/responses/F31/status.json | 14 + .../test/resources/responses/F35/status.json | 12 + .../test/resources/responses/F45/status.json | 12 + .../test/resources/responses/F48/status.json | 62 ++ .../responses/G31_NBTevo/auth_response.json | 7 + .../responses/G31_NBTevo/flash_delivered.json | 10 + .../responses/G31_NBTevo/flash_executed.json | 11 + .../responses/G31_NBTevo/flash_initiated.json | 7 + .../responses/G31_NBTevo/flash_pending.json | 10 + .../responses/G31_NBTevo/status.json | 55 + .../G31_NBTevo/status_position_disabled.json | 52 + .../resources/responses/I01_NOREX/status.json | 61 ++ .../responses/I01_REX/all-trips.json | 40 + .../responses/I01_REX/charge-profile.json | 41 + .../responses/I01_REX/discovery.json | 63 ++ .../responses/I01_REX/last-trip.json | 19 + .../resources/responses/I01_REX/status.json | 61 ++ .../test/resources/responses/vehicles.json | 450 ++++++++ .../src/test/resources/webapi/all-trips.json | 40 + .../resources/webapi/charging-profile.json | 41 + .../webapi/connected-drive-account-info.json | 63 ++ .../test/resources/webapi/destinations.json | 94 ++ .../src/test/resources/webapi/last-trip.json | 19 + .../webapi/remote-services/delivered.json | 10 + .../webapi/remote-services/executed.json | 12 + .../webapi/remote-services/pending.json | 10 + .../webapi/vehicle-status-ccm-tyre.json | 87 ++ .../webapi/vehicle-status-charging.json | 77 ++ .../test/resources/webapi/vehicle-status.json | 77 ++ bundles/pom.xml | 1 + 176 files changed, 12877 insertions(+) create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/NOTICE create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/README.md create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/doc/AwayImage.png create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/doc/CarStatusImages.png create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/doc/ChargingImage.png create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/doc/CheckControlImage.png create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/doc/ServiceOptions.png create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/doc/UnlockedImage.png create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/doc/panel.png create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/doc/properties.png create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/doc/range-radius.png create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/pom.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/feature/feature.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/ConnectedDriveConfiguration.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/ConnectedDriveConstants.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/ConnectedDriveHandlerFactory.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/VehicleConfiguration.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/action/BMWConnectedDriveActions.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/discovery/VehicleDiscovery.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/Destination.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/DestinationContainer.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/NetworkError.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/auth/AuthResponse.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/charge/ChargeProfile.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/charge/ChargingWindow.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/charge/Timer.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/charge/WeeklyPlanner.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/compat/CBSMessageCompat.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/compat/CCMMessageCompat.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/compat/VehicleAttributes.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/compat/VehicleAttributesContainer.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/compat/VehicleMessages.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/discovery/Dealer.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/discovery/Vehicle.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/discovery/VehiclesContainer.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/remote/ExecutionStatus.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/remote/ExecutionStatusContainer.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/statistics/AllTrips.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/statistics/AllTripsContainer.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/statistics/CommunityChargeCycleEntry.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/statistics/CommunityEletricDistanceEntry.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/statistics/CommunityPowerEntry.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/statistics/LastTrip.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/statistics/LastTripContainer.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/status/CBSMessage.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/status/CCMMessage.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/status/Doors.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/status/Position.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/status/VehicleStatus.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/status/VehicleStatusContainer.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/dto/status/Windows.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/handler/BMWConnectedDriveOptionProvider.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/handler/ByteResponseCallback.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/handler/ConnectedDriveBridgeHandler.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/handler/ConnectedDriveProxy.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/handler/RemoteServiceHandler.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/handler/ResponseCallback.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/handler/StringResponseCallback.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/handler/Token.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/handler/VehicleChannelHandler.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/handler/VehicleHandler.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/handler/simulation/Injector.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/utils/BimmerConstants.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/utils/ChargeProfileUtils.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/utils/ChargeProfileWrapper.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/utils/Constants.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/utils/Converter.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/utils/HTTPConstants.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/utils/ImageProperties.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/utils/RemoteServiceUtils.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/java/org/openhab/binding/bmwconnecteddrive/internal/utils/VehicleStatusUtils.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/binding/binding.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/config/bridge-config.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/config/thing-config.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/i18n/bmwconnecteddrive_de.properties create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/bridge-connected-drive.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/charge-channel-groups.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/charge-channel-types.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/check-control-channel-types.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/check-control-group.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/conv-range-channel-group.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/destination-channel-types.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/destination-group.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/door-status-channel-types.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/doors-status-group.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/ev-last-trip-group.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/ev-lifetime-group.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/ev-range-channel-group.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/ev-vehicle-status-group.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/hybrid-last-trip-group.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/hybrid-lifetime-group.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/hybrid-range-channel-group.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/image-channel-group.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/image-channel-types.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/last-trip-channel-types.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/lifetime-channel-types.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/location-channel-group.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/location-channel-types.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/range-channel-types.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/remote-services-channel-group.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/remote-services-channel-types.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/service-channel-types.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/service-group.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/thing-bev.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/thing-bev_rex.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/thing-conv.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/thing-phev.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/vehicle-status-channel-types.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/main/resources/OH-INF/thing/vehicle-status-group.xml create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/discovery/DiscoveryTest.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/dto/ChargeProfileTest.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/dto/ConnectedDriveTest.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/dto/DestinationTest.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/dto/LastTripTest.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/dto/LifetimeWrapper.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/dto/RemoteStatusTest.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/dto/StatusWrapper.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/dto/TripWrapper.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/dto/VehicleStatusTest.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/handler/AllTripTests.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/handler/AuthTest.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/handler/ChargeProfileTest.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/handler/ConfigurationTest.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/handler/ErrorResponseTest.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/handler/FingerprintTest.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/handler/LastTripTests.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/handler/SimulationTest.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/handler/VehicleTests.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/util/FileReader.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/java/org/openhab/binding/bmwconnecteddrive/internal/util/LocaleTest.java create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/api/vehicle/efficiency.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/api/vehicle/navigation.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/api/vehicle/test.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/api/vehicle/vehicle-ccm.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/api/vehicle/vehicle.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/api/vehicle/webapi-status.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/530E/all-trips.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/530E/charge-profile.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/530E/discovery.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/530E/last-trip.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/530E/status.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/F11/vehicle-status.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/F15/status.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/F31/status-318i.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/F31/status.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/F35/status.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/F45/status.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/F48/status.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/G31_NBTevo/auth_response.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/G31_NBTevo/flash_delivered.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/G31_NBTevo/flash_executed.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/G31_NBTevo/flash_initiated.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/G31_NBTevo/flash_pending.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/G31_NBTevo/status.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/G31_NBTevo/status_position_disabled.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/I01_NOREX/status.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/I01_REX/all-trips.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/I01_REX/charge-profile.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/I01_REX/discovery.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/I01_REX/last-trip.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/I01_REX/status.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/responses/vehicles.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/webapi/all-trips.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/webapi/charging-profile.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/webapi/connected-drive-account-info.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/webapi/destinations.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/webapi/last-trip.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/webapi/remote-services/delivered.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/webapi/remote-services/executed.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/webapi/remote-services/pending.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/webapi/vehicle-status-ccm-tyre.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/webapi/vehicle-status-charging.json create mode 100644 bundles/org.openhab.binding.bmwconnecteddrive/src/test/resources/webapi/vehicle-status.json diff --git a/CODEOWNERS b/CODEOWNERS index 9f5136c9d..3a9dcf65f 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -37,6 +37,7 @@ /bundles/org.openhab.binding.bluetooth.govee/ @cpmeister /bundles/org.openhab.binding.bluetooth.roaming/ @cpmeister /bundles/org.openhab.binding.bluetooth.ruuvitag/ @ssalonen +/bundles/org.openhab.binding.bmwconnecteddrive/ @weymann @ntruchsess /bundles/org.openhab.binding.boschindego/ @jofleck /bundles/org.openhab.binding.boschshc/ @stefan-kaestle @coeing @GerdZanker /bundles/org.openhab.binding.bosesoundtouch/ @marvkis @tratho diff --git a/bom/openhab-addons/pom.xml b/bom/openhab-addons/pom.xml index c6d486fce..82397f5e9 100644 --- a/bom/openhab-addons/pom.xml +++ b/bom/openhab-addons/pom.xml @@ -171,6 +171,11 @@ org.openhab.binding.bluetooth.ruuvitag ${project.version} + + org.openhab.addons.bundles + org.openhab.binding.bmwconnecteddrive + ${project.version} + org.openhab.addons.bundles org.openhab.binding.boschindego diff --git a/bundles/org.openhab.binding.bmwconnecteddrive/NOTICE b/bundles/org.openhab.binding.bmwconnecteddrive/NOTICE new file mode 100644 index 000000000..38d625e34 --- /dev/null +++ b/bundles/org.openhab.binding.bmwconnecteddrive/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.bmwconnecteddrive/README.md b/bundles/org.openhab.binding.bmwconnecteddrive/README.md new file mode 100644 index 000000000..2ed6771af --- /dev/null +++ b/bundles/org.openhab.binding.bmwconnecteddrive/README.md @@ -0,0 +1,964 @@ +# BMW ConnectedDrive Binding + +The binding provides a connection between [BMW's ConnectedDrive Portal](https://www.bmw-connecteddrive.com/country-region-select/country-region-selection.html) and openHAB. +All vehicles connected to an account will be detected by the discovery with the correct type + +* Conventional Fuel Vehicle +* Plugin-Hybrid Electrical Vehicle +* Battery Electric Vehicle with Range Extender +* Battery Electric Vehicle + +In addition properties are attached with information and services provided by this vehicle. +The provided data depends on + +1. the [Thing Type](#things) and +2. the [Properties](#properties) mentioned in Services + +Different channel groups are clustering all informations. +Check for each group if it's supported for this Vehicle. + +Please note **this isn't a real-time binding**. +If a door is opened the state isn't transmitted and changed immediately. +This isn't a flaw in the binding itself because the state in BMW's own ConnectedDrive App is also updated with some delay. + +## Supported Things + +### Bridge + +The bridge establishes the connection between BMW's ConnectedDrive Portal and openHAB. + +| Name | Bridge Type ID | Description | +|----------------------------|----------------|------------------------------------------------------------| +| BMW ConnectedDrive Account | `account` | Access to BMW ConnectedDrive Portal for a specific user | + + +### Things + +Four different vehicle types are provided. +They differ in the supported channel groups & channels. +Conventional Fuel Vehicles have no _Charging Profile_, Electric Vehicles don't provide a _Fuel Range_. +For hybrid vehicles in addition to _Fuel and Electric Range_ the _Hybrid Range_ is shown. + +| Name | Thing Type ID | Supported Channel Groups | +|-------------------------------------|---------------|--------------------------------------------------------| +| BMW Electric Vehicle | `bev` | status, range, location, service, check, charge, image | +| BMW Electric Vehicle with REX | `bev_rex` | status, range, location, service, check, charge, image | +| BMW Plug-In-Hybrid Electric Vehicle | `phev` | status, range, location, service, check, charge, image | +| BMW Conventional Vehicle | `conv` | status, range, location, service, check, image | + + +#### Properties + + + +For each vehicle properties are available. +Basically 3 types of information are registered as properties + +* Informations regarding your dealer with address and phone number +* Which services are available / not available +* Vehicle properties like color, model type, drive train and construction year + +In the right picture can see in *Services Activated* e.g. the *DoorLock* and *DoorUnlock* services are mentioned. +This ensures channel group [Remote Services](#remote-services) is supporting door lock and unlock remote control. + +In *Services Supported* the entry *LastDestination* is mentioned. +So it's valid to connect channel group [Last Destinations](#destinations) in order to display and select the last navigation destinations. + +| Property Key | Property Value | Supported Channel Groups | +|--------------------|---------------------|------------------------------| +| servicesSupported | Statistics | last-trip, lifetime | +| servicesSupported | LastDestinations | destinations | +| servicesActivated | _list of services_ | remote | + + +## Discovery + +Auto discovery is starting after the bridge towards BMW's ConnectedDrive is created. +A list of your registered vehicles is queried and all found things are added in the inbox. +Unique identifier is the *Vehicle Identification Number* (VIN). +If a thing is already declared in a _.things_ configuration, discovery won't highlight it again. +Properties will be attached to predefined vehicles if the VIN is matching. + +## Configuration + +### Bridge Configuration + +| Parameter | Type | Description | +|-----------------|---------|--------------------------------------------------------------------| +| userName | text | BMW ConnectedDrive Username | +| password | text | BMW ConnectedDrive Password | +| region | text | Select region in order to connect to the appropriate BMW server. | + +The region Configuration has 3 different options + +* _NORTH_AMERICA_ +* _CHINA_ +* _ROW_ (Rest of World) + +### Thing Configuration + +Same configuration is needed for all things + +| Parameter | Type | Description | +|-----------------|---------|---------------------------------------| +| vin | text | Vehicle Identification Number (VIN) | +| refreshInterval | integer | Refresh Interval in Minutes | +| units | text | Unit Selection. See below. | +| imageSize | integer | Image Size | +| imageViewport | text | Image Viewport | + +The unit configuration has 3 options + +* _AUTODETECT_ selects miles for US & UK, kilometer otherwise +* _METRIC_ selects directly kilometers +* _IMPERIAL_ selects directly miles + +The _imageVieport_ allows to show the vehicle from different angels. +Possible options are + +* _FRONT_ +* _REAR_ +* _SIDE_ +* _DASHBOARD_ +* _DRIVERDOOR_ + +## Channels + +There are many channels available for each vehicle. +For better overview they are clustered in different channel groups. +They differ for each vehicle type, build-in sensors and activated services. + + +### Thing Channel Groups + +#### Vehicle Status + +Reflects overall status of the vehicle. + +* Channel Group ID is **status** +* Available for all vehicles +* Read-only values + +| Channel Label | Channel ID | Type | Description | +|---------------------------|---------------------|---------------|------------------------------------------------| +| Overall Door Status | doors | String | Combined status for all doors | +| Overall Window Status | windows | String | Combined status for all windows | +| Doors Locked | lock | String | Status if doors are locked or unlocked | +| Next Service Date | service-date | DateTime | Date of upcoming service | +| Mileage till Next Service | service-mileage | Number:Length | Mileage till upcoming service | +| Check Control | check-control | String | Presence of active warning messages | +| Charging Status | charge | String | Only available for phev, bev_rex and bev | +| Last Status Timestamp | last-update | DateTime | Date and time of last status update | + +Overall Door Status values + +* _Closed_ - all doors closed +* _Open_ - at least one door is open +* _Undef_ - no door data delivered at all + +Overall Windows Status values + +* _Closed_ - all windows closed +* _Open_ - at least one window is completely open +* _Intermediate_ - at least one window is partially open +* _Undef_ - no window data delivered at all + +Check Control values + +* _Active_ - at least one warning message is active +* _Not Active_ - no warning message is active +* _Undef_ - no data for warnings delivered + +Charging Status values + +* _Charging_ +* _Error_ +* _Finished Fully Charged_ +* _Finished Not Full_ +* _Invalid_ +* _Not Charging_ +* _Charging Goal reached_ +* _Waiting For Charging_ + +#### Services + +Group for all upcoming services with description, service date and/or service mileage. +If more than one service is scheduled in the future the channel _name_ contains all future services as options. + +* Channel Group ID is **service** +* Available for all vehicles +* Read/Write access + +| Channel Label | Channel ID | Type | Access | +|--------------------------------|---------------------|----------------|------------| +| Service Name | name | String | Read/Write | +| Service Details | details | String | Read | +| Service Date | date | Number | Read | +| Mileage till Service | mileage | Number:Length | Read | + +#### Check Control + +Group for all current active CheckControl messages. +If more than one message is active the channel _name_ contains all active messages as options. + +* Channel Group ID is **check** +* Available for all vehicles +* Read/Write access + +| Channel Label | Channel ID | Type | Access | +|---------------------------------|---------------------|----------------|------------| +| CheckControl Description | name | String | Read/Write | +| CheckControl Details | details | String | Read | +| Mileage Occurrence | mileage | Number:Length | Read | + +#### Doors Details + +Detailed status of all doors and windows. + +* Channel Group ID is **doors** +* Available for all vehicles if corresponding sensors are built-in +* Read-only values + +| Channel Label | Channel ID | Type | +|----------------------------|-------------------------|---------------| +| Driver Door | driver-front | String | +| Driver Door Rear | driver-rear | String | +| Passenger Door | passenger-front | String | +| Passenger Door Rear | passenger-rear | String | +| Trunk | trunk | String | +| Hood | hood | String | +| Driver Window | win-driver-front | String | +| Driver Rear Window | win-driver-rear | String | +| Passenger Window | win-passenger-front | String | +| Passenger Rear Window | win-passenger-rear | String | +| Rear Window | win-rear | String | +| Sunroof | sunroof | String | + +Possible states + +* _Undef_ - no status data available +* _Invalid_ - this door / window isn't applicable for this vehicle +* _Closed_ - the door / window is closed +* _Open_ - the door / window is open +* _Intermediate_ - window in intermediate position, not applicable for doors + +#### Range Data + +Based on vehicle type some channels are present or not. +Conventional fuel vehicles don't provide *Electric Range* and battery electric vehicles don't show *Fuel Range*. +Hybrid vehicles have both and in addition *Hybrid Range*. +See description [Range vs Range Radius](#range-vs-range-radius) to get more information. + +* Channel Group ID is **range** +* Availability according to table +* Read-only values + +| Channel Label | Channel ID | Type | conv | phev | bev_rex | bev | +|-----------------------|-----------------------|----------------------|------|------|---------|-----| +| Mileage | mileage | Number:Length | X | X | X | X | +| Fuel Range | range-fuel | Number:Length | X | X | X | | +| Battery Range | range-electric | Number:Length | | X | X | X | +| Hybrid Range | range-hybrid | Number:Length | | X | X | | +| Battery Charge Level | soc | Number:Dimensionless | | X | X | X | +| Remaining Fuel | remaining-fuel | Number:Volume | X | X | X | | +| Fuel Range Radius | range-radius-fuel | Number:Length | X | X | X | | +| Electric Range Radius | range-radius-electric | Number:Length | | X | X | X | +| Hybrid Range Radius | range-radius-hybrid | Number:Length | | X | X | | + + +#### Charge Profile + +Charging options with date and time for preferred time windows and charging modes. + +* Channel Group ID is **charge** +* Available for electric and hybrid vehicles +* Read/Write access for UI. Use [Charge Profile Editing Action](#charge-profile-editing) in rules +* There are 3 timers *T1, T2 and T3* available. Replace *X* with number 1,2 or 3 to target the correct timer +* Additional override Timer *OT* defines a single departure besides the 3 predefined schedule timers + +| Channel Label | Channel Group ID | Channel ID | Type | +|----------------------------|------------------|---------------------------|----------| +| Charge Mode | charge | profile-mode | String | +| Charge Preferences | charge | profile-prefs | String | +| Window Start Time | charge | window-start | DateTime | +| Window End Time | charge | window-end | DateTime | +| A/C at Departure | charge | profile-climate | Switch | +| T*X* Enabled | charge | timer*X*-enabled | Switch | +| T*X* Departure Time | charge | timer*X*-departure | DateTime | +| T*X* Days | charge | timer*X*-days | String | +| T*X* Monday | charge | timer*X*-day-mon | Switch | +| T*X* Tuesday | charge | timer*X*-day-tue | Switch | +| T*X* Wednesday | charge | timer*X*-day-wed | Switch | +| T*X* Thursday | charge | timer*X*-day-thu | Switch | +| T*X* Friday | charge | timer*X*-day-fri | Switch | +| T*X* Saturday | charge | timer*X*-day-sat | Switch | +| T*X* Sunday | charge | timer*X*-day-sun | Switch | +| OT Enabled | charge | override-enabled | Switch | +| OT Departure Time | charge | override-departure | DateTime | + +The channel _profile-mode_ supports + +* *IMMEDIATE_CHARGING* +* *DELAYED_CHARGING* + +The channel _profile-prefs_ supports + +* *NO_PRESELECTION* +* *CHARGING_WINDOW* + +#### Location + +GPS location and heading of the vehicle. + +* Channel Group ID is **location** +* Available for all vehicles with built-in GPS sensor. Function can be enabled/disabled in the head unit +* Read-only values + +| Channel Label | Channel ID | Type | +|-----------------|---------------------|--------------| +| GPS Coordinates | gps | Location | +| Heading | heading | Number:Angle | + +#### Last Trip + +Statistic values of duration, distance and consumption of the last trip. + +* Channel Group ID is **last-trip** +* Available if *Statistics* is present in *Services Supported*. See [Vehicle Properties](#properties) for further details +* Read-only values +* Depending on units configuration in [Thing Configuration](#thing-configuration) average values are given for 100 kilometers or miles + +| Channel Label | Channel ID | Type | +|-----------------------------------------|------------------------------|---------------| +| Last Trip Date | date | DateTime | +| Last Trip Duration | duration | Number:Time | +| Last Trip Distance | distance | Number:Length | +| Distance since Charge | distance-since-charging | Number:Length | +| Avg. Power Consumption | avg-consumption | Number:Power | +| Avg. Power Recuperation | avg-recuperation | Number:Power | +| Avg. Combined Consumption | avg-combined-consumption | Number:Volume | + + +#### Lifetime Statistics + +Providing lifetime consumption values. + +* Channel Group ID is **lifetime** +* Available if *Statistics* is present in *Services Supported*. See [Vehicle Properties](#properties) for further details +* Read-only values +* Depending on units configuration in [Thing Configuration](#thing-configuration) average values are given for 100 kilometers or miles + +| Channel Label | Channel ID | Type | +|-----------------------------------------|------------------------------|---------------| +| Total Electric Distance | total-driven-distance | Number:Length | +| Longest 1-Charge Distance | single-longest-distance | Number:Length | +| Avg. Power Consumption | avg-consumption | Number:Power | +| Avg. Power Recuperation | avg-recuperation | Number:Power | +| Avg. Combined Consumption | avg-combined-consumption | Number:Volume | + + +#### Remote Services + +Remote control of the vehicle. +Send a *command* to the vehicle and the *state* is reporting the execution progress. +Only one command can be executed each time. +Parallel execution isn't supported. + +* Channel Group ID is **remote** +* Available for all commands mentioned in *Services Activated*. See [Vehicle Properties](#properties) for further details +* Read/Write access + + +| Channel Label | Channel ID | Type | Access | +|-------------------------|---------------------|---------|--------| +| Remote Service Command | command | String | Write | +| Service Execution State | state | String | Read | + +The channel _command_ provides options + +* _Flash Lights_ +* _Vehicle Finder_ +* _Door Lock_ +* _Door Unlock_ +* _Horn Blow_ +* _Climate Control_ +* _Start Charging_ +* _Send Charging Profile_ + +The channel _state_ shows the progress of the command execution in the following order + +1) _Initiated_ +2) _Pending_ +3) _Delivered_ +4) _Executed_ + +#### Destinations + +Shows the last destinations stored in the navigation system. +If several last destinations are stored in the navigation system the channel _name_ contains all addresses as options. + +* Channel Group ID is **destination** +* Available if *LastDestinations* is present in *Services Supported*. Check [Vehicle Properties](#properties) for further details +* Read/Write access + + +| Channel Label | Channel ID | Type | Access | +|----------------------|---------------|-----------|-------------| +| Name | name | String | Read/Write | +| GPS Coordinates | gps | Location | Read | + + + +#### Image + +Image representation of the vehicle. Size and viewport are writable and can be +The possible values are the same mentioned in [Thing Configuration](#thing-configuration). + +* Channel Group ID is **image** +* Available for all vehicles +* Read/Write access + +| Channel Label | Channel ID | Type | Access | +|----------------------------|---------------------|--------|----------| +| Rendered Vehicle Image | png | Image | Read | +| Image Viewport | view | String | Write | +| Image Picture Size | size | Number | Write | + +## Actions + +Get the _Actions_ object for your vehicle using the Thing ID + +* bmwconnecteddrive - Binding ID, don't change! +* bev_rex - [Thing UID](#things) of your car +* user - Thing ID of the [Bridge](#bridge) +* i3 - Thing ID of your car + +``` + val profile = getActions("bmwconnecteddrive", "bmwconnecteddrive:bev_rex:user:i3") +``` + +### Charge Profile Editing + +Like in the Charge Profile Channels 3 Timers are provided. Replace *X* with 1, 2 or 3 to address the right timer. + +| Function | Parameters | Returns | Description | +|---------------------------------------|------------------|---------------------------|------------------------------------------------------------| +| getClimatizationEnabled | void | Boolean | Returns the enabled state of climatization | +| setClimatizationEnabled | Boolean | void | Sets the enabled state of climatization | +| getChargingMode | void | String | Gets the charging-mode, see valid options below | +| setChargingMode | String | void | Sets the charging-mode, see valid options below | +| getPreferredWindowStart | void | LocalTime | Returns the preferred charging-window start time | +| setPreferredWindowStart | LocalTime | void | Sets the preferred charging-window start time | +| getPreferredWindowEnd | void | LocalTime | Returns the preferred charging-window end time | +| setPreferredWindowEnd | LocalTime | void | Sets the preferred charging-window end time | +| getTimer*X*Enabled | void | Boolean | Returns the enabled state of timer*X* | +| setTimer*X*Enabled | Boolean | void | Returns the enabled state of timer*X* | +| getTimer*X*Departure | void | LocalTime | Returns the departure time of timer*X* | +| setTimer*X*Departure | LocalTime | void | Sets the timer*X* departure time | +| getTimer*X*Days | void | Set | Returns the days of week timer*X* is enabled for | +| setTimer*X*Days | Set | void | sets the days of week timer*X* is enabled for | +| getOverrideTimerEnabled | void | Boolean | Returns the enabled state of override timer | +| setOverrideTimerEnabled | Boolean | void | Sets the enabled state of override timer | +| getOverrideTimerDeparture | void | LocalTime | Returns the departure time of override timer | +| setOverrideTimerDeparture | LocalTime | void | Sets the override timer departure time | +| getOverrideTimerDays | void | Set | Returns the days of week the overrideTimer is enabled for | +| setOverrideTimerDays | Set | void | Sets the days of week the overrideTimer is enabled for | +| cancelEditChargeProfile | void | void | Cancel current edit of charging profile | +| sendChargeProfile | void | void | Sends the charging profile to the vehicle | + +Values for valid charging mode get/set + +* *IMMEDIATE_CHARGING* +* *DELAYED_CHARGING* + + +## Further Descriptions + +### Dynamic Data + + + +There are 3 occurrences of dynamic data delivered + +* Upcoming Services delivered in group [Services](#services) +* Check Control Messages delivered in group [Check Control](#check-control) +* Last Destinations delivered in group [Destinations](#destinations) + +The channel id _name_ shows the first element as default. +All other possibilities are attached as options. +The picture on the right shows the _Service Name_ item and all four possible options. +Select the desired service and the corresponding _Service Date & Milage_ will be shown. + +### TroubleShooting + +BMW has a high range of vehicles supported by ConnectedDrive. +In case of any issues with this binding help to resolve it! +Please perform the following steps: + +* Can you [log into ConnectedDrive](https://www.bmw-connecteddrive.com/country-region-select/country-region-selection.html) with your credentials? Please note this isn't the BMW Customer portal - it's the ConnectedDrive portal +* Is the vehicle listed in your account? There's a one-to-one relation from user to vehicle + +If the access to the portal is working and the vehicle is listed some debug data is needed in order to identify the issue. + +#### Generate Debug Fingerprint + +If you checked the above pre-conditions you need to get the debug fingerprint from the logs. +First [enable debug logging](https://www.openhab.org/docs/administration/logging.html#defining-what-to-log) for the binding. + +``` +log:set DEBUG org.openhab.binding.bmwconnecteddrive +``` + +The debug fingerprint is generated immediately after the vehicle thing is initialized the first time, e.g. after openHAB startup. +To force a new fingerprint disable the thing shortly and enable it again. +Personal data is eliminated from the log entries so it should be possible to share them in public. +Data like + +* Dealer Properties +* Vehicle Identification Number (VIN) +* Location latitude / longitude + +are anonymized. +You'll find the fingerprint in the logs with the command + +``` +grep "Troubleshoot Fingerprint Data" openhab.log +``` + +After the corresponding fingerprint is generated please [follow the instructions to raise an issue](https://community.openhab.org/t/how-to-file-an-issue/68464) and attach the fingerprint data! +Your feedback is highly appreciated! + + +### Range vs Range Radius + + + +You will observe differences in the vehicle range and range radius values. +While range is indicating the possible distance to be driven on roads the range radius indicates the reachable range on the map. + +The right picture shows the distance between Kassel and Frankfurt in Germany. +While the air-line distance is ~145 kilometer the route distance is ~192 kilometer. +So range value is the normal remaining range while the range radius values can be used e.g. on [Mapview](https://www.openhab.org/docs/configuration/sitemaps.html#element-type-mapview) to indicate the reachable range on map. +Please note this is just an indicator of the effective range. +Especially for electric vehicles it depends on many factors like driving style and usage of electric consumers. + +## Full Example + +The example is based on a BMW i3 with range extender (REX). +Exchange the three configuration parameters in the Things section + +* YOUR_USERNAME - with your ConnectedDrive login username +* YOUR_PASSWORD - with your ConnectedDrive password credentials +* VEHICLE_VIN - the vehicle identification number + +In addition search for all occurrences of *i3* and replace it with your Vehicle Identification like *x3* or *535d* and you're ready to go! + +### Things File + +``` +Bridge bmwconnecteddrive:account:user "BMW ConnectedDrive Account" [userName="YOUR_USERNAME",password="YOUR_PASSWORD",region="ROW"] { + Thing bev_rex i3 "BMW i3 94h REX" [ vin="VEHICLE_VIN",units="AUTODETECT",imageSize=600,imageViewport="FRONT",refreshInterval=5] +} +``` + +### Items File + +``` +Number:Length i3Mileage "Odometer [%d %unit%]" (i3) {channel="bmwconnecteddrive:bev_rex:user:i3:range#mileage" } +Number:Length i3Range "Range [%d %unit%]" (i3) {channel="bmwconnecteddrive:bev_rex:user:i3:range#hybrid"} +Number:Length i3RangeElectric "Electric Range [%d %unit%]" (i3,long) {channel="bmwconnecteddrive:bev_rex:user:i3:range#electric"} +Number:Length i3RangeFuel "Fuel Range [%d %unit%]" (i3) {channel="bmwconnecteddrive:bev_rex:user:i3:range#fuel"} +Number:Dimensionless i3BatterySoc "Battery Charge [%.1f %%]" (i3,long) {channel="bmwconnecteddrive:bev_rex:user:i3:range#soc"} +Number:Volume i3Fuel "Fuel [%.1f %unit%]" (i3) {channel="bmwconnecteddrive:bev_rex:user:i3:range#remaining-fuel"} +Number:Length i3RadiusElectric "Electric Radius [%d %unit%]" (i3) {channel="bmwconnecteddrive:bev_rex:user:i3:range#radius-electric" } +Number:Length i3RadiusHybrid "Hybrid Radius [%d %unit%]" (i3) {channel="bmwconnecteddrive:bev_rex:user:i3:range#radius-hybrid" } + +String i3DoorStatus "Door Status [%s]" (i3) {channel="bmwconnecteddrive:bev_rex:user:i3:status#doors" } +String i3WindowStatus "Window Status [%s]" (i3) {channel="bmwconnecteddrive:bev_rex:user:i3:status#windows" } +String i3LockStatus "Lock Status [%s]" (i3) {channel="bmwconnecteddrive:bev_rex:user:i3:status#lock" } +DateTime i3NextServiceDate "Next Service Date [%1$tb %1$tY]" (i3) {channel="bmwconnecteddrive:bev_rex:user:i3:status#service-date" } +String i3NextServiceMileage "Next Service Mileage [%d %unit%]" (i3) {channel="bmwconnecteddrive:bev_rex:user:i3:status#service-mileage" } +String i3CheckControl "Check Control [%s]" (i3) {channel="bmwconnecteddrive:bev_rex:user:i3:status#check-control" } +String i3ChargingStatus "Charging [%s]" (i3) {channel="bmwconnecteddrive:bev_rex:user:i3:status#charge" } +DateTime i3LastUpdate "Update [%1$tA, %1$td.%1$tm. %1$tH:%1$tM]" (i3) {channel="bmwconnecteddrive:bev_rex:user:i3:status#last-update"} + +DateTime i3TripDateTime "Trip Date [%1$tA, %1$td.%1$tm. %1$tH:%1$tM]" (i3) {channel="bmwconnecteddrive:bev_rex:user:i3:last-trip#date"} +Number:Time i3TripDuration "Trip Duration [%d %unit%]"