]> git.basschouten.com Git - openhab-addons.git/commitdiff
[draytonwiser] Add comfort mode option to boiler controller (#9649)
authorAndrew Schofield <the.uncle.fungus@gmail.com>
Sat, 2 Jan 2021 19:58:16 +0000 (19:58 +0000)
committerGitHub <noreply@github.com>
Sat, 2 Jan 2021 19:58:16 +0000 (11:58 -0800)
Signed-off-by: Andrew Schofield <the.uncle.fungus@gmail.com>
bundles/org.openhab.binding.draytonwiser/README.md
bundles/org.openhab.binding.draytonwiser/src/main/java/org/openhab/binding/draytonwiser/internal/DraytonWiserBindingConstants.java
bundles/org.openhab.binding.draytonwiser/src/main/java/org/openhab/binding/draytonwiser/internal/api/DraytonWiserApi.java
bundles/org.openhab.binding.draytonwiser/src/main/java/org/openhab/binding/draytonwiser/internal/handler/ControllerHandler.java
bundles/org.openhab.binding.draytonwiser/src/main/java/org/openhab/binding/draytonwiser/internal/model/SystemDTO.java
bundles/org.openhab.binding.draytonwiser/src/main/resources/OH-INF/thing/thing-types.xml

index ef55911140bf325f7800f7f5d0ed191fcad145a7..6a05d3b5c0d23b49fa976470193b9feea8bb972b 100644 (file)
@@ -121,10 +121,11 @@ The `awaySetPoint` defines the temperature in degrees Celsius that will be sent
 
 #### Boiler Controller
 
-| Channel         | Item Type | Description                |
-|-----------------|-----------|----------------------------|
-| `awayModeState` | Switch    | Has away mode been enabled |
-| `ecoModeState`  | Switch    | Has eco mode been enabled  |
+| Channel            | Item Type | Description                   |
+|--------------------|-----------|-------------------------------|
+| `awayModeState`    | Switch    | Has away mode been enabled    |
+| `ecoModeState`     | Switch    | Has eco mode been enabled     |
+| `comfortModeState` | Switch    | Has comfort mode been enabled |
 
 #### Hot Water
 
index 370cae8805348530433a62a73bc9c7f59680c789..524536173e326cb55265b8009aac1dd9ffb29260 100644 (file)
@@ -104,6 +104,7 @@ public class DraytonWiserBindingConstants {
     public static final String CHANNEL_DEVICE_LOCKED = "deviceLocked";
     public static final String CHANNEL_SMARTPLUG_OUTPUT_STATE = "plugOutputState";
     public static final String CHANNEL_SMARTPLUG_AWAY_ACTION = "plugAwayAction";
+    public static final String CHANNEL_COMFORT_MODE_STATE = "comfortModeState";
 
     public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
             .unmodifiableSet(new HashSet<>(Arrays.asList(THING_TYPE_CONTROLLER, THING_TYPE_ROOM, THING_TYPE_ROOMSTAT,
index 8c03af39f90f976a4d22222aaf5dcfb46ee9c0d5..457194a4a73f4b5b8f6392de45431746c40dd3ab 100644 (file)
@@ -171,6 +171,11 @@ public class DraytonWiserApi {
         sendMessageToHeatHub(SMARTPLUG_ENDPOINT + id, "PATCH", payload);
     }
 
+    public void setComfortMode(final boolean comfortMode) throws DraytonWiserApiException {
+        final String payload = "{\"ComfortModeEnabled\":" + comfortMode + "}";
+        sendMessageToHeatHub(SYSTEM_ENDPOINT, "PATCH", payload);
+    }
+
     private synchronized @Nullable ContentResponse sendMessageToHeatHub(final String path, final HttpMethod method)
             throws DraytonWiserApiException {
         return sendMessageToHeatHub(path, method.asString(), "");
index a15779fa0cee1042c1f642b22557edb2f78639c4..4b6958085ad18e565d4a9ef0a3b2d660aca36d47 100644 (file)
@@ -60,6 +60,8 @@ public class ControllerHandler extends DraytonWiserThingHandler<ControllerData>
                 setAwayMode(onOffState);
             } else if (CHANNEL_ECO_MODE_STATE.equals(channelId)) {
                 setEcoMode(onOffState);
+            } else if (CHANNEL_COMFORT_MODE_STATE.equals(channelId)) {
+                setComfortMode(onOffState);
             }
         }
     }
@@ -76,6 +78,7 @@ public class ControllerHandler extends DraytonWiserThingHandler<ControllerData>
         updateState(CHANNEL_HEATCHANNEL_2_DEMAND_STATE, this::getHeatChannel2DemandState);
         updateState(CHANNEL_AWAY_MODE_STATE, this::getAwayModeState);
         updateState(CHANNEL_ECO_MODE_STATE, this::getEcoModeState);
+        updateState(CHANNEL_COMFORT_MODE_STATE, this::getComfortModeState);
     }
 
     @Override
@@ -139,6 +142,11 @@ public class ControllerHandler extends DraytonWiserThingHandler<ControllerData>
         return OnOffType.from(getData().system.getEcoModeEnabled() != null && getData().system.getEcoModeEnabled());
     }
 
+    private State getComfortModeState() {
+        return OnOffType
+                .from(getData().system.getComfortModeEnabled() != null && getData().system.getComfortModeEnabled());
+    }
+
     private void setAwayMode(final Boolean awayMode) throws DraytonWiserApiException {
         getApi().setAwayMode(awayMode);
     }
@@ -147,6 +155,10 @@ public class ControllerHandler extends DraytonWiserThingHandler<ControllerData>
         getApi().setEcoMode(ecoMode);
     }
 
+    private void setComfortMode(final Boolean comfortMode) throws DraytonWiserApiException {
+        getApi().setComfortMode(comfortMode);
+    }
+
     static class ControllerData {
         public final DeviceDTO device;
         public final SystemDTO system;
index bf2557b925463f1a876e5cacdf8d4b995cc9844b..7807138858f01111dc22bc3bd9133a0a6c12c804 100644 (file)
@@ -26,6 +26,7 @@ public class SystemDTO {
     private Boolean fotaEnabled;
     private Boolean valveProtectionEnabled;
     private Boolean ecoModeEnabled;
+    private Boolean comfortModeEnabled;
     private BoilerSettingsDTO boilerSettings;
     private Long unixTime;
     private String cloudConnectionStatus;
@@ -162,4 +163,12 @@ public class SystemDTO {
     public void setHotWaterButtonOverrideState(final String hotWaterButtonOverrideState) {
         this.hotWaterButtonOverrideState = hotWaterButtonOverrideState;
     }
+
+    public Boolean getComfortModeEnabled() {
+        return comfortModeEnabled;
+    }
+
+    public void setComfortModeEnabled(final Boolean comfortModeEnabled) {
+        this.comfortModeEnabled = comfortModeEnabled;
+    }
 }
index faf2196e34b6e08925776423f7f4779c530ec67b..6fd046ace695bba34e413f1c61fe556b41f3f4a9 100644 (file)
@@ -62,6 +62,7 @@
                        <channel id="currentSignalRSSI" typeId="signalRSSI-channel"/>
                        <channel id="currentSignalStrength" typeId="system.signal-strength"/>
                        <channel id="currentWiserSignalStrength" typeId="wiserSignalStrength-channel"/>
+                       <channel id="comfortModeState" typeId="comfortModeState-channel"/>
                </channels>
 
                <representation-property>id</representation-property>
                <description>Should the smart plug switch off when in away mode</description>
        </channel-type>
 
+       <channel-type id="comfortModeState-channel">
+               <item-type>Switch</item-type>
+               <label>Comfort Mode Active</label>
+               <description>Should the room pre-heat to achieve the desired temperature</description>
+       </channel-type>
+
 </thing:thing-descriptions>