Skip to content

Commit

Permalink
Fixed various review findings
Browse files Browse the repository at this point in the history
  • Loading branch information
Arjan Mels committed Apr 30, 2022
1 parent 8448f81 commit 223ac76
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 91 deletions.
2 changes: 1 addition & 1 deletion bundles/org.openhab.binding.groupepsa/NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ https://github.com/openhab/openhab-addons

== Third-party Content

Java Telegram Bot API
GeoJSON support for Gson
* License: Apache License 2.0
* Project: https://github.com/filosganga/geogson
* Source: https://github.com/filosganga/geogson
114 changes: 57 additions & 57 deletions bundles/org.openhab.binding.groupepsa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,85 +18,85 @@ 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.)

### properties
### 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)|
| 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.

### properties
### 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.|
| 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
| 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

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

### Items file

```perl
```
Group Auto
Number:ElectricCurrent Auto_Aux_Current "Auxillliary Battery Current [%.1f %unit%]" (Auto) ["Measurement","Current"] {channel="groupepsa:vehicle:opel:zafira:battery#current"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
import org.openhab.core.thing.binding.BaseBridgeHandler;
import org.openhab.core.thing.binding.ThingHandlerService;
import org.openhab.core.types.Command;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* The {@link GroupePSABridgeHandler} is responsible for handling commands,
Expand All @@ -55,8 +53,6 @@
*/
@NonNullByDefault
public class GroupePSABridgeHandler extends BaseBridgeHandler {
private final Logger logger = LoggerFactory.getLogger(GroupePSABridgeHandler.class);

public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_BRIDGE);
private static final long DEFAULT_POLLING_INTERVAL_M = TimeUnit.HOURS.toMinutes(1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;

import com.google.gson.annotations.SerializedName;

/**
* @author Arjan Mels - Initial contribution
*/
Expand All @@ -26,7 +28,8 @@ public class User {
private @Nullable String email;
private @Nullable String firstName;
private @Nullable String lastName;
private @Nullable Embedded _embedded;
@SerializedName("_embedded")
private @Nullable Embedded embedded;
private @Nullable ZonedDateTime createdAt;
private @Nullable ZonedDateTime updatedAt;

Expand All @@ -52,7 +55,7 @@ public String toString() {
}

public @Nullable List<Vehicle> getVehicles() {
final Embedded resEmbedded = _embedded;
final Embedded resEmbedded = embedded;
if (resEmbedded != null) {
return resEmbedded.vehicles;
} else {
Expand All @@ -72,6 +75,6 @@ public String toString() {
public String toString() {
return new ToStringBuilder(this).append("createdAt", createdAt).append("updatedAt", createdAt)
.append("email", email).append("firstName", firstName).append("lastName", lastName)
.append("vehicles", _embedded != null ? _embedded : null).toString();
.append("vehicles", embedded != null ? embedded : null).toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
public class VehicleStatus {

private @Nullable ZonedDateTime updatedAt;
private @Nullable Embedded _embedded;
@SerializedName("_embedded")
private @Nullable Embedded embedded;
private @Nullable Battery battery;
private @Nullable DoorsState doorsState;
private @Nullable List<Energy> energy = null;
Expand Down Expand Up @@ -65,7 +66,7 @@ public String toString() {
if (kinetic != null) {
return kinetic;
} else {
final Embedded finalEmbedded = _embedded;
final Embedded finalEmbedded = embedded;
if (finalEmbedded != null) {
final Extension finalExtension = finalEmbedded.extension;
if (finalExtension != null) {
Expand All @@ -80,7 +81,7 @@ public String toString() {
if (odometer != null) {
return odometer;
} else {
Embedded finalEmbedded = _embedded;
Embedded finalEmbedded = embedded;
if (finalEmbedded != null) {
final Extension finalExtension = finalEmbedded.extension;
if (finalExtension != null) {
Expand Down Expand Up @@ -137,7 +138,7 @@ public String toString() {

@Override
public String toString() {
return new ToStringBuilder(this).append("updatedAt", updatedAt).append("_embedded", _embedded)
return new ToStringBuilder(this).append("updatedAt", updatedAt).append("_embedded", embedded)
.append("battery", battery).append("doorsState", doorsState).append("energy", energy)
.append("environment", environment).append("ignition", ignition).append("kinetic", kinetic)
.append("odometer", odometer).append("lastPosition", lastPosition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ public class GroupePSAHandler extends BaseThingHandler {
private long maxQueryFrequencyNanos = TimeUnit.MINUTES.toNanos(1);
private long onlineIntervalM;

public GroupePSAHandler(Thing thing) {
super(thing);
}

@Override
protected @Nullable Bridge getBridge() {
return super.getBridge();
Expand All @@ -113,10 +117,6 @@ private void pollStatus() {
}
};

public GroupePSAHandler(Thing thing) {
super(thing);
}

@Override
public void handleCommand(ChannelUID channelUID, Command command) {
if (command instanceof RefreshType) {
Expand Down
Loading

0 comments on commit 223ac76

Please sign in to comment.