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

[groupepsa] Initial Contribution #10332

Merged
merged 32 commits into from
Apr 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7806d6e
Initial commit: template only
arjanmels Apr 24, 2022
51a600d
Initial version
arjanmels Apr 24, 2022
d94af6b
Minor cleanup after rebase
arjanmels Apr 24, 2022
92d5580
Corrected type "peugot" => "peugeot"
arjanmels Apr 24, 2022
520f18b
Improved Exception messages
arjanmels Apr 24, 2022
1235254
Switched from vin to id
arjanmels Apr 24, 2022
38fdd2d
Before rebase
arjanmels Apr 24, 2022
d6ede8d
Various fixes
arjanmels Apr 24, 2022
3ed9a7f
Updated tests
arjanmels Apr 24, 2022
4383ec5
Changed double to BigDecimal to keep accuracy
arjanmels Apr 24, 2022
b3c9347
Updated to 3.1.0-SNAPSHOT
arjanmels Apr 24, 2022
4bbee5f
Added README.md
Apr 24, 2022
db877db
Changed channels to lowerCamelCase
Apr 24, 2022
e7163b2
Minor corrections
Apr 24, 2022
5cf8f0d
Corrected lastUpdated in thing-types.xml
Apr 24, 2022
6432968
Fixed ToStringbuilder
Apr 24, 2022
97e4659
corrected capitalization in thing-types.xml and Constants
Apr 24, 2022
fb42f43
Corrected URL for Citroen
Apr 24, 2022
401af82
Added groupepsa binding to bom pom.xml
Apr 24, 2022
e7a189f
Updated copyrights
Apr 24, 2022
240e6a7
Fixed CheckStyle warnings
Apr 24, 2022
f7100ef
Fixed check style notifications
Apr 24, 2022
0900cac
Updated readme
Apr 24, 2022
c7a32c1
Corrected capitalization of thing-types.xml
Apr 24, 2022
69afeee
Updated pom. xml to 3.3.0-SNAPSHOT
Apr 24, 2022
420e8ac
Updated copyright messages
Apr 24, 2022
d333cf5
Various minor cleanups
Apr 24, 2022
54de48d
Logging updates
Apr 24, 2022
c9d0c42
Updated dependencies
Apr 24, 2022
8f45cd3
Ignore lastposition for isConnected check
Apr 24, 2022
8448f81
Updated to use ThingHandlerService
Apr 25, 2022
370ff44
Fixed various review findings
Apr 30, 2022
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
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>
arjanmels marked this conversation as resolved.
Show resolved Hide resolved
<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