Skip to content

Commit

Permalink
Adding Pause-Resume Endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
fifipil909 committed Mar 8, 2023
1 parent 96f3e7b commit 6411bf5
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class Car {
private boolean disableHvac = false;
private boolean disableLockStatus = false;

private PauseMode pausemode = PauseMode.UNKNOWN;
private PauseMode pausemode = PauseMode.OFF;
private ChargingStatus chargingStatus = ChargingStatus.UNKNOWN;
private ChargingMode chargingMode = ChargingMode.UNKNOWN;
private PlugStatus plugStatus = PlugStatus.UNKNOWN;
Expand All @@ -71,9 +71,8 @@ public enum ChargingMode {
}

public enum PauseMode {
RESUME,
PAUSE,
UNKNOWN
ON,
OFF
}

public enum ChargingStatus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ public void actionChargeMode(ChargingMode mode)

public void actionPause(PauseMode mode)
throws RenaultForbiddenException, RenaultNotImplementedException, RenaultActionException {
final String apiMode = PauseMode.PAUSE.equals(mode) ? "pause" : "resume";

final String apiMode = PauseMode.ON.equals(mode) ? "pause" : "resume";
final String path = "/commerce/v1/accounts/" + kamereonaccountId + "/kamereon/kcm/v1/vehicles/" + config.vin
+ "/charge/pause-resume?country=" + getCountry(config);
postKamereonRequest(path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,18 @@ public void handleCommand(ChannelUID channelUID, Command command) {
case RenaultBindingConstants.CHANNEL_PAUSE_MODE:
if (command instanceof RefreshType) {
reschedulePollingJob();
} else if (command instanceof StringType) {
} else if (command instanceof OnOffType) {
try {
PauseMode newMode = PauseMode.valueOf(command.toString());
if (!PauseMode.UNKNOWN.equals(newMode)) {
MyRenaultHttpSession httpSession = new MyRenaultHttpSession(this.config, httpClient);
try {
httpSession.initSesssion(car);
httpSession.actionPause(newMode);
car.setPauseMode(newMode);
updateState(CHANNEL_PAUSE_MODE, new StringType(newMode.toString()));
} catch (Exception e) {
logger.warn("Error My Renault Http Session.", e);
Thread.currentThread().interrupt();
}
MyRenaultHttpSession httpSession = new MyRenaultHttpSession(this.config, httpClient);
try {
httpSession.initSesssion(car);
httpSession.actionPause(newMode);
car.setPauseMode(newMode);
updateState(CHANNEL_PAUSE_MODE, new StringType(newMode.toString()));
} catch (Exception e) {
logger.warn("Error My Renault Http Session.", e);
Thread.currentThread().interrupt();
}
} catch (IllegalArgumentException e) {
logger.warn("Invalid Pause Mode {}.", command.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ channel-type.renault.chargingmode.state.option.UNKNOWN = Unknown
channel-type.renault.chargingmode.state.option.SCHEDULE_MODE = Schedule mode
channel-type.renault.chargingmode.state.option.ALWAYS_CHARGING = Instant charge
channel-type.renault.pausemode.label = Pause Mode
channel-type.renault.pausemode.state.option.UNKNOWN = Unknown
channel-type.renault.pausemode.state.option.RESUME = Resume
channel-type.renault.pausemode.state.option.PAUSE = Pause
channel-type.renault.chargingremainingtime.label = Charging Time Remaining
channel-type.renault.chargingstatus.label = Charging Status
channel-type.renault.chargingstatus.state.option.NOT_IN_CHARGE = Not charging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ channel-type.renault.chargingmode.label = Mode Charge
channel-type.renault.chargingmode.state.option.UNKNOWN = Inconnu
channel-type.renault.chargingmode.state.option.SCHEDULE_MODE = Mode planification
channel-type.renault.chargingmode.state.option.ALWAYS_CHARGING = Charge instantanée
channel-type.renault.pausemode.label = Pause Mode
channel-type.renault.pausemode.state.option.UNKNOWN = Inconnu
channel-type.renault.pausemode.state.option.RESUME = Démarrer
channel-type.renault.pausemode.state.option.PAUSE = Pause
channel-type.renault.chargingremainingtime.label = Temps Recharge Restant
channel-type.renault.chargingstatus.label = Statut Charge
channel-type.renault.chargingstatus.state.option.NOT_IN_CHARGE = Pas en charge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,9 @@
</state>
</channel-type>
<channel-type id="pausemode">
<item-type>String</item-type>
<label>Pause Mode</label>
<item-type>Switch</item-type>
<label>Pause Charge</label>
<state readOnly="false">
<options>
<option value="UNKNOWN">Unknown</option>
<option value="PAUSE">Pause</option>
<option value="RESUME">Resume</option>
</options>
</state>
</channel-type>
<channel-type id="chargingremainingtime">
Expand Down

0 comments on commit 6411bf5

Please sign in to comment.