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

[mercedesme] Additional mappings and channels #17143

Merged
merged 23 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
126 changes: 107 additions & 19 deletions bundles/org.openhab.binding.mercedesme/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MercedesMe Binding

This binding provides access to your Mercedes Benz vehicle like _Mercedes Me_ Smartphone App .
This binding provides access to your Mercedes Benz vehicle like _Mercedes Me_ Smartphone App.

## Installation Instructions

Expand Down Expand Up @@ -41,8 +41,8 @@ Bridge needs configuration in order to connect properly to your Mercedes Me acco
| pin | text | Mercedes Me Smartphone App PIN | N/A | no | no |
| region | text | Your region | EU | yes | no |
| refreshInterval | integer | API refresh interval | 15 | yes | no |
| callbackIP | text | Your region | N/A | yes | yes |
| callbackPort | integer | API refresh interval | N/A | yes | yes |
| callbackIP | text | IP Address of openHAB Device | N/A | yes | yes |
| callbackPort | integer | Port Number of openHAB Device | N/A | yes | yes |

Set `region` to your location

Expand Down Expand Up @@ -135,10 +135,6 @@ Channels are separated in groups:
| [position](#position) | Positioning Data |
| [tires](#tires) | Tire Information |

## Actions

See [Vehicle Actions](#vehicle-actions) which can be used in rules.

### Vehicle

Group name: `vehicle`
Expand Down Expand Up @@ -327,14 +323,16 @@ States and controls are depending on your vehicle capabilities.

| Channel | Type | Description | Read | Write |
|---------------------|----------------------|----------------------------------|------|-------|
| front-left | Switch | Front Left Seat Climatization | X | |
| front-right | Switch | Front Left Seat Climatization | X | |
| rear-left | Switch | Front Left Seat Climatization | X | |
| rear-right | Switch | Front Left Seat Climatization | X | |
| zone | Number | Selected Climatization Zone | X | X |
| temperature | Number:Temperature | Desired Temperature for Zone | X | X |
| activate | Switch | Start/Stop Climatization | X | X |
| front-left | Switch | AC Seat Front Left | X | |
| front-right | Switch | AC Seat Front Right | X | |
| rear-left | Switch | AC Seat Rear Left | X | |
| rear-right | Switch | AC Seat Rear Right | X | |
| zone | Number | AC Zone | X | X |
| temperature | Number:Temperature | AC Desired Temperature | X | X |
| activate | Switch | AC Precondition Control | X | X |
| ac-status | Number | AC Precondition Status | X | |
| aux-heat | Switch | Auxiliary Heating | X | X |
| aux-status | Number | Auxiliary Status | X | |

#### Zone Mapping

Expand Down Expand Up @@ -374,14 +372,35 @@ Fahrenheit

Triggers `TEMPERATURECONFIGURE` from [Command Name Mapping](#command-name-mapping)

#### Activate Switch
#### AC Precondition Control

Triggers `PRECONDSTART` and `PRECONDSTOP` from [Command Name Mapping](#command-name-mapping)

#### Auxiliary Heat Switch
#### AC Precondition Status Mapping

- 0 : No Request
- 1 : Battery or Fuel Low
- 2 : Available after Restart Engine
- 3 : Not Possible, Charging not Finished
- 4 : General Error</option>

#### Auxiliary Heating Switch

Triggers `AUXHEATSTART` and `AUXHEATSTOP` from [Command Name Mapping](#command-name-mapping)

#### Auxiliary Status Mapping

- 0 : None
- 1 : No Budget
- 2 : Budget Empty
- 4 : System Error
- 8 : Running Error
- 16 : Fuel on Reserve
- 32 : Reserve Reached
- 64 : Low Voltage
- 128 : Low Voltage Operation
- 256 : Communication Error

### Service

Group name: `service`
Expand All @@ -408,6 +427,16 @@ Traffic light status of the starter battery
- 0 : Green
- 1 : Yellow
- 2 : Red
- 3 : Service Disabled
- 4 : Vehicle Not Available

#### Tire Pressure Warnings Mapping

- 0 : No warning
- 1 : Soft warning
- 2 : Low warning
- 3 : Deflation
- 4 : Unknown warning

### Range

Expand Down Expand Up @@ -449,6 +478,8 @@ States and controls are depending on your vehicle capabilities.
| coupler-dc | Number | Coupler DC Status | X | |
| coupler-lock | Number | Coupler Lock Status | X | |
| active | Switch | Charging Active | X | |
| status | Number | Charge Status | X | |
| error | Number | Charge Error | X | |
| power | Number:Power | Current Charging Power | X | |
| end-time | DateTime | Estimated Charging End | X | |
| program | Number | Selected Charge Program | X | X |
Expand All @@ -475,6 +506,25 @@ States and controls are depending on your vehicle capabilities.
- 0 : Locked
- 1 : Unlocked

#### Charge Status Mapping

- 0 : Charging
- 1 : End of Charge
- 2 : Charge Break
- 3 : Charge Cable Unplugged
- 4 : Charging Failure
- 5 : Slow Charging
- 6 : Fast Charging
- 7 : Discharging

#### Charge Error Mapping

- 0 : None
- 1 : Cable
- 2 : Charging Disorder
- 3 : Charging Station
- 4 : Charging Type

#### Program Mapping

- 0 : DEFAULT_CHARGE_PROGRAM
Expand Down Expand Up @@ -540,11 +590,32 @@ In your Mercedes Me App front page

<img src="./doc/ElectricConsumptionUnits.png" width="300" height="300"/>

### Trip Duration
#### Trip Duration

Shown as String in format `d days, HH:mm`.
If duration is below 24 hours format is `HH:mm`.

### ECO Score

Group name: `eco`

All channels `read-only`

| Channel | Type | Description |
|---------------------|------------------------|-------------------------|
| accel | Number:Dimensionless | Acceleration Score |
| coasting | Number:Dimensionless | Coasting Score |
| constant | Number:Dimensionless | Constant Score |
| bonus | Number:Length | Bonus Range |

The Mercedes ECO Score is aimed to improve your driving behavior.

- Acceleration Score: smooth acceleration e.g. use *eco driving setting*
- Coasting Score: ideally use only *recuperation* instead of brake
- Constant Score: drive at constant speed e.g. use *cruise control*
- Bonus Range: assumed bonus range vs. a *very sportive driver*


### Position

Group name: `position`
Expand All @@ -553,8 +624,18 @@ Group name: `position`
|---------------------|----------------------|-------------------------------------------------|------|-------|
| heading | Number:Angle | Heading of Vehicle | X | |
| gps | Point | GPS Location Point of Vehicle | X | |
| status | Number | Status Positioning | X | |
| signal | Number | Request Light or Horn Signal to find Vehicle | | X |

#### Status Mapping

- 0 : Unknown
- 1 : Service Inactive
- 2 : Tracking Inactive
- 3 : Parked
- 4 : Ignition On
- 5 : Ok

#### Signal Settings

Command Options
Expand Down Expand Up @@ -585,11 +666,18 @@ All channels `read-only`

#### Sensor Available Mapping

- Not available yet
- 0 : All Sensors Located
- 1 : 1-3 Sensors are Missing
- 2 : All Sensors Missing
- 3 : System Error

#### Tire Marker Mapping

- Not available yet
- 0 : No warning
- 1 : Soft warning
- 2 : Low warning
- 3 : Deflation
- 4 : Unknown warning

### Commands

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public class Constants {
public static final String MB_KEY_CHARGE_COUPLER_DC_STATUS = "chargeCouplerDCStatus";
public static final String MB_KEY_CHARGE_COUPLER_AC_STATUS = "chargeCouplerACStatus";
public static final String MB_KEY_CHARGE_FLAP_DC_STATUS = "chargeFlapDCStatus";
public static final String MB_KEY_CHARGE_STATUS = "chargingstatus";
public static final String MB_KEY_CHARGE_ERROR = "chargingErrorDetails";
public static final String MB_KEY_SERVICEINTERVALDAYS = "serviceintervaldays";
public static final String MB_KEY_TIREWARNINGSRDK = "tirewarningsrdk";
public static final String MB_KEY_STARTER_BATTERY_STATE = "starterBatteryState";
Expand Down Expand Up @@ -149,6 +151,13 @@ public class Constants {
public static final String MB_KEY_COMMAND_DOORS_LOCK = "commandDoorsLock";
public static final String MB_KEY_COMMAND_WINDOWS_OPEN = "commandWindowsOpen";
public static final String MB_KEY_COMMAND_ENGINE_START = "commandEngineStart";
public static final String MB_KEY_POSITION_ERROR = "vehiclePositionErrorCode";
public static final String MB_KEY_AUXILIARY_WARNINGS = "auxheatwarnings";
public static final String MB_KEY_PRECOND_NOW_ERROR = "precondNowError";
public static final String MB_KEY_ECOSCORE_ACCEL = "ecoscoreaccel";
public static final String MB_KEY_ECOSCORE_CONSTANT = "ecoscoreconst";
public static final String MB_KEY_ECOSCORE_COASTING = "ecoscorefreewhl";
public static final String MB_KEY_ECOSCORE_BONUS = "ecoscorebonusrange";

public static final String GROUP_VEHICLE = "vehicle";
public static final String GROUP_DOORS = "doors";
Expand All @@ -159,6 +168,7 @@ public class Constants {
public static final String GROUP_RANGE = "range";
public static final String GROUP_CHARGE = "charge";
public static final String GROUP_TRIP = "trip";
public static final String GROUP_ECO = "eco";
public static final String GROUP_POSITION = "position";
public static final String GROUP_TIRES = "tires";
public static final String GROUP_COMMAND = "command";
Expand Down Expand Up @@ -247,6 +257,14 @@ public class Constants {
public static final String OH_CHANNEL_GPS = "gps";
public static final String OH_CHANNEL_CONS_CONV_UNIT = "cons-conv-unit";
public static final String OH_CHANNEL_CONS_EV_UNIT = "cons-ev-unit";
public static final String OH_CHANNEL_STATUS = "status";
public static final String OH_CHANNEL_ERROR = "error";
public static final String OH_CHANNEL_AC_STATUS = "ac-status";
public static final String OH_CHANNEL_AUX_STATUS = "aux-status";
public static final String OH_CHANNEL_ACCEL = "accel";
public static final String OH_CHANNEL_COASTING = "coasting";
public static final String OH_CHANNEL_CONSTANT = "constant";
public static final String OH_CHANNEL_BONUS_RANGE = "bonus";

public static final String CALLBACK_ENDPOINT = "/mb-auth";
// https://developer.mercedes-benz.com/content-page/api_migration_guide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package org.openhab.binding.mercedesme.internal;

import static org.openhab.binding.mercedesme.internal.Constants.*;

import javax.measure.Unit;
import javax.measure.quantity.Length;

Expand Down Expand Up @@ -56,16 +58,17 @@ public void added(ItemChannelLink element) {
if (Constants.BINDING_ID.equals(cuid.getBindingId())) {
MetadataKey key = new MetadataKey("unit", itemName);
switch (cuid.getId()) {
case Constants.GROUP_RANGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + "mileage":
case Constants.GROUP_RANGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + "range-electric":
case Constants.GROUP_RANGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + "radius-electric":
case Constants.GROUP_RANGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + "range-fuel":
case Constants.GROUP_RANGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + "radius-fuel":
case Constants.GROUP_RANGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + "range-hybrid":
case Constants.GROUP_RANGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + "radius-hybrid":
case Constants.GROUP_RANGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + "home-distance":
case Constants.GROUP_TRIP + ChannelUID.CHANNEL_GROUP_SEPARATOR + "distance":
case Constants.GROUP_TRIP + ChannelUID.CHANNEL_GROUP_SEPARATOR + "distance-reset":
case GROUP_RANGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_MILEAGE:
case GROUP_RANGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_RANGE_ELECTRIC:
case GROUP_RANGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_RADIUS_ELECTRIC:
case GROUP_RANGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_RANGE_FUEL:
case GROUP_RANGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_RADIUS_FUEL:
case GROUP_RANGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_RANGE_HYBRID:
case GROUP_RANGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_RADIUS_HYBRID:
case GROUP_RANGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_HOME_DISTANCE:
case GROUP_TRIP + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_DISTANCE:
case GROUP_TRIP + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_DISTANCE_RESET:
case GROUP_ECO + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_BONUS_RANGE:
if (metadataRegistry.get(key) == null) {
Unit<Length> lengthUnit = unitProvider.getUnit(Length.class);
if (ImperialUnits.FOOT.equals(lengthUnit)) {
Expand All @@ -75,17 +78,20 @@ public void added(ItemChannelLink element) {
}
}
break;
case Constants.GROUP_RANGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + "soc":
case Constants.GROUP_CHARGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + "max-soc":
case Constants.GROUP_RANGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + "fuel-level":
case GROUP_RANGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_SOC:
case GROUP_CHARGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_MAX_SOC:
case GROUP_RANGE + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_FUEL_LEVEL:
case GROUP_ECO + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_ACCEL:
case GROUP_ECO + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_COASTING:
case GROUP_ECO + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_CONSTANT:
if (metadataRegistry.get(key) == null) {
metadataRegistry.add(new Metadata(key, Units.PERCENT.getSymbol(), null));
}
break;
case Constants.GROUP_TIRES + ChannelUID.CHANNEL_GROUP_SEPARATOR + "pressure-front-left":
case Constants.GROUP_TIRES + ChannelUID.CHANNEL_GROUP_SEPARATOR + "pressure-front-right":
case Constants.GROUP_TIRES + ChannelUID.CHANNEL_GROUP_SEPARATOR + "pressure-rear-left":
case Constants.GROUP_TIRES + ChannelUID.CHANNEL_GROUP_SEPARATOR + "pressure-rear-right":
case GROUP_TIRES + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_PRESSURE_FRONT_LEFT:
case GROUP_TIRES + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_PRESSURE_FRONT_RIGHT:
case GROUP_TIRES + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_PRESSURE_REAR_LEFT:
case GROUP_TIRES + ChannelUID.CHANNEL_GROUP_SEPARATOR + OH_CHANNEL_PRESSURE_REAR_RIGHT:
if (metadataRegistry.get(key) == null) {
Unit<Length> lengthUnit = unitProvider.getUnit(Length.class);
if (ImperialUnits.FOOT.equals(lengthUnit)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ private ClientMessage createCM(CommandRequest cr) {

@Override
public void dispose() {
accountHandler.get().unregisterVin(config.get().vin);
accountHandler.ifPresent(ah -> {
ah.unregisterVin(config.get().vin);
});
super.dispose();
}

Expand Down
Loading