]> git.basschouten.com Git - openhab-addons.git/commitdiff
[tado] Add channel for remaining time of open window override (#17576)
authorAndrew Fiddian-Green <software@whitebear.ch>
Mon, 21 Oct 2024 21:55:50 +0000 (22:55 +0100)
committerGitHub <noreply@github.com>
Mon, 21 Oct 2024 21:55:50 +0000 (23:55 +0200)
* [tado] Add open window override remaining time channel

Signed-off-by: AndrewFG <software@whitebear.ch>
bundles/org.openhab.binding.tado/README.md
bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/TadoBindingConstants.java
bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/adapter/TadoZoneStateAdapter.java
bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/handler/TadoZoneHandler.java
bundles/org.openhab.binding.tado/src/main/resources/OH-INF/i18n/tado.properties
bundles/org.openhab.binding.tado/src/main/resources/OH-INF/thing/thing-types.xml
bundles/org.openhab.binding.tado/src/main/resources/OH-INF/update/instructions.xml

index 568180c2412b90e2755ad8507f91a0e6dac63334..90973abe8473ef05e4d2b384d27b951094b3dc7e 100644 (file)
@@ -79,7 +79,8 @@ Name | Type | Description | Read/Write | Zone type
 `verticalSwing`<sup>2)</sup> | String | Vertical swing state, one of <sup>3)</sup> `OFF`, `ON`, `UP`, `MID_UP`, `MID`, `MID_DOWN`, `DOWN`, `AUTO` | RW | `AC`
 `horizontalSwing`<sup>2)</sup> | String | Horizontal swing state, one of <sup>3)</sup> `OFF`, `ON`, `LEFT`, `MID_LEFT`, `MID`, `MID_RIGHT`, `RIGHT`, `AUTO` | RW | `AC`
 `batteryLowAlarm` | Switch | A control device in the Zone has a low battery | R | Any Zone
-`openWindowDetected` | Switch | An open window has been detected in the Zone | R | Any Zone
+`openWindowDetected` | Switch | An open window has been detected in the Zone | R | `HEATING`, `AC`
+`openWindowRemainingTime` | Number:Time | The remaining Open Window heating/cooling Override time in the Zone | R | `HEATING`, `AC`
 `light` | Switch | State (`ON`, `OFF`) of the control panel light | RW | `AC`
 
 You will see some of the above mentioned Channels only if your tado° device supports the respective function.
index b92792b95bd150772be8740b9398a79195415d9a..eb7101128b9237350c019b6ea815b942be232cc8 100644 (file)
@@ -130,6 +130,8 @@ public class TadoBindingConstants {
     public static final String CHANNEL_ZONE_BATTERY_LOW_ALARM = "batteryLowAlarm";
     // open window detected channel
     public static final String CHANNEL_ZONE_OPEN_WINDOW_DETECTED = "openWindowDetected";
+    // open window heating/cooling override remaining time channel
+    public static final String CHANNEL_ZONE_OPEN_WINDOW_REMAINING_TIME = "openWindowRemainingTime";
 
     public static final String CHANNEL_MOBILE_DEVICE_AT_HOME = "atHome";
 
index fcc4d030d5a2965af729dd8fa10aaca1dbf1dac6..b70d229ff6897dfc068d0eeae9fc7c0d9ea397b7 100644 (file)
@@ -31,6 +31,7 @@ import org.openhab.binding.tado.swagger.codegen.api.model.CoolingZoneSetting;
 import org.openhab.binding.tado.swagger.codegen.api.model.GenericZoneSetting;
 import org.openhab.binding.tado.swagger.codegen.api.model.HeatingZoneSetting;
 import org.openhab.binding.tado.swagger.codegen.api.model.HotWaterZoneSetting;
+import org.openhab.binding.tado.swagger.codegen.api.model.OpenWindow;
 import org.openhab.binding.tado.swagger.codegen.api.model.Overlay;
 import org.openhab.binding.tado.swagger.codegen.api.model.OverlayTerminationConditionType;
 import org.openhab.binding.tado.swagger.codegen.api.model.PercentageDataPoint;
@@ -262,6 +263,18 @@ public class TadoZoneStateAdapter {
         return OnOffType.OFF;
     }
 
+    public State getOpenWindowRemainingTime() {
+        int seconds = 0;
+        OpenWindow openWindow = zoneState.getOpenWindow();
+        if (openWindow != null) {
+            Integer remainingSeconds = openWindow.getRemainingTimeInSeconds();
+            if (remainingSeconds != 0) {
+                seconds = remainingSeconds.intValue();
+            }
+        }
+        return new QuantityType<>(seconds, Units.SECOND);
+    }
+
     public State getLight() {
         if (zoneState.getSetting().getType() == TadoSystemType.AIR_CONDITIONING) {
             Power result = ((CoolingZoneSetting) zoneState.getSetting()).getLight();
index 37078ed17a75ebdcc5abc210481b85afeabcb65e..082b635d7f11f8f74b11a9584bf71913ce7db143 100644 (file)
@@ -350,6 +350,9 @@ public class TadoZoneHandler extends BaseHomeThingHandler {
 
             updateState(TadoBindingConstants.CHANNEL_ZONE_OPEN_WINDOW_DETECTED, state.getOpenWindowDetected());
 
+            updateState(TadoBindingConstants.CHANNEL_ZONE_OPEN_WINDOW_REMAINING_TIME,
+                    state.getOpenWindowRemainingTime());
+
             updateDynamicStateDescriptions(zoneState);
 
             onSuccessfulOperation();
@@ -514,6 +517,8 @@ public class TadoZoneHandler extends BaseHomeThingHandler {
                 capabilitiesSupport.batteryLowAlarm());
         removeListProcessChannel(removeList, TadoBindingConstants.CHANNEL_ZONE_OPEN_WINDOW_DETECTED,
                 capabilitiesSupport.openWindow());
+        removeListProcessChannel(removeList, TadoBindingConstants.CHANNEL_ZONE_OPEN_WINDOW_REMAINING_TIME,
+                capabilitiesSupport.openWindow());
         removeListProcessChannel(removeList, TadoBindingConstants.CHANNEL_ZONE_LIGHT, capabilitiesSupport.light());
         removeListProcessChannel(removeList, TadoBindingConstants.CHANNEL_ZONE_HORIZONTAL_SWING,
                 capabilitiesSupport.horizontalSwing());
index b9d79d3bb0d3037f9d2b58ed4275d6531931d7c2..defbd588d3e5009fa11d7b6594a14a865652006f 100644 (file)
@@ -84,6 +84,8 @@ channel-type.tado.light.label = Light
 channel-type.tado.light.description = State of control panel light (only if supported by AC)
 channel-type.tado.openWindowDetected.label = Open Window Detected
 channel-type.tado.openWindowDetected.description = Indicates if an open window has been detected
+channel-type.tado.openWindowRemainingTime.label = Override Remaining Time
+channel-type.tado.openWindowRemainingTime.description = The remaining Open Window heating/cooling Override time in the Zone
 channel-type.tado.operationMode.label = Zone Operation Mode
 channel-type.tado.operationMode.description = Active operation mode (schedule, manual, timer or until next change)
 channel-type.tado.operationMode.state.option.SCHEDULE = Schedule
index 66ef58897432c39f6aafd13531d963c2ae6f5497..a6b383a813afa53c1d858f5b50523c44a117d828 100644 (file)
@@ -55,6 +55,7 @@
                        <channel typeId="overlayExpiry" id="overlayExpiry"/>
                        <channel typeId="timerDuration" id="timerDuration"/>
                        <channel typeId="openWindowDetected" id="openWindowDetected"/>
+                       <channel typeId="openWindowRemainingTime" id="openWindowRemainingTime"/>
                        <channel typeId="system.low-battery" id="batteryLowAlarm">
                                <label>Battery Low Alarm</label>
                                <description>ON if one or more devices in the zone have a low battery</description>
@@ -63,7 +64,7 @@
 
                <properties>
                        <property name="vendor">tado°</property>
-                       <property name="thingTypeVersion">1</property>
+                       <property name="thingTypeVersion">2</property>
                </properties>
                <representation-property>id</representation-property>
 
                <state readOnly="true"/>
        </channel-type>
 
+       <channel-type id="openWindowRemainingTime">
+               <item-type>Number:Time</item-type>
+               <label>Override Remaining Time</label>
+               <description>The remaining Open Window heating/cooling Override time in the Zone</description>
+               <category>Window</category>
+               <state readOnly="true" pattern="%.0f %unit%"/>
+       </channel-type>
+
 </thing:thing-descriptions>
index 4cbe82b0ccb10fc5f775dd4ede15cae9f61bf156..f5a0c373f0951e57e65676b1e27397aa24d42bea 100644 (file)
                                <description>Current humidity in %</description>
                        </update-channel>
                </instruction-set>
+
+               <instruction-set targetVersion="2">
+                       <add-channel id="openWindowRemainingTime">
+                               <type>tado:openWindowRemainingTime</type>
+                       </add-channel>
+               </instruction-set>
+
        </thing-type>
 
 </update:update-descriptions>