]> git.basschouten.com Git - openhab-addons.git/commitdiff
[Juicenet] Fix Charging state controls and override functionality (#15566)
authorEd Martin <edman007@edman007.com>
Sat, 9 Sep 2023 13:58:51 +0000 (09:58 -0400)
committerGitHub <noreply@github.com>
Sat, 9 Sep 2023 13:58:51 +0000 (15:58 +0200)
* [Juicenet] Fix typos in setOverride()
 Some obvious typos in setOverride() result in the timestamp being
  ignored which causes it to fail

Fixes #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>
bundles/org.openhab.binding.juicenet/README.md
bundles/org.openhab.binding.juicenet/src/main/java/org/openhab/binding/juicenet/internal/api/JuiceNetApi.java
bundles/org.openhab.binding.juicenet/src/main/java/org/openhab/binding/juicenet/internal/handler/JuiceNetDeviceHandler.java

index 0379975822aba2be04eb7041eac0c4339e8a5a28..fc727d62f9d4a6a0d381b4570dde27df987a2347 100644 (file)
@@ -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. |
index e9e7ef1516016e26b24494ec26fec69721753bd1..29785ddcc74b8c4aa99712bd52796b2e53b9ec5c 100644 (file)
@@ -156,8 +156,8 @@ public class JuiceNetApi {
         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);
     }
index 214066ab6b39464de52c3418a61caea95fb3fb48..aadc5a94162afb8b4eaef825bb401cd3f681b19c 100644 (file)
@@ -253,6 +253,13 @@ public class JuiceNetDeviceHandler extends BaseThingHandler {
 
                     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;
                 }
             }