Skip to content

Commit

Permalink
[groupepsa] Initial Contribution (#10332)
Browse files Browse the repository at this point in the history
* Initial commit: template only

Signed-off-by: Arjan Mels <github@mels.email>

* Initial version

Signed-off-by: Arjan Mels <github@mels.email>

* Minor cleanup after rebase

Signed-off-by: Arjan Mels <github@mels.email>

* Corrected type "peugot" => "peugeot"

Signed-off-by: Arjan Mels <github@mels.email>

* Improved Exception messages
Corrected URL

Signed-off-by: Arjan Mels <github@mels.email>

* Switched from vin to id
Changed nextDelayedTime from ZonedDateTime to Duration
Added vehcile etails and additional info retrieval

Signed-off-by: Arjan Mels <github@mels.email>

* Before rebase

Signed-off-by: Arjan Mels <github@mels.email>

* Various fixes

Signed-off-by: Arjan Mels <github@mels.email>

* Updated tests

Signed-off-by: Arjan Mels <github@mels.email>

* Changed double to BigDecimal to keep accuracy
Added lastupdated channel
Small corrections

Signed-off-by: Arjan Mels <github@mels.email>

* Updated to 3.1.0-SNAPSHOT

Signed-off-by: Arjan Mels <github@mels.email>

* Added README.md

Signed-off-by: Arjan Mels <github@mels.email>

* Changed channels to lowerCamelCase

Signed-off-by: Arjan Mels <github@mels.email>

* Minor corrections

Signed-off-by: Arjan Mels <github@mels.email>

* Corrected lastUpdated in thing-types.xml

Signed-off-by: Arjan Mels <github@mels.email>

* Fixed ToStringbuilder

Signed-off-by: Arjan Mels <github@mels.email>

* corrected capitalization in thing-types.xml and Constants

Signed-off-by: Arjan Mels <github@mels.email>

* Corrected URL for Citroen

Signed-off-by: Arjan Mels <github@mels.email>

* Added groupepsa binding to bom pom.xml

Signed-off-by: Arjan Mels <github@mels.email>

* Updated copyrights

Signed-off-by: Arjan Mels <github@mels.email>

* Fixed CheckStyle warnings

Signed-off-by: Arjan Mels <github@mels.email>

* Fixed check style notifications

Signed-off-by: Arjan Mels <github@mels.email>

* Updated readme

Signed-off-by: Arjan Mels <github@mels.email>

* Corrected capitalization of thing-types.xml

Signed-off-by: Arjan Mels <github@mels.email>

* Updated pom. xml to 3.3.0-SNAPSHOT

Signed-off-by: Arjan Mels <github@mels.email>

* Updated copyright messages

Signed-off-by: Arjan Mels <github@mels.email>

* Various minor cleanups
Cleanup of the README.md
Removed unnecessary license header form the feature.xml file
Various null annotation corrections
Further cleanup of thing-types.xml
Cleanup of groupepsa.properties

Signed-off-by: Arjan Mels <github@mels.email>

* Logging updates

Signed-off-by: Arjan Mels <github@mels.email>

* Updated dependencies
Added dependencies to NOTICE

Signed-off-by: Arjan Mels <github@mels.email>

* Ignore lastposition for isConnected check

Signed-off-by: Arjan Mels <github@mels.email>

* Updated to use ThingHandlerService

Signed-off-by: Arjan Mels <github@mels.email>

* Fixed various review findings

Signed-off-by: Arjan Mels <github@mels.email>

Co-authored-by: Arjan Mels <github@mels.email>
  • Loading branch information
arjanmels and Arjan Mels authored Apr 30, 2022
1 parent 7adfc48 commit 8e7c78c
Show file tree
Hide file tree
Showing 53 changed files with 4,369 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,11 @@
<artifactId>org.openhab.binding.groheondus</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.groupepsa</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.guntamatic</artifactId>
Expand Down
20 changes: 20 additions & 0 deletions bundles/org.openhab.binding.groupepsa/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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

== Third-party Content

GeoJSON support for Gson
* License: Apache License 2.0
* Project: https://github.com/filosganga/geogson
* Source: https://github.com/filosganga/geogson
151 changes: 151 additions & 0 deletions bundles/org.openhab.binding.groupepsa/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# Groupe PSA Binding

Binding to retrieve information via the Groupe PSA Web API for cars from Opel, Peugeot, Citroen, DS and Vauxhall.

## Supported Things

bridge - Groupe PSA Web Api Bridge: The Thing to auto discover your cars

vehicle - Groupe PSA Car: The actual car thing.

## Discovery

Use the "Groupe PSA Web Api bridge" to auto discover your cars. You need to select the brand for the bridge binding and only cars for the brand will be auto discovered. If you need to add for multiple brands or multiple different users, add multiple bridges.

## Bridge Configuration

You need to select a brand and enter the User Name and Password.
The Polling interval (in minutes) determines how often the API will polled for new cars.
The Client ID and Client Secret should not need to be updated. (However you can register your own app via https://developer.groupe-psa.com/inc/ and use this client information if you wish.)

### parameters

| Property | Default | Required | Description |
| --------------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| vendor | None | Yes | The brand of the car (PEUGEOT, CITROEN, DS, OPEL or VAUXHALL) |
| userName | None | Yes | The user name for the mypeugot/mycitroen/myds/myopel/myvauxhall website or app |
| password | None | Yes | The password for the given user |
| pollingInterval | 60 | No | The Polling interval (in minutes) determines how often the available vehicles are queried |
| clientId | | Yes | The client ID for API access: can normally left at the default value. (see: https://developer.groupe-psa.io/webapi/b2c/quickstart/connect/#article) |
| clientSecret | | Yes | The client secret for API access: can normally left at the default value. (see: https://developer.groupe-psa.io/webapi/b2c/quickstart/connect/#article) |

## Vehicle Configuration

Normally the vehicles will be autodiscovered. The Polling Interval and Online Timeout can be adjusted.

### parameters

| Property | Default | Required | Description |
| --------------- | ------- | -------- | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ |
| id | None | Yes | Vehicle API ID | The ID is the vehicle API ID (not equal to the VIN), which is autodiscoverd by the bridge. |
| pollingInterval | 5 | No | The Polling interval (in minutes) determines how often the car is polled for updated information |
| onlineInterval | 15 | No | The Online Timeout (in minutes) determines when the car is deemed to be offline. |

## Channels

| Channel Type ID | Item Type | Description |
| ----------------------- | ------------------------- | ------------------------------------------------ |
| current | Number:ElectricCurrent | Electrical current |
| voltage | Number:ElectricPotential | Voltage |
| temperature | Number:Temperature | Temperature |
| daytime | Contact | Enabled if it is daytime |
| doorLock | String | Door lock state |
| doorOpen | Contact | Door is open |
| ignition | String | Ignition state |
| moving | Contact | Vehicle is moving |
| acceleration | Number:Acceleration | Current acceleration |
| speed | Number:Speed | Current speed |
| mileage | Number:Length | Total travelled distance |
| position | Location | Last known position |
| heading | Number:Angle | Direction of travel |
| type | String | Position acquisition type |
| signal | Number:Dimensionless | Strength of the position localization signal |
| lastUpdated | DateTime | Last time the results were updated on the server |
| privacy | String | Privacy status |
| belt | String | Seat belt status |
| emergency | String | Emergency call status |
| service | String | Service Type |
| preconditioning | String | Air conditioning status |
| preconditioningFailure | String | Airr conditioning failure cause |
| level | Number:Dimensionless | Fuel level |
| autonomy | Number:Length | Remaining distance |
| consumption | Number:VolumetricFlowRate | Fuel consumption |
| residual | Number:Energy | Remaining battery charge |
| capacity | Number:Energy | Battery capacity |
| healthCapacity | Number:Dimensionless | Health of the battery capacity |
| healthResistance | Number:Dimensionless | Health of the battery resistance |
| chargingStatus | String | Battery charging status |
| chargingMode | String | Battery charging mode |
| chargingPlugged | Contact | Vehicle plugged in to charger |
| chargingRate | Number:Speed | Battery Charging Rate |
| chargingRemainingTime | Number:Time | Time remaining till charged |
| chargingNextDelayedTime | Number:Time | Time till the next charging starts |

Further documentation can be found at: https://developer.groupe-psa.io/webapi/b2c/api-reference/specification/#article

## Full Example

### Things file

```
Bridge groupepsa:bridge:opel "Auto Interface" [
pollingInterval=60,
userName="anonymous@anonymous.email",
password="password",
vendor="OPEL"
] {
Things:
vehicle zafira "Auto" @ "Outdoors"
[
id="<web api id here>",
pollingInterval=5,
onlineInterval=1440
]
}
```

### Items file

```
Group Auto
Number:ElectricCurrent Auto_Aux_Current "Auxillliary Battery Current [%.1f %unit%]" (Auto) ["Measurement","Current"] {channel="groupepsa:vehicle:opel:zafira:battery#current"}
Number Auto_Aux_Level "Auxillliary Battery Level [%.1f %unit%]" (Auto) ["Measurement","Level"] {channel="groupepsa:vehicle:opel:zafira:battery#voltage"}
Number:Temperature Auto_Outside_Temperature "Outside Temperature [%.1f %unit%]" (Auto) ["Measurement","Temperature"] {channel="groupepsa:vehicle:opel:zafira:environment#temperature"}
Number:Length Auto_Mileage "Mileage [%.1f %unit%]" (Auto) ["Measurement"] {channel="groupepsa:vehicle:opel:zafira:motion#mileage"}
Number:Speed Auto_Speed "Speed [%.1f %unit%]" (Auto) ["Measurement"] {channel="groupepsa:vehicle:opel:zafira:motion#speed"}
Number:Acceleration Auto_Acceleration "Acceleration [%.1f %unit%]" (Auto) ["Measurement"] {channel="groupepsa:vehicle:opel:zafira:motion#acceleration"}
Location Auto_Location "Locatie" (Auto) ["Point"] {channel="groupepsa:vehicle:opel:zafira:position#position"}
Number:Angle Auto_Heading "Richting" (Auto) ["Measurement"] {channel="groupepsa:vehicle:opel:zafira:position#heading"}
String Auto_Location_Type "Locatie Type" (Auto) ["Measurement"] {channel="groupepsa:vehicle:opel:zafira:position#type"}
Number Auto_Signal_Strength "Signaal Sterkte [%.1f %unit%]" (Auto) ["Measurement"] {channel="groupepsa:vehicle:opel:zafira:position#signal"}
DateTime Auto_Last_Update "Laatst bijgewerkt [%1$tA, %1$te %1$tb %1$tY %1$tR]" (Auto) ["Measurement", "Timestamp"] {channel="groupepsa:vehicle:opel:zafira:various#lastUpdated"}
String Auto_Privacy_Status "Privacy Status" (Auto) ["Status"] {channel="groupepsa:vehicle:opel:zafira:various#privacyStatus"}
String Auto_Belt_Status "Belt Status" (Auto) ["Status"] {channel="groupepsa:vehicle:opel:zafira:various#beltStatus"}
String Auto_Emergency_Call "Emergency Call" (Auto) ["Status"] {channel="groupepsa:vehicle:opel:zafira:various#emergencyCall"}
String Auto_Service "Service" (Auto) ["Status"] {channel="groupepsa:vehicle:opel:zafira:various#service"}
String Auto_Air_Conditioning "Air Conditioning" (Auto) ["Status"] {channel="groupepsa:vehicle:opel:zafira:various#preconditioning"}
String Auto_Air_Conditioning_Failure "Air Conditioning Failure" (Auto) ["Status"] {channel="groupepsa:vehicle:opel:zafira:various#preconditioningFailure"}
Number:Length Auto_Autonomy "Autonomy [%.1f %unit%]" (Auto) ["Measurement"] {channel="groupepsa:vehicle:opel:zafira:electric#autonomy"}
Number Auto_Level "Battery Level [%.1f %unit%]" (Auto) ["Measurement", "Level"] {channel="groupepsa:vehicle:opel:zafira:electric#level"}
Number:Energy Auto_Residual "Battery Residual [%.1f %unit%]" (Auto) ["Measurement", "Level"] {channel="groupepsa:vehicle:opel:zafira:electric#residual"}
Number:Energy Auto_Capacity "Battery Capacity [%.1f %unit%]" (Auto) ["Measurement"] {channel="groupepsa:vehicle:opel:zafira:electric#capacity"}
Number Auto_Health_Capacity "Battery Health Capacity [%.1f %unit%]" (Auto) ["Measurement"] {channel="groupepsa:vehicle:opel:zafira:electric#batteryHealthCapacity"}
Number Auto_Health_Resistance "Battery Health Resistance [%.1f %unit%]" (Auto) ["Measurement"] {channel="groupepsa:vehicle:opel:zafira:electric#batteryHealthResistance"}
String Auto_Charging_Status "Charging Status" (Auto) ["Status"] {channel="groupepsa:vehicle:opel:zafira:electric#chargingStatus"}
String Auto_Charging_Mode "Charging Mode" (Auto) ["Status"] {channel="groupepsa:vehicle:opel:zafira:electric#chargingMode"}
Contact Auto_Plugged_In "Plugged In" (Auto) ["Status"] {channel="groupepsa:vehicle:opel:zafira:electric#chargingPlugged"}
Number:Speed Auto_Charging_Rate "Charging Rate [%.1f %unit%]" (Auto) ["Measurement"] {channel="groupepsa:vehicle:opel:zafira:electric#chargingRate"}
Number:Time Auto_Charging_Time_Remaining "Charging Time Remaining [%.1f %unit%]" (Auto) ["Measurement", "Duration"] {channel="groupepsa:vehicle:opel:zafira:electric#chargingRemainingTime"}
Number:Time Auto_Charging_Time_Till_Next "Charging Time Till Next Charging [%.1f %unit%]" (Auto) ["Measurement", "Duration"] {channel="groupepsa:vehicle:opel:zafira:electric#chargingNextDelayedTime"}
```
25 changes: 25 additions & 0 deletions bundles/org.openhab.binding.groupepsa/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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.3.0-SNAPSHOT</version>
</parent>

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

<name>openHAB Add-ons :: Bundles :: Groupe PSA Binding</name>

<dependencies>
<dependency>
<groupId>com.github.filosganga</groupId>
<artifactId>geogson-core</artifactId>
<version>1.4.31</version>
</dependency>
</dependencies>

</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.groupepsa-${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/${ohc.version}/xml/features</repository>

<feature name="openhab-binding-groupepsa" description="Groupe PSA Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.groupepsa/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/**
* Copyright (c) 2010-2022 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.groupepsa.internal;

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

/**
* The {@link GroupePSABindingConstants} class defines common constants, which
* are used across the whole binding.
*
* @author Arjan Mels - Initial contribution
*/
@NonNullByDefault
public class GroupePSABindingConstants {

public static final String BINDING_ID = "groupepsa";

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_BRIDGE = new ThingTypeUID(BINDING_ID, "bridge");
public static final ThingTypeUID THING_TYPE_VEHICLE = new ThingTypeUID(BINDING_ID, "vehicle");

// Vehicle properties
public static final String VEHICLE_ID = "id";
public static final String VEHICLE_VIN = "vin";
public static final String VEHICLE_VENDOR = "vendor";
public static final String VEHICLE_MODEL = "model";

// List of all Channel ids
public static final String CHANNEL_BATTERY_CURRENT = "battery#current";
public static final String CHANNEL_BATTERY_VOLTAGE = "battery#voltage";

public static final String CHANNEL_TYPE_DOORLOCK = "doorLock";
public static final String CHANNEL_TYPE_DOOROPEN = "doorOpen";

public static final String CHANNEL_GROUP_DOORS = "doors";
public static final String CHANNEL_DOORS_LOCK = "doors#locked";

public static final String CHANNEL_ENVIRONMENT_TEMPERATURE = "environment#temperature";
public static final String CHANNEL_ENVIRONMENT_DAYTIME = "environment#daytime";

public static final String CHANNEL_MOTION_IGNITION = "motion#ignition";
public static final String CHANNEL_MOTION_ACCELERATION = "motion#acceleration";
public static final String CHANNEL_MOTION_MOVING = "motion#moving";
public static final String CHANNEL_MOTION_SPEED = "motion#speed";
public static final String CHANNEL_MOTION_MILEAGE = "motion#mileage";

public static final String CHANNEL_POSITION_POSITION = "position#position";
public static final String CHANNEL_POSITION_HEADING = "position#heading";
public static final String CHANNEL_POSITION_TYPE = "position#type";
public static final String CHANNEL_POSITION_SIGNALSTRENGTH = "position#signal";

public static final String CHANNEL_VARIOUS_LAST_UPDATED = "various#lastUpdated";
public static final String CHANNEL_VARIOUS_PRIVACY = "various#privacy";
public static final String CHANNEL_VARIOUS_BELT = "various#belt";
public static final String CHANNEL_VARIOUS_EMERGENCY = "various#emergency";
public static final String CHANNEL_VARIOUS_SERVICE = "various#service";
public static final String CHANNEL_VARIOUS_PRECONDITINING = "various#preconditioning";
public static final String CHANNEL_VARIOUS_PRECONDITINING_FAILURE = "various#preconditioningFailure";

public static final String CHANNEL_FUEL_AUTONOMY = "fuel#autonomy";
public static final String CHANNEL_FUEL_CONSUMPTION = "fuel#consumption";
public static final String CHANNEL_FUEL_LEVEL = "fuel#level";

public static final String CHANNEL_ELECTRIC_AUTONOMY = "electric#autonomy";
public static final String CHANNEL_ELECTRIC_LEVEL = "electric#level";
public static final String CHANNEL_ELECTRIC_RESIDUAL = "electric#residual";

public static final String CHANNEL_ELECTRIC_BATTERY_CAPACITY = "electric#batteryCapacity";
public static final String CHANNEL_ELECTRIC_BATTERY_HEALTH_CAPACITY = "electric#batteryHealthCapacity";
public static final String CHANNEL_ELECTRIC_BATTERY_HEALTH_RESISTANCE = "electric#batteryHealthResistance";

public static final String CHANNEL_ELECTRIC_CHARGING_STATUS = "electric#chargingStatus";
public static final String CHANNEL_ELECTRIC_CHARGING_MODE = "electric#chargingMode";
public static final String CHANNEL_ELECTRIC_CHARGING_PLUGGED = "electric#chargingPlugged";
public static final String CHANNEL_ELECTRIC_CHARGING_RATE = "electric#chargingRate";
public static final String CHANNEL_ELECTRIC_CHARGING_REMAININGTIME = "electric#chargingRemainingTime";
public static final String CHANNEL_ELECTRIC_CHARGING_NEXTDELAYEDTIME = "electric#chargingNextDelayedTime";

public enum VendorConstants {
PEUGEOT("https://idpcvs.peugeot.com/am/oauth2/access_token", "clientsB2CPeugeot"),
CITROEN("https://idpcvs.citroen.com/am/oauth2/access_token", "clientsB2CCitroen"),
DS("https://idpcvs.driveds.com/am/oauth2/access_token", "clientsB2CDS"),
OPEL("https://idpcvs.opel.com/am/oauth2/access_token", "clientsB2COpel"),
VAUXHALL("https://idpcvs.vauxhall.co.uk/am/oauth2/access_token", "clientsB2CVauxhall");

public final String url;
public final String realm;
public final String scope;

VendorConstants(String url, String realm) {
this.url = url;
this.realm = realm;
this.scope = "profile openid";
}
}

public static final String API_URL = "https://api.groupe-psa.com/connectedcar/v4";
}
Loading

0 comments on commit 8e7c78c

Please sign in to comment.