Skip to content

Commit

Permalink
[Juicenet] Fix Charging state controls and override functionality (op…
Browse files Browse the repository at this point in the history
…enhab#15566)

* [Juicenet] Fix typos in setOverride()
 Some obvious typos in setOverride() result in the timestamp being
  ignored which causes it to fail

Fixes openhab#15564

* [Juicenet] Allow disabling the override
 - The charger has default settings upon plugin, changing the current state
    sets the overide to Y, this makes override settable only in the N direction
    to remove whatever settings were previously applied

* [Juicenet] Document new writable status of override

---------

Signed-off-by: Ed Martin <edman007@edman007.com>
Signed-off-by: Jørgen Austvik <jaustvik@acm.org>
  • Loading branch information
edman007 authored and austvik committed Mar 27, 2024
1 parent a094ba2 commit 1d4b87f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bundles/org.openhab.binding.juicenet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ A JuiceBox EV Charger requires a unitID which can also be found in the device se
| chargingState | String | N | Current charging state (Start Charging, Smart Charging, Stop Charging). |
| state | String | Y | This is the current device state (Available, Plugged-In, Charging, Error, Disconnected). |
| message | String | Y | This is a message detailing the state of the EV charger. |
| override | Switch | Y | Smart charging is overridden. |
| override | Switch | N | Smart charging is overridden. Set to "OFF" to remove override. |
| chargingTimeLeft | Number:Time | Y | Charging time left (seconds). |
| plugUnplugTime | DateTime | Y | Last time of either plug-in or plug-out. |
| targetTime | DateTime | N | “Start charging” start time, or time to start when overriding smart charging. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ public void setOverride(String token, int energy_at_plugin, Long override_time,
Map<String, Object> params = new HashMap<>();

params.put("energy_at_plugin", Integer.toString(energy_at_plugin));
params.put("override_time", Long.toString(energy_at_plugin));
params.put("energy_to_add", Integer.toString(energy_at_plugin));
params.put("override_time", Long.toString(override_time));
params.put("energy_to_add", Integer.toString(energy_to_add));

postApiCommand(ApiCommand.SET_OVERRIDE, token, params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ public void handleCommand(ChannelUID channelUID, Command command) {

api.setOverride(Objects.requireNonNull(token), energyAtPlugin, overrideTime, energyToAdd);

break;
}
case CHANNEL_OVERRIDE: {
if (command instanceof OnOffType onOffCommand && OnOffType.OFF.equals(onOffCommand)) {
api.setOverride(Objects.requireNonNull(token), 0, ((long) 0), 0);
}

break;
}
}
Expand Down

0 comments on commit 1d4b87f

Please sign in to comment.