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

[mybmw] Upgrade to new BMW API #14452

Merged
merged 79 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 78 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
f026cd2
[mybmw] fix not working binding due to API update
Feb 11, 2023
544272b
[mybmw] fix case sensitive brand in request header
martingrassl Feb 11, 2023
7125555
[mybmw] added Finnish translations
martingrassl Feb 15, 2023
f94b448
[mybmw] update Copyright header
martingrassl Feb 19, 2023
6e525c9
[mybmw/Documentation] re-fix linting of README
martingrassl Feb 20, 2023
ee6f259
Merge remote-tracking branch 'origin/main' into 14065_upgrade_BMW_API_40
martingrassl Mar 6, 2023
0227b6a
[mybmw] add and replace code owners
martingrassl Mar 20, 2023
ab1c44b
Merge branch 'main' into 14065_upgrade_BMW_API_40
martingrassl Mar 20, 2023
2a36347
[mybmw] add and replace code owners - fix typo
martingrassl Mar 20, 2023
eb3d5f8
[mybmw] add and replace code owners - fix name
martingrassl Mar 20, 2023
0bab2d0
[mybmw] Merge remote-tracking branch 'origin/main' into 14065_upgrade…
martingrassl Mar 20, 2023
de4e1ae
[mybmw] delete unit test due to compile errors
martingrassl Mar 21, 2023
35ad717
Merge remote-tracking branch 'origin/main' into 14065_upgrade_BMW_API_40
martingrassl Mar 21, 2023
f517c4d
[mybmw] fix spotless error
martingrassl Mar 21, 2023
25ab42f
[mybmw] apply change requested by @lsiepel
martingrassl Mar 28, 2023
3f70cad
[mybmw] Merge remote-tracking branch 'origin/main' into 14065_upgrade…
martingrassl Apr 22, 2023
7270c0c
Merge branch 'openhab:main' into 14065_upgrade_BMW_API_40
martingrassl Jul 2, 2023
f75aa58
Merge remote-tracking branch 'origin/main' into 14065_upgrade_BMW_API_40
martingrassl Aug 7, 2023
41aa52f
[mybmw] fix UoM issues
martingrassl Aug 17, 2023
3d73f52
[mybmw] add upgrade instructions
martingrassl Aug 18, 2023
1bf2299
Merge remote-tracking branch 'origin/main'
martingrassl Sep 23, 2023
fef673b
[mybmw] improve concurrency handling
martingrassl Oct 21, 2023
0b17819
[mybmw] deleted .gitignore
martingrassl Oct 21, 2023
c269f50
Merge remote-tracking branch 'origin/main' into 14065_upgrade_BMW_API_40
martingrassl Oct 21, 2023
550c3ae
[mybmw] remove ampersand from javadoc
martingrassl Oct 21, 2023
6ec8423
[mybmw] merge remote-tracking branch 'origin/main'
martingrassl Oct 28, 2023
ec356fc
[mybmw] changed null check
martingrassl Oct 29, 2023
40a34b4
Update bundles/org.openhab.binding.mybmw/src/main/java/org/openhab/bi…
martingrassl Oct 30, 2023
e39476d
[mybmw] remove unnecessary pom entry
martingrassl Oct 30, 2023
5f809f5
Update bundles/org.openhab.binding.mybmw/src/test/java/org/openhab/bi…
martingrassl Oct 30, 2023
7bf30ff
Merge remote-tracking branch 'origin/main' into 14065_upgrade_BMW_API_40
martingrassl Oct 30, 2023
70080df
Merge branch '14065_upgrade_BMW_API_40' of https://github.com/marting…
martingrassl Oct 30, 2023
72eb84b
[mybmw] remove commented out code
martingrassl Oct 30, 2023
52c16b1
Update bundles/org.openhab.binding.mybmw/src/main/java/org/openhab/bi…
martingrassl Oct 30, 2023
7f7ceec
[mybmw] deleted i18n files, moving to crowdin
martingrassl Oct 30, 2023
82a26ca
Merge branch '14065_upgrade_BMW_API_40' of https://github.com/marting…
martingrassl Oct 30, 2023
b4c4638
[mybmw] remove commented code
martingrassl Oct 30, 2023
7f3195f
Update bundles/org.openhab.binding.mybmw/src/main/java/org/openhab/bi…
martingrassl Oct 31, 2023
b3562c9
[mybmw] revert previous change
martingrassl Oct 31, 2023
2d12e30
[mybmw] changed time conversion
martingrassl Oct 31, 2023
dca468b
[mybmw] delete unnecessary files
martingrassl Oct 31, 2023
bf6fe13
[mybmw] change handling of TimeZoneProvider
martingrassl Oct 31, 2023
ca9c31e
[mybmw] delete png file used in unit test
martingrassl Nov 1, 2023
64bc60d
[mybmw] revert setting default state unit
martingrassl Nov 1, 2023
f1d60cf
[mybmw] cleanup pom file
martingrassl Nov 27, 2023
15599e4
[mybmw] added sleep time for having time distance
martingrassl Dec 11, 2023
9a37b95
[mybmw] removed the trace log prefixes
martingrassl Dec 11, 2023
055ebd7
[mybmw] changed language handling
martingrassl Dec 11, 2023
facbd37
[mybmw] improved exception logging
martingrassl Dec 11, 2023
8272148
[mybmw] create constants for strings
martingrassl Dec 11, 2023
c4aaee4
[mybmw] set target version to 1
martingrassl Dec 11, 2023
ced799e
[mybmw] fix command for start charging
martingrassl Dec 11, 2023
c3fa9cf
[mybmw] fix FindBugs logging error
martingrassl Dec 11, 2023
96be12e
Update bundles/org.openhab.binding.mybmw/src/main/java/org/openhab/bi…
martingrassl Dec 12, 2023
56ff217
Update bundles/org.openhab.binding.mybmw/src/main/java/org/openhab/bi…
martingrassl Dec 12, 2023
a31a767
Update bundles/org.openhab.binding.mybmw/src/main/java/org/openhab/bi…
martingrassl Dec 12, 2023
89c31d1
[mybmw] fixed some small things due to code review
martingrassl Dec 12, 2023
01cfa8d
[mybmw] merge with remote
martingrassl Dec 12, 2023
852f275
Update bundles/org.openhab.binding.mybmw/src/main/java/org/openhab/bi…
martingrassl Dec 13, 2023
c397b60
Update bundles/org.openhab.binding.mybmw/src/main/java/org/openhab/bi…
martingrassl Dec 13, 2023
c3389d4
Update bundles/org.openhab.binding.mybmw/src/main/java/org/openhab/bi…
martingrassl Dec 13, 2023
b8757ad
Update bundles/org.openhab.binding.mybmw/src/main/java/org/openhab/bi…
martingrassl Dec 13, 2023
53c1dd1
Update bundles/org.openhab.binding.mybmw/README.md
martingrassl Dec 13, 2023
5ed0773
Update bundles/org.openhab.binding.mybmw/README.md
martingrassl Dec 13, 2023
06ca7af
Update bundles/org.openhab.binding.mybmw/src/main/java/org/openhab/bi…
martingrassl Dec 13, 2023
bc8ae15
[mybmw] fix compile error
martingrassl Dec 13, 2023
1c9325b
[mybmw] extract strings to constants
martingrassl Dec 13, 2023
50857a2
[mybmw] cleanup comments
martingrassl Dec 13, 2023
dbf9d8d
[mybmw] add description of return value
martingrassl Dec 13, 2023
c8bf8bf
[mybmw] fix Javadoc
martingrassl Dec 13, 2023
9814602
[mybmw] catch InterruptedException properly
martingrassl Dec 13, 2023
7019a00
[mybmw] revert change of some props
martingrassl Dec 13, 2023
7054713
[mybmw] revert deletion of de translations
martingrassl Dec 13, 2023
1b971b1
[mybmw] fix missing line break at end of file
martingrassl Dec 13, 2023
74f26a4
Update bundles/org.openhab.binding.mybmw/src/main/resources/OH-INF/i1…
jlaur Dec 13, 2023
54b3116
[mybmw] decrease log level of JSON deserialization error
martingrassl Dec 14, 2023
4e3175f
[mybmw] merge with remote
martingrassl Dec 14, 2023
7e4b42c
[mybmw] remove dimension of some numbers
martingrassl Dec 14, 2023
4588674
Update bundles/org.openhab.binding.mybmw/README.md
jlaur Dec 14, 2023
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
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
/bundles/org.openhab.binding.mqtt.homie/ @openhab/add-ons-maintainers
/bundles/org.openhab.binding.mqtt.ruuvigateway/ @ssalonen
/bundles/org.openhab.binding.mycroft/ @dalgwen
/bundles/org.openhab.binding.mybmw/ @weymann @ntruchsess
/bundles/org.openhab.binding.mybmw/ @ntruchsess @mherwege @martingrassl
/bundles/org.openhab.binding.mynice/ @clinique
/bundles/org.openhab.binding.myq/ @digitaldan
/bundles/org.openhab.binding.mystrom/ @pail23
Expand Down
71 changes: 39 additions & 32 deletions bundles/org.openhab.binding.mybmw/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ Reflects overall status of the vehicle.
| Check Control | check-control | String | Presence of active warning messages | X | X | X | X |
| Plug Connection Status | plug-connection | String | Plug is _Connected_ or _Not connected_ | | X | X | X |
| Charging Status | charge | String | Current charging status | | X | X | X |
| Charging Information | charge-info | String | Information regarding current charging session | | X | X | X |
| Motion Status | motion | Switch | Driving state - depends on vehicle hardware | X | X | X | X |
| Remaining Charging Time | charge-remaining | Number:Time | Remaining time for current charging session | | X | X | X |
| Last Status Timestamp | last-update | DateTime | Date and time of last status update | X | X | X | X |
| Last Fetched Timestamp | last-fetched | DateTime | Date and time of last time status fetched | X | X | X | X |

Overall Door Status values

Expand Down Expand Up @@ -239,17 +239,19 @@ See description [Range vs Range Radius](#range-vs-range-radius) to get more info
- 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 | |
| Electric 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 | |
| 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 | |
| Electric 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 | |
| Estimated Fuel Consumption l/100km | estimated-fuel-l-100km | Number:Dimensionless | X | X | X | |
| Estimated Fuel Consumption mpg | estimated-fuel-mpg | Number:Dimensionless | X | X | X | |
jlaur marked this conversation as resolved.
Show resolved Hide resolved
| 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 | |

#### Doors Details

Expand Down Expand Up @@ -359,6 +361,7 @@ The channel _command_ provides options
- _horn-blow_
- _climate-now-start_
- _climate-now-stop_
- _charge-now_

The channel _state_ shows the progress of the command execution in the following order

Expand Down Expand Up @@ -471,10 +474,11 @@ Image representation of the vehicle.

Possible view ports:

- _VehicleStatus_ Front Side View
- _VehicleInfo_ Front View
- _ChargingHistory_ Side View
- _Default_ Front Side View
- _VehicleStatus_ Front Left Side View
- _FrontView_ Front View
- _FrontLeft_ Front Left Side View
- _FrontRight_ Front Right Side View
- _RearView_ Rear View

## Further Descriptions

Expand All @@ -491,7 +495,8 @@ There are 3 occurrences of dynamic data delivered
The channel id _name_ shows the first element as default.
All other possibilities are attached as options.
The picture on the right shows the _Session Title_ item and 3 possible options.
Select the desired service and the corresponding Charge Session with _Energy Charged_, _Session Status_ and _Session Issues_ will be shown.
Select the desired service and the corresponding Charge Session with _Energy Charged_, _Session Status_ and
_Session Issues_ will be shown.

### TroubleShooting

Expand All @@ -507,32 +512,34 @@ If these preconditions are fulfilled proceed with the fingerprint generation.

#### Generate Debug Fingerprint

<img align="right" src="./doc/DiscoveryScan.png" width="400" height="350"/>
Login to the openHAB console and use the `mybmw fingerprint` command.

First [enable debug logging](https://www.openhab.org/docs/administration/logging.html#defining-what-to-log) for the binding.
Fingerprint information on your account and vehicle(s) will show in the console and can be copiedfrom there.
A zip file with fingerprint information for your vehicle(s) will also be generated and put into the `mybmw` folder in the userdata folder.
This fingerprint information is valuable for the developers to better support your vehicle.

```shell
log:set DEBUG org.openhab.binding.mybmw
```
You can restrict the accounts and vehicles for the fingerprint generation.
Full syntax is available through the `mybmw help` console command.

The debug fingerprint is generated every time the discovery is executed.
To force a new fingerprint perform a _Scan_ for MyBMW things.
Personal data is eliminated from the log entries so it should be possible to share them in public.
Personal data is eliminated from fingerprints so it should be possible to share them in public.
Data like

- Vehicle Identification Number (VIN)
- Location data

are anonymized.
You'll find the fingerprint in the logs with the command
are anonymized in the JSON response and URL's.

```shell
grep "Discovery 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!

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!

#### Debug Logging
martingrassl marked this conversation as resolved.
Show resolved Hide resolved

You can [enable debug logging](https://www.openhab.org/docs/administration/logging.html#defining-what-to-log) to get more information on the behaviour of the binding.
The package.subpackage in this case would be "org.openhab.binding.mybmw".

As with fingerprint data, personal data is eliminated from logs.

### Range vs Range Radius

<img align="right" src="./doc/range-radius.png" width="400" height="350"/>
Expand Down
167 changes: 167 additions & 0 deletions bundles/org.openhab.binding.mybmw/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,171 @@

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

<profiles>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wborn - can you help review the changes in this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as I wrote above, the profiles I use for my local testing and for checking the code coverage. They won't be used for the builds of the OH Jenkins as you have to activate them by the "-P" flag which is not set in the OH Jenkins and hence can be ignored. I just moved the additional dependency inside of the profile so that the default execution is using just the regular two-line pom.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed that. Thanks for the explanation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I keep it, would be good

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it then if we don't receive any feedback from @wborn before the PR is ready to be merged (which seems to be quite soon).

<profile>
<id>test-coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<executions>
<execution>
<id>default-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</execution>
<execution>
<id>default-restore-instrumented-classes</id>
<phase>test</phase>
<goals>
<goal>restore-instrumented-classes</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value>
<minimum>0.20</minimum>
</limit>
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>0.20</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<!-- must be on the classpath -->
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<classifier>runtime</classifier>
<version>0.8.8</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
<profile>
<!--
If you activate this profile, the MyBmwProxyIT is executed which means real
backend requests. The test is only successful if you provide CONNECTED_USER and
CONNECTED_PASSWORD as environment variable of the Maven command.
-->
<id>integration-tests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M7</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!--
This profile generates a jar file <regular-jar-file-name>-testenv.jar in the target folder. This
testenv jar contains the regular classes and in addition all responses from
src/test/resources. If you copy this jar file to your addons folder, you can simulate all
accounts which are available as fingerprints in the responses folder. This can be done like
this:
1. start openhab with the environment variable "ENVIRONMENT=test"
2. configure the connected account with username "testuser"
3. configure as connected password the folder which you want to test, e.g. "BEV", "BEV2", "PHEV", "ICE", "ICE2",
"MILD_HYBRID"
after that you should get the vehicles loaded properly so you can check if the channels are populated with data properly.
-->
<id>test-jar</id>
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/classes</outputDirectory>
<resources>
<resource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>testenv</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
import org.openhab.binding.mybmw.internal.utils.Constants;

/**
* The {@link MyBMWConfiguration} class contains fields mapping thing configuration parameters.
* The {@link MyBMWBridgeConfiguration} class contains fields mapping thing configuration parameters.
*
* @author Bernd Weymann - Initial contribution
* @author Martin Grassl - renamed
*/
@NonNullByDefault
public class MyBMWConfiguration {
public class MyBMWBridgeConfiguration {

/**
* Depending on the location the correct server needs to be called
Expand Down
Loading