Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BMW ConnectedDrive] initial contribution #8576

Merged
merged 185 commits into from
May 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
185 commits
Select commit Hold shift + click to select a range
50526d8
initial commit
weymann Aug 17, 2020
30f5647
initial commit
weymann Aug 17, 2020
15f4aed
Range feature added
weymann Aug 23, 2020
e4f68c4
last-trip and lifetime values
weymann Aug 23, 2020
caf8530
add location group
weymann Aug 24, 2020
3f0a812
add location group
weymann Aug 24, 2020
fac2914
switch to webapi
weymann Aug 25, 2020
1de2bb5
local date time conversion
weymann Aug 26, 2020
abf4265
added vehicle status
weymann Aug 26, 2020
e43651b
added vehicle status
weymann Aug 26, 2020
2b01922
add remote services
weymann Aug 27, 2020
f509bc4
reduce logging
weymann Aug 28, 2020
00e0239
Asnyc Jetty Client API
weymann Aug 31, 2020
8a4c05e
Constant cleanup, Network error handling and logging cleanup
weymann Sep 1, 2020
1cfba13
discovery optimization
weymann Sep 1, 2020
0d76c7c
readme.md plus organizational changes
weymann Sep 2, 2020
50b196e
add group destinations
weymann Sep 3, 2020
dd6e5f9
de translations
weymann Sep 5, 2020
1123aef
added all account variables to dto
weymann Sep 5, 2020
22a6656
consistent Vehicle naming
weymann Sep 6, 2020
3773991
HttpClient reorg
weymann Sep 6, 2020
6231032
extended Service Message
weymann Sep 6, 2020
1c610e0
hard-coded checks for StatusWrapper
weymann Sep 7, 2020
3f0bd53
date time corrections
weymann Sep 10, 2020
cc04aa1
more descriptions
weymann Sep 10, 2020
90da4a3
add service rule
weymann Sep 11, 2020
e8f8746
charge status
weymann Sep 11, 2020
68986ef
image channels added
weymann Sep 13, 2020
581ac0f
token handling optimization
weymann Sep 14, 2020
cc86095
http request optimization
weymann Sep 15, 2020
7ef14bb
translation corrections
weymann Sep 15, 2020
caeada3
readme corrections
weymann Sep 15, 2020
f82a77b
readme corrections
weymann Sep 15, 2020
6b6e441
readme corrections
weymann Sep 15, 2020
e25f724
readme corrections
weymann Sep 15, 2020
112f7bc
remove readme.md previews
weymann Sep 15, 2020
8f560ec
change unit test from hard coded date to service name
weymann Sep 15, 2020
0088cfb
remove locale time test
weymann Sep 15, 2020
87520d2
remote state execution status update increase
weymann Sep 15, 2020
557a2ff
update after remote service call
weymann Sep 16, 2020
50e96c5
fix window intermediate state handling
weymann Sep 18, 2020
02bfae2
add service list interface
weymann Sep 21, 2020
6afcc53
final service data list interface adaptions
weymann Sep 21, 2020
1282f07
destinations list interface
weymann Sep 21, 2020
a012189
add check control list
weymann Sep 22, 2020
612a8e0
correct Doors and Windows default values
weymann Sep 22, 2020
e388a0b
remove service-name from status
weymann Sep 22, 2020
9bcb67c
adapt translation to new lists
weymann Sep 23, 2020
3e6315c
adapt translation to new lists
weymann Sep 23, 2020
d74e1c2
move to oh3
weymann Sep 24, 2020
f40f103
fix discovery
weymann Sep 24, 2020
eaa60ce
introduce backward compatibility mode
weymann Sep 27, 2020
04cc162
introduce backward compatibility mode
weymann Sep 27, 2020
e062e37
add backward compatibility unit tests
weymann Sep 28, 2020
e296412
add backward compatibility unit tests
weymann Sep 28, 2020
adb5a0a
bugfix status channel types
weymann Sep 28, 2020
2e4dc42
enable compatibility mode
weymann Sep 28, 2020
8e13318
clear list content after receiving empty list
weymann Sep 29, 2020
6e3cd76
bugfix refresh job cancel
weymann Sep 29, 2020
fe3853a
Injector added to simulate different Vehicles
weymann Oct 5, 2020
a38ad21
Injector added to simulate different Vehicles
weymann Oct 5, 2020
8d61d7a
correct legacy mode
weymann Oct 11, 2020
5e74c52
bugfix fingerprint logging
weymann Oct 11, 2020
2dcb753
add region constants
weymann Oct 26, 2020
44f19e1
Switch to legacy auth like BimmerConnected project
weymann Nov 22, 2020
45b29dd
remove auto generated files
weymann Nov 22, 2020
0b5962a
correct structural review comments
weymann Nov 23, 2020
3c0e233
lower case thing type ids
weymann Nov 23, 2020
b2444d8
introduce Location type for GPS coordinates
weymann Nov 24, 2020
80001e8
satisfy null checker
weymann Nov 24, 2020
974e914
introduce VehicleStatusUtils
weymann Nov 24, 2020
c483c85
introduce ThingHandlerService
weymann Dec 24, 2020
bb64ada
update Units import
weymann Dec 24, 2020
d523ec5
update Units import
weymann Dec 24, 2020
8870834
introduce command description for remote services
weymann Dec 24, 2020
9d9ba93
handle destination list as option list
weymann Dec 25, 2020
257dfee
update list item after first call
weymann Dec 25, 2020
987f6a6
check if selected item is in updated list
weymann Dec 25, 2020
13ccfd5
switch serviceList to options
weymann Dec 25, 2020
2e07630
switch check control list to options
weymann Dec 25, 2020
511b172
rework troubleshoot fingerprint output
weymann Dec 25, 2020
972380c
update servers and constants due to changed authorization
weymann Dec 25, 2020
1f09545
correct readme.md according to code changes
weymann Dec 26, 2020
43d4c34
solve checkstyle warnings
weymann Dec 26, 2020
b80c640
shorten some channel ids
weymann Dec 26, 2020
de0db37
remove fingerprint channel leftovers
weymann Dec 26, 2020
e67a72b
label bugfixes
weymann Dec 26, 2020
0bc45b2
title case adaptions plus minor bugfixes
weymann Dec 27, 2020
292bb68
harmonize readme.md and solved some compiler warnings
weymann Dec 27, 2020
7a8d4cd
introduce TimeZonePRovider
weymann Dec 28, 2020
6ed53d3
readme corrections
weymann Dec 28, 2020
f7241d8
correct review findings
weymann Jan 1, 2021
c183cf3
imperial handling for statistuc values
weymann Jan 2, 2021
85e828b
ensure channel label & id <= 25 chars
weymann Jan 2, 2021
dce959b
update readme refs to thing-configuration
weymann Jan 2, 2021
61acc7f
remove local gitignore
weymann Jan 5, 2021
fb398b1
Use QuantityType to convert km values into mi
weymann Jan 6, 2021
f026bb5
select int index instead of string value
weymann Jan 8, 2021
d09988b
improve address conversion and undef values
weymann Jan 8, 2021
99b3a15
implement edit and send of ChargeProfile
ntruchsess Jan 17, 2021
54e737a
adapt ChargeProfileTest to latest changes
ntruchsess Jan 17, 2021
125d3f6
update channel state when receiving commands (fixes UI not updating o…
ntruchsess Jan 17, 2021
b30a9a0
add pattern to channel-type states, revert last change
ntruchsess Jan 17, 2021
4eef45a
refactoring charge-profile-handling into separate method
ntruchsess Jan 18, 2021
659741d
some beautification
ntruchsess Jan 18, 2021
c1108ee
use Map.of when declaring constant
ntruchsess Jan 19, 2021
ab2841b
refactoring plus addition of ChargeProfile Action
ntruchsess Feb 2, 2021
b1f68d8
fix skip of charge-profile-command handling if no profile has been re…
ntruchsess Feb 2, 2021
bc96c42
codeowners
ntruchsess Feb 2, 2021
230b981
some cleanup and logging
ntruchsess Feb 3, 2021
47931e6
add remaining charging time
ntruchsess Feb 4, 2021
2b2ebe1
some cleanup of nullable, more functional use of Optional
ntruchsess Feb 4, 2021
9a759fc
minor cleanup of leftovers
ntruchsess Feb 4, 2021
f6eeb78
fix Optional as parameter and use of Option.isPresent + get() antipat…
ntruchsess Feb 4, 2021
7429851
fix more Optional as parameter antipattern
ntruchsess Feb 5, 2021
2430300
fix byte[] cannot be @Nullable
ntruchsess Feb 9, 2021
c6f48ca
use java standard classes (DayOfWeek, Boolean, String) as paramters/r…
ntruchsess Feb 9, 2021
edb650e
cleanup
ntruchsess Feb 10, 2021
bed6ecf
Add missing example item
cholawo Feb 10, 2021
4e7d287
fixing review comments
ntruchsess Feb 15, 2021
465f366
fixing review comments (channelUIDs are now dynamic)
ntruchsess Feb 15, 2021
09e73de
fix unnessary use of StringBuilder and Optional as parameter antipattern
ntruchsess Feb 16, 2021
66a59c7
fix further missing JsonSyntaxException-handling
ntruchsess Feb 16, 2021
af4d27b
fix NoSuchElementException
ntruchsess Feb 16, 2021
d816b48
fix potential Optional.of NullPointerException
ntruchsess Feb 16, 2021
8f205df
fix more Optional.ifPresent -> Optional.get antipattern
ntruchsess Feb 16, 2021
93d5663
use streaming api to join days
ntruchsess Feb 19, 2021
2325d3d
move metadata-classes to ChargeProfileUtils
ntruchsess Feb 22, 2021
8ded928
fix racecondition resulting in 'NoSuchElementException: No value pres…
ntruchsess Feb 22, 2021
1d0ad87
fix redundant refresh of GROUP_LASTTRIP, include GROUP_DESTINATION in…
ntruchsess Feb 23, 2021
f0f0b20
solve remaining checkstyle issues
weymann Mar 5, 2021
1a206df
adapt readme, added service and checkcontrol details
weymann Mar 5, 2021
5ad27cf
missing translations added
weymann Mar 5, 2021
838de39
Bugfix Service Details
weymann Mar 5, 2021
91e8264
reduce info logging
weymann Mar 6, 2021
0a35f61
readme adaptions
weymann Mar 6, 2021
ef163d9
solve review comments
weymann Mar 6, 2021
a0e5315
correct pom.xml format
weymann Mar 7, 2021
ea0ddbe
dynamic RemoteService-command options
ntruchsess Mar 6, 2021
cb33d0b
review corrections
weymann Mar 7, 2021
262f0bc
solve checkstyle issues of RemoteServiceUtils
weymann Mar 7, 2021
48ace3a
fixing handling of NonNull result of getConfigAs
ntruchsess Mar 21, 2021
59d6403
fix use of defaultCharset being platform-dependant
ntruchsess Mar 21, 2021
ec67d8e
fix import
ntruchsess Mar 21, 2021
c7351f7
fix log of stacktrace
ntruchsess Mar 21, 2021
2203c9b
fix reponse-type handling
ntruchsess Mar 21, 2021
ecf35cf
fix state-retrieval future not canceled on ThingHandler.dispose
ntruchsess Mar 21, 2021
b91dbe0
fix getConfigAs being not Nullable
ntruchsess Mar 21, 2021
e51254a
fix editTimeout not being canceled in dispose
ntruchsess Mar 21, 2021
ca5afb0
fix obsolete if (..) return true else return false
ntruchsess Mar 21, 2021
2f150af
fix use of Constant.SPACE and StringBuilder
ntruchsess Mar 21, 2021
5ad8ba2
fix syntactical sugar in lambdas
ntruchsess Mar 21, 2021
3632b78
Merge pull request #7 from ntruchsess/bmw-connected-drive-finding1
weymann Mar 22, 2021
ef04a36
Merge pull request #8 from ntruchsess/bmw-connected-drive-finding2
weymann Mar 22, 2021
950d7c1
Merge pull request #9 from ntruchsess/bmw-connected-drive-finding3
weymann Mar 22, 2021
82fb2ba
Merge pull request #10 from ntruchsess/bmw-connected-drive-finding4
weymann Mar 22, 2021
950f070
Merge pull request #11 from ntruchsess/bmw-connected-drive-finding5
weymann Mar 22, 2021
d87929e
solve review comments
weymann Mar 21, 2021
c794022
revert Action renaming until review comment is clarified
weymann Mar 22, 2021
95051e8
solve further review findings
weymann Mar 23, 2021
24eb066
solve further review comments
weymann Mar 24, 2021
f83b0ad
Bugfix: legacy mode
weymann Mar 25, 2021
a3234a7
improve error handling
weymann Mar 27, 2021
570b80b
review findings error logging
weymann Mar 27, 2021
d9aefdb
correct undef handling
weymann Mar 28, 2021
a1a1650
fix translations
weymann Mar 28, 2021
91f7f26
xml review finding corrections
weymann Mar 28, 2021
bf1df07
move config declaration into separate files
weymann Mar 28, 2021
275dc93
shorten labels for things and channels
weymann Mar 29, 2021
03f4787
add state tags to channels
weymann Mar 29, 2021
59865cf
writable datetime channels for charge profile
weymann Apr 3, 2021
64813ea
editable DateTimeType-channels, removal of minute and hour-channels
ntruchsess Apr 3, 2021
b53dd5f
channel-type-definitions & documentation-update
ntruchsess Apr 3, 2021
0801bea
Merge pull request #13 from ntruchsess/bmw-connected-drive-datetime
weymann Apr 3, 2021
c368dc0
rules for editing datetimes in sitemap
ntruchsess Apr 4, 2021
094538b
Merge pull request #14 from ntruchsess/bmw-connected-drive-datetime-r…
weymann Apr 5, 2021
420dae3
bugfix: set legacy mode only one time
weymann Apr 9, 2021
1156d89
add missing translation
weymann Apr 9, 2021
5876481
rename actions-scope as requested by @kaikreuzer
ntruchsess Apr 11, 2021
f2a23ec
adjust README to renames of actions
ntruchsess Apr 11, 2021
c45fde8
Merge pull request #15 from ntruchsess/bmw-connected-drive-renameactions
weymann Apr 11, 2021
afd5b16
correct Actions section in readme
weymann Apr 11, 2021
db78bab
descriptions were swapped
ntruchsess Apr 12, 2021
dd50d7e
Merge pull request #16 from ntruchsess/bmw-connected-drive-readme
weymann Apr 12, 2021
ac539e8
remove logo and author from documentation
weymann May 1, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,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
Expand Down
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@
<artifactId>org.openhab.binding.bluetooth.ruuvitag</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.bmwconnecteddrive</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.boschindego</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.bmwconnecteddrive/NOTICE
Original file line number Diff line number Diff line change
@@ -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
964 changes: 964 additions & 0 deletions bundles/org.openhab.binding.bmwconnecteddrive/README.md

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions bundles/org.openhab.binding.bmwconnecteddrive/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>3.1.0-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.binding.bmwconnecteddrive</artifactId>

<name>openHAB Add-ons :: Bundles :: BMWConnectedDrive Binding</name>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.bmwconnecteddrive-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${project.version}/xml/features</repository>

<feature name="openhab-binding-bmwconnecteddrive" description="BMWConnectedDrive Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.bmwconnecteddrive/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.bmwconnecteddrive.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.bmwconnecteddrive.internal.utils.Constants;

/**
* The {@link ConnectedDriveConfiguration} class contains fields mapping thing configuration parameters.
*
* @author Bernd Weymann - Initial contribution
*/
@NonNullByDefault
public class ConnectedDriveConfiguration {

/**
* Depending on the location the correct server needs to be called
*/
public String region = Constants.EMPTY;

/**
* BMW Connected Drive Username
*/
public String userName = Constants.EMPTY;

/**
* BMW Connected Drive Password
*/
public String password = Constants.EMPTY;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.bmwconnecteddrive.internal;

import java.util.Set;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingTypeUID;

/**
* The {@link ConnectedDriveConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Bernd Weymann - Initial contribution
* @author Norbert Truchsess - edit & send of charge profile
*/
@NonNullByDefault
public class ConnectedDriveConstants {

private static final String BINDING_ID = "bmwconnecteddrive";

// Units
public static final String UNITS_AUTODETECT = "AUTODETECT";
public static final String UNITS_IMPERIAL = "IMPERIAL";
public static final String UNITS_METRIC = "METRIC";

public static final String VIN = "vin";

public static final int DEFAULT_IMAGE_SIZE_PX = 1024;
public static final int DEFAULT_REFRESH_INTERVAL_MINUTES = 5;
public static final String DEFAULT_IMAGE_VIEWPORT = "FRONT";

// See constants from bimmer-connected
// https://github.com/bimmerconnected/bimmer_connected/blob/master/bimmer_connected/vehicle.py
public enum VehicleType {
CONVENTIONAL("conv"),
PLUGIN_HYBRID("phev"),
ELECTRIC_REX("bev_rex"),
ELECTRIC("bev");

private final String type;

VehicleType(String s) {
type = s;
}

@Override
public String toString() {
return type;
}
}

public enum ChargingMode {
IMMEDIATE_CHARGING,
DELAYED_CHARGING
}

public enum ChargingPreference {
NO_PRESELECTION,
CHARGING_WINDOW
}

public static final Set<String> FUEL_VEHICLES = Set.of(VehicleType.CONVENTIONAL.toString(),
VehicleType.PLUGIN_HYBRID.toString(), VehicleType.ELECTRIC_REX.toString());
public static final Set<String> ELECTRIC_VEHICLES = Set.of(VehicleType.ELECTRIC.toString(),
VehicleType.PLUGIN_HYBRID.toString(), VehicleType.ELECTRIC_REX.toString());

// Countries with Mileage display
public static final Set<String> IMPERIAL_COUNTRIES = Set.of("US", "GB");

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_CONNECTED_DRIVE_ACCOUNT = new ThingTypeUID(BINDING_ID, "account");
public static final ThingTypeUID THING_TYPE_CONV = new ThingTypeUID(BINDING_ID,
VehicleType.CONVENTIONAL.toString());
public static final ThingTypeUID THING_TYPE_PHEV = new ThingTypeUID(BINDING_ID,
VehicleType.PLUGIN_HYBRID.toString());
public static final ThingTypeUID THING_TYPE_BEV_REX = new ThingTypeUID(BINDING_ID,
VehicleType.ELECTRIC_REX.toString());
public static final ThingTypeUID THING_TYPE_BEV = new ThingTypeUID(BINDING_ID, VehicleType.ELECTRIC.toString());
public static final Set<ThingTypeUID> SUPPORTED_THING_SET = Set.of(THING_TYPE_CONNECTED_DRIVE_ACCOUNT,
THING_TYPE_CONV, THING_TYPE_PHEV, THING_TYPE_BEV_REX, THING_TYPE_BEV);

// Thing Group definitions
public static final String CHANNEL_GROUP_STATUS = "status";
public static final String CHANNEL_GROUP_SERVICE = "service";
public static final String CHANNEL_GROUP_CHECK_CONTROL = "check";
public static final String CHANNEL_GROUP_DOORS = "doors";
public static final String CHANNEL_GROUP_RANGE = "range";
public static final String CHANNEL_GROUP_LOCATION = "location";
public static final String CHANNEL_GROUP_LAST_TRIP = "last-trip";
public static final String CHANNEL_GROUP_LIFETIME = "lifetime";
public static final String CHANNEL_GROUP_REMOTE = "remote";
public static final String CHANNEL_GROUP_CHARGE = "charge";
public static final String CHANNEL_GROUP_VEHICLE_IMAGE = "image";
public static final String CHANNEL_GROUP_DESTINATION = "destination";

// Generic Constants for several groups
public static final String NAME = "name";
public static final String DETAILS = "details";
public static final String DATE = "date";
public static final String MILEAGE = "mileage";
public static final String GPS = "gps";
public static final String HEADING = "heading";

// Status
public static final String DOORS = "doors";
public static final String WINDOWS = "windows";
public static final String LOCK = "lock";
public static final String SERVICE_DATE = "service-date";
public static final String SERVICE_MILEAGE = "service-mileage";
public static final String CHECK_CONTROL = "check-control";
public static final String CHARGE_STATUS = "charge";
public static final String CHARGE_END_REASON = "reason";
public static final String CHARGE_REMAINING = "remaining";
public static final String LAST_UPDATE = "last-update";

// Door Details
public static final String DOOR_DRIVER_FRONT = "driver-front";
public static final String DOOR_DRIVER_REAR = "driver-rear";
public static final String DOOR_PASSENGER_FRONT = "passenger-front";
public static final String DOOR_PASSENGER_REAR = "passenger-rear";
public static final String HOOD = "hood";
public static final String TRUNK = "trunk";
public static final String WINDOW_DOOR_DRIVER_FRONT = "win-driver-front";
public static final String WINDOW_DOOR_DRIVER_REAR = "win-driver-rear";
public static final String WINDOW_DOOR_PASSENGER_FRONT = "win-passenger-front";
public static final String WINDOW_DOOR_PASSENGER_REAR = "win-passenger-rear";
public static final String WINDOW_REAR = "win-rear";
public static final String SUNROOF = "sunroof";

// Charge Profile
public static final String CHARGE_PROFILE_CLIMATE = "profile-climate";
public static final String CHARGE_PROFILE_MODE = "profile-mode";
public static final String CHARGE_PROFILE_PREFERENCE = "profile-prefs";
public static final String CHARGE_WINDOW_START = "window-start";
public static final String CHARGE_WINDOW_END = "window-end";
public static final String CHARGE_TIMER1 = "timer1";
public static final String CHARGE_TIMER2 = "timer2";
public static final String CHARGE_TIMER3 = "timer3";
public static final String CHARGE_OVERRIDE = "override";
public static final String CHARGE_DEPARTURE = "-departure";
public static final String CHARGE_ENABLED = "-enabled";
public static final String CHARGE_DAYS = "-days";
public static final String CHARGE_DAY_MON = "-day-mon";
public static final String CHARGE_DAY_TUE = "-day-tue";
public static final String CHARGE_DAY_WED = "-day-wed";
public static final String CHARGE_DAY_THU = "-day-thu";
public static final String CHARGE_DAY_FRI = "-day-fri";
public static final String CHARGE_DAY_SAT = "-day-sat";
public static final String CHARGE_DAY_SUN = "-day-sun";

// Range
public static final String RANGE_HYBRID = "hybrid";
public static final String RANGE_ELECTRIC = "electric";
public static final String SOC = "soc";
public static final String RANGE_FUEL = "fuel";
public static final String REMAINING_FUEL = "remaining-fuel";
public static final String RANGE_RADIUS_ELECTRIC = "radius-electric";
public static final String RANGE_RADIUS_FUEL = "radius-fuel";
public static final String RANGE_RADIUS_HYBRID = "radius-hybrid";

// Last Trip
public static final String DURATION = "duration";
public static final String DISTANCE = "distance";
public static final String DISTANCE_SINCE_CHARGING = "distance-since-charging";
public static final String AVG_CONSUMPTION = "avg-consumption";
public static final String AVG_COMBINED_CONSUMPTION = "avg-combined-consumption";
public static final String AVG_RECUPERATION = "avg-recuperation";

// Lifetime + Average Consumptions
public static final String TOTAL_DRIVEN_DISTANCE = "total-driven-distance";
public static final String SINGLE_LONGEST_DISTANCE = "single-longest-distance";

// Image
public static final String IMAGE_FORMAT = "png";
public static final String IMAGE_VIEWPORT = "view";
public static final String IMAGE_SIZE = "size";

// Remote Services
public static final String REMOTE_SERVICE_LIGHT_FLASH = "light";
public static final String REMOTE_SERVICE_VEHICLE_FINDER = "finder";
public static final String REMOTE_SERVICE_DOOR_LOCK = "lock";
public static final String REMOTE_SERVICE_DOOR_UNLOCK = "unlock";
public static final String REMOTE_SERVICE_HORN = "horn";
public static final String REMOTE_SERVICE_AIR_CONDITIONING = "climate";
public static final String REMOTE_SERVICE_CHARGE_NOW = "charge-now";
public static final String REMOTE_SERVICE_CHARGING_CONTROL = "charge-control";
public static final String REMOTE_SERVICE_COMMAND = "command";
public static final String REMOTE_STATE = "state";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.bmwconnecteddrive.internal;

import static org.openhab.binding.bmwconnecteddrive.internal.ConnectedDriveConstants.*;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.bmwconnecteddrive.internal.handler.BMWConnectedDriveOptionProvider;
import org.openhab.binding.bmwconnecteddrive.internal.handler.ConnectedDriveBridgeHandler;
import org.openhab.binding.bmwconnecteddrive.internal.handler.VehicleHandler;
import org.openhab.binding.bmwconnecteddrive.internal.utils.Converter;
import org.openhab.core.i18n.LocaleProvider;
import org.openhab.core.i18n.TimeZoneProvider;
import org.openhab.core.io.net.http.HttpClientFactory;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.thing.binding.ThingHandlerFactory;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

/**
* The {@link ConnectedDriveHandlerFactory} is responsible for creating things and thing
* handlers.
*
* @author Bernd Weymann - Initial contribution
*/
@NonNullByDefault
@Component(configurationPid = "binding.bmwconnecteddrive", service = ThingHandlerFactory.class)
public class ConnectedDriveHandlerFactory extends BaseThingHandlerFactory {

private final HttpClientFactory httpClientFactory;
private final BMWConnectedDriveOptionProvider optionProvider;
private boolean imperial = false;

@Activate
public ConnectedDriveHandlerFactory(final @Reference HttpClientFactory hcf,
final @Reference BMWConnectedDriveOptionProvider op, final @Reference LocaleProvider lp,
final @Reference TimeZoneProvider timeZoneProvider) {
httpClientFactory = hcf;
optionProvider = op;
imperial = IMPERIAL_COUNTRIES.contains(lp.getLocale().getCountry());
Converter.setTimeZoneProvider(timeZoneProvider);
}

@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return SUPPORTED_THING_SET.contains(thingTypeUID);
}

@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (THING_TYPE_CONNECTED_DRIVE_ACCOUNT.equals(thingTypeUID)) {
return new ConnectedDriveBridgeHandler((Bridge) thing, httpClientFactory);
} else if (SUPPORTED_THING_SET.contains(thingTypeUID)) {
VehicleHandler vh = new VehicleHandler(thing, optionProvider, thingTypeUID.getId(), imperial);
return vh;
}
return null;
}
}
Loading