]> git.basschouten.com Git - openhab-addons.git/commitdiff
[miele] Temperature channel improvements: UoM, categories and descriptions (#11329)
authorjlaur <jacob-github@vindvejr.dk>
Sat, 2 Oct 2021 17:57:22 +0000 (19:57 +0200)
committerGitHub <noreply@github.com>
Sat, 2 Oct 2021 17:57:22 +0000 (19:57 +0200)
* Improvements for temperature channels

Fixes #11317

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
* Added jlaur as miele binding maintainer

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
* Fix spinning speed for washing machines

Fixes #11317

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
* Added time as category for DateTime-related channels

Fixes #11317

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
* Elapsed/remaining time channels are no longer marked as advanced.

Fixes #11317

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
* Fixed type for temperature item examples.

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
* Document all states (cross-appliance).

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
* Improved error handling for getTemperatureState

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
* Split current/target temperature into two channel types for label reuse

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
* Fix possible NullPointerException

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
* Distinguish between oven program temperatures

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
* Mark oven program temperature 1 and 2 as advanced.

Fixes #11317

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
14 files changed:
CODEOWNERS
bundles/org.openhab.binding.miele/README.md
bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtil.java
bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/MieleBindingConstants.java
bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/FridgeChannelSelector.java
bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/FridgeFreezerChannelSelector.java
bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/OvenChannelSelector.java
bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/WashingMachineChannelSelector.java
bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml
bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/fridge.xml
bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/fridgefreezer.xml
bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/oven.xml
bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/washingmachine.xml
bundles/org.openhab.binding.miele/src/test/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtilTest.java

index 1913885694c0ed79d23b1d1cf78b572f3359e9b6..e95e3a802299a776673c33e41a3b85594509f220 100644 (file)
 /bundles/org.openhab.binding.meteoalerte/ @clinique
 /bundles/org.openhab.binding.meteoblue/ @9037568
 /bundles/org.openhab.binding.meteostick/ @cdjackson
-/bundles/org.openhab.binding.miele/ @kgoderis
+/bundles/org.openhab.binding.miele/ @kgoderis @jlaur
 /bundles/org.openhab.binding.mielecloud/ @BjoernLange
 /bundles/org.openhab.binding.mihome/ @pboos
 /bundles/org.openhab.binding.miio/ @marcelrv
index e8e3a715eb8b31cd88cb250b726d6722af76e3ca..1a71c52920e427898f78c860bfb132eccecd4284 100644 (file)
@@ -64,8 +64,8 @@ demo.items:
 ```
 String MieleFridgeState  (gMiele,gMieleFridge) {channel="miele:fridge:dilbeek:fridge:state"}
 Switch MieleFridgeSuperCool (gMiele,gMieleFridge) {channel="miele:fridge:dilbeek:fridge:supercool"}
-Number MieleFridgeCurrent (gMiele,gMieleFridge) {channel="miele:fridge:dilbeek:fridge:current"}
-Number MieleFridgeTarget (gMiele,gMieleFridge) {channel="miele:fridge:dilbeek:fridge:target"}
+Number:Temperature MieleFridgeCurrent (gMiele,gMieleFridge) {channel="miele:fridge:dilbeek:fridge:current"}
+Number:Temperature MieleFridgeTarget (gMiele,gMieleFridge) {channel="miele:fridge:dilbeek:fridge:target"}
 Contact MieleFridgeDoor (gMiele,gMieleFridge) {channel="miele:fridge:dilbeek:fridge:door"}
 Switch MieleFridgeStart (gMiele,gMieleFridge) {channel="miele:fridge:dilbeek:fridge:start"}
 ```
index f8c1692243ba06a20b9ed70eb3a7b18de9f81a55..dfe1fd0411c9843391399da81f6cb5703d97392b 100644 (file)
@@ -14,6 +14,11 @@ package org.openhab.binding.miele.internal;
 
 import java.nio.charset.StandardCharsets;
 
+import org.openhab.core.library.types.QuantityType;
+import org.openhab.core.library.unit.SIUnits;
+import org.openhab.core.types.State;
+import org.openhab.core.types.UnDefType;
+
 /**
  * The {@link ExtendedDeviceStateUtil} class contains utility methods for parsing
  * ExtendedDeviceState information
@@ -22,6 +27,7 @@ import java.nio.charset.StandardCharsets;
  */
 public class ExtendedDeviceStateUtil {
     private static final byte[] HEX_ARRAY = "0123456789ABCDEF".getBytes(StandardCharsets.US_ASCII);
+    private static final String TEMPERATURE_UNDEFINED = "32768";
 
     /**
      * Convert byte array to hex representation.
@@ -46,4 +52,15 @@ public class ExtendedDeviceStateUtil {
     public static byte[] stringToBytes(String input) {
         return input.getBytes(StandardCharsets.ISO_8859_1);
     }
+
+    /**
+     * Convert string to Number:Temperature state with unit Celcius
+     */
+    public static State getTemperatureState(String s) throws NumberFormatException {
+        if (TEMPERATURE_UNDEFINED.equals(s)) {
+            return UnDefType.UNDEF;
+        }
+        int temperature = Integer.parseInt(s);
+        return new QuantityType<>(temperature, SIUnits.CELSIUS);
+    }
 }
index 97af65635dbfa86ad6384807d75e8d9182543f3d..d9fd24ae909b093174a278f69d6d3f4be22c16b9 100644 (file)
@@ -58,8 +58,24 @@ public class MieleBindingConstants {
     public static final String MIELE_DEVICE_CLASS_FRIDGE_FREEZER = "FridgeFreezer";
 
     // Miele appliance states
+    public static final int STATE_UNKNOWN = 0;
+    public static final int STATE_OFF = 1;
+    public static final int STATE_STAND_BY = 2;
+    public static final int STATE_PROGRAMMED = 3;
+    public static final int STATE_WAITING_TO_START = 4;
+    public static final int STATE_RUNNING = 5;
+    public static final int STATE_PAUSED = 6;
+    public static final int STATE_END = 7;
+    public static final int STATE_FAILURE = 8;
+    public static final int STATE_ABORT = 9;
+    public static final int STATE_IDLE = 10;
+    public static final int STATE_RINSE_HOLD = 11;
+    public static final int STATE_SERVICE = 12;
     public static final int STATE_SUPER_FREEZING = 13;
     public static final int STATE_SUPER_COOLING = 14;
+    public static final int STATE_SUPER_HEATING = 15;
+    public static final int STATE_LOCKED = 145;
+    public static final int STATE_NOT_CONNECTED = 255;
 
     // Bridge config properties
     public static final String HOST = "ipAddress";
index 5efdd859d9078c430ce42d25a39f799980d5eb71..6fc1244efb53e15bd602277c02e3429a7eefcd19 100644 (file)
@@ -17,10 +17,11 @@ import static org.openhab.binding.miele.internal.MieleBindingConstants.SUPERCOOL
 import java.lang.reflect.Method;
 import java.util.Map.Entry;
 
+import org.openhab.binding.miele.internal.ExtendedDeviceStateUtil;
 import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceMetaData;
-import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.OpenClosedType;
+import org.openhab.core.library.types.QuantityType;
 import org.openhab.core.library.types.StringType;
 import org.openhab.core.types.State;
 import org.openhab.core.types.Type;
@@ -43,16 +44,16 @@ public enum FridgeChannelSelector implements ApplianceChannelSelector {
     COMPANY_ID("companyId", "companyId", StringType.class, true),
     STATE("state", "state", StringType.class, false),
     SUPERCOOL(null, SUPERCOOL_CHANNEL_ID, OnOffType.class, false),
-    FRIDGECURRENTTEMP("currentTemperature", "current", DecimalType.class, false) {
+    FRIDGECURRENTTEMP("currentTemperature", "current", QuantityType.class, false) {
         @Override
         public State getState(String s, DeviceMetaData dmd) {
-            return getState(s);
+            return getTemperatureState(s);
         }
     },
-    FRIDGETARGETTEMP("targetTemperature", "target", DecimalType.class, false) {
+    FRIDGETARGETTEMP("targetTemperature", "target", QuantityType.class, false) {
         @Override
         public State getState(String s, DeviceMetaData dmd) {
-            return getState(s);
+            return getTemperatureState(s);
         }
     },
     DOOR("signalDoor", "door", OpenClosedType.class, false) {
@@ -142,6 +143,15 @@ public enum FridgeChannelSelector implements ApplianceChannelSelector {
         return null;
     }
 
+    public State getTemperatureState(String s) {
+        try {
+            return ExtendedDeviceStateUtil.getTemperatureState(s);
+        } catch (NumberFormatException e) {
+            logger.warn("An exception occurred while converting '{}' into a State", s);
+            return UnDefType.UNDEF;
+        }
+    }
+
     public String getMieleEnum(String s, DeviceMetaData dmd) {
         if (dmd.MieleEnum != null) {
             for (Entry<String, JsonElement> enumEntry : dmd.MieleEnum.entrySet()) {
index 26a32701408b16e94812d762892853b69f083e86..60d76e29bbc5adc1fa5f5459b8a2c3929672ce0f 100644 (file)
@@ -18,10 +18,11 @@ import static org.openhab.binding.miele.internal.MieleBindingConstants.SUPERFREE
 import java.lang.reflect.Method;
 import java.util.Map.Entry;
 
+import org.openhab.binding.miele.internal.ExtendedDeviceStateUtil;
 import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceMetaData;
-import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.OpenClosedType;
+import org.openhab.core.library.types.QuantityType;
 import org.openhab.core.library.types.StringType;
 import org.openhab.core.types.State;
 import org.openhab.core.types.Type;
@@ -48,28 +49,28 @@ public enum FridgeFreezerChannelSelector implements ApplianceChannelSelector {
     FRIDGESTATE("fridgeState", "fridgestate", StringType.class, false),
     SUPERCOOL(null, SUPERCOOL_CHANNEL_ID, OnOffType.class, false),
     SUPERFREEZE(null, SUPERFREEZE_CHANNEL_ID, OnOffType.class, false),
-    FREEZERCURRENTTEMP("freezerCurrentTemperature", "freezercurrent", DecimalType.class, false) {
+    FREEZERCURRENTTEMP("freezerCurrentTemperature", "freezercurrent", QuantityType.class, false) {
         @Override
         public State getState(String s, DeviceMetaData dmd) {
-            return getState(s);
+            return getTemperatureState(s);
         }
     },
-    FREEZERTARGETTEMP("freezerTargetTemperature", "freezertarget", DecimalType.class, false) {
+    FREEZERTARGETTEMP("freezerTargetTemperature", "freezertarget", QuantityType.class, false) {
         @Override
         public State getState(String s, DeviceMetaData dmd) {
-            return getState(s);
+            return getTemperatureState(s);
         }
     },
-    FRIDGECURRENTTEMP("fridgeCurrentTemperature", "fridgecurrent", DecimalType.class, false) {
+    FRIDGECURRENTTEMP("fridgeCurrentTemperature", "fridgecurrent", QuantityType.class, false) {
         @Override
         public State getState(String s, DeviceMetaData dmd) {
-            return getState(s);
+            return getTemperatureState(s);
         }
     },
-    FRIDGETARGETTEMP("fridgeTargetTemperature", "fridgetarget", DecimalType.class, false) {
+    FRIDGETARGETTEMP("fridgeTargetTemperature", "fridgetarget", QuantityType.class, false) {
         @Override
         public State getState(String s, DeviceMetaData dmd) {
-            return getState(s);
+            return getTemperatureState(s);
         }
     },
     DOOR("signalDoor", "door", OpenClosedType.class, false) {
@@ -160,6 +161,15 @@ public enum FridgeFreezerChannelSelector implements ApplianceChannelSelector {
         return null;
     }
 
+    public State getTemperatureState(String s) {
+        try {
+            return ExtendedDeviceStateUtil.getTemperatureState(s);
+        } catch (NumberFormatException e) {
+            logger.warn("An exception occurred while converting '{}' into a State", s);
+            return UnDefType.UNDEF;
+        }
+    }
+
     public String getMieleEnum(String s, DeviceMetaData dmd) {
         if (dmd.MieleEnum != null) {
             for (Entry<String, JsonElement> enumEntry : dmd.MieleEnum.entrySet()) {
index bf93d57e51566eb47569f0ba475fea41a240e8ae..4e8858e4157dd4bc4921918d1a334d581ee2f45c 100644 (file)
@@ -18,11 +18,12 @@ import java.util.Date;
 import java.util.Map.Entry;
 import java.util.TimeZone;
 
+import org.openhab.binding.miele.internal.ExtendedDeviceStateUtil;
 import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceMetaData;
 import org.openhab.core.library.types.DateTimeType;
-import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.OpenClosedType;
+import org.openhab.core.library.types.QuantityType;
 import org.openhab.core.library.types.StringType;
 import org.openhab.core.types.State;
 import org.openhab.core.types.Type;
@@ -104,28 +105,28 @@ public enum OvenChannelSelector implements ApplianceChannelSelector {
             return getState(dateFormatter.format(date));
         }
     },
-    TARGET_TEMP("targetTemperature", "target", DecimalType.class, false) {
+    TARGET_TEMP("targetTemperature", "target", QuantityType.class, false) {
         @Override
         public State getState(String s, DeviceMetaData dmd) {
-            return getState(s);
+            return getTemperatureState(s);
         }
     },
-    MEASURED_TEMP("measuredTemperature", "measured", DecimalType.class, false) {
+    MEASURED_TEMP("measuredTemperature", "measured", QuantityType.class, false) {
         @Override
         public State getState(String s, DeviceMetaData dmd) {
-            return getState(s);
+            return getTemperatureState(s);
         }
     },
-    DEVICE_TEMP_ONE("deviceTemperature1", "temp1", DecimalType.class, false) {
+    DEVICE_TEMP_ONE("deviceTemperature1", "temp1", QuantityType.class, false) {
         @Override
         public State getState(String s, DeviceMetaData dmd) {
-            return getState(s);
+            return getTemperatureState(s);
         }
     },
-    DEVICE_TEMP_TWO("deviceTemperature2", "temp2", DecimalType.class, false) {
+    DEVICE_TEMP_TWO("deviceTemperature2", "temp2", QuantityType.class, false) {
         @Override
         public State getState(String s, DeviceMetaData dmd) {
-            return getState(s);
+            return getTemperatureState(s);
         }
     },
     DOOR("signalDoor", "door", OpenClosedType.class, false) {
@@ -216,6 +217,15 @@ public enum OvenChannelSelector implements ApplianceChannelSelector {
         return null;
     }
 
+    public State getTemperatureState(String s) {
+        try {
+            return ExtendedDeviceStateUtil.getTemperatureState(s);
+        } catch (NumberFormatException e) {
+            logger.warn("An exception occurred while converting '{}' into a State", s);
+            return UnDefType.UNDEF;
+        }
+    }
+
     public String getMieleEnum(String s, DeviceMetaData dmd) {
         if (dmd.MieleEnum != null) {
             for (Entry<String, JsonElement> enumEntry : dmd.MieleEnum.entrySet()) {
index 18b50e4f7cf402dea7f51fda4aabac00df945c85..294cfb61af9b8fd6162d212e8d9ecf387693ce43 100644 (file)
@@ -23,9 +23,9 @@ import java.util.Map.Entry;
 import java.util.TimeZone;
 
 import org.apache.commons.lang3.StringUtils;
+import org.openhab.binding.miele.internal.ExtendedDeviceStateUtil;
 import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceMetaData;
 import org.openhab.core.library.types.DateTimeType;
-import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.OpenClosedType;
 import org.openhab.core.library.types.QuantityType;
@@ -111,10 +111,10 @@ public enum WashingMachineChannelSelector implements ApplianceChannelSelector {
             return getState(dateFormatter.format(date));
         }
     },
-    TARGET_TEMP("targetTemperature", "target", DecimalType.class, false, false) {
+    TARGET_TEMP("targetTemperature", "target", QuantityType.class, false, false) {
         @Override
         public State getState(String s, DeviceMetaData dmd) {
-            return getState(s);
+            return getTemperatureState(s);
         }
     },
     SPINNING_SPEED("spinningSpeed", "spinningspeed", StringType.class, false, false) {
@@ -126,7 +126,7 @@ public enum WashingMachineChannelSelector implements ApplianceChannelSelector {
             if ("256".equals(s)) {
                 return getState("Rinsing");
             }
-            return getState(Integer.toString((Integer.valueOf(s) * 10)));
+            return getState(Integer.toString((Integer.valueOf(s))));
         }
     },
     DOOR("signalDoor", "door", OpenClosedType.class, false, false) {
@@ -223,6 +223,15 @@ public enum WashingMachineChannelSelector implements ApplianceChannelSelector {
         return null;
     }
 
+    public State getTemperatureState(String s) {
+        try {
+            return ExtendedDeviceStateUtil.getTemperatureState(s);
+        } catch (NumberFormatException e) {
+            logger.warn("An exception occurred while converting '{}' into a State", s);
+            return UnDefType.UNDEF;
+        }
+    }
+
     public String getMieleEnum(String s, DeviceMetaData dmd) {
         if (dmd.MieleEnum != null) {
             for (Entry<String, JsonElement> enumEntry : dmd.MieleEnum.entrySet()) {
index 72721267faf53ba077cc530f1fb30e73aeba13e8..92fde09740ff8a250a0edd67bae7879a760df522 100644 (file)
@@ -4,14 +4,14 @@
        xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
        xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
 
-       <channel-type id="state" advanced="false">
+       <channel-type id="state">
                <item-type>String</item-type>
                <label>Status</label>
                <description>Current status of the appliance</description>
                <state readOnly="true"></state>
        </channel-type>
 
-       <channel-type id="program" advanced="false">
+       <channel-type id="program">
                <item-type>String</item-type>
                <label>Program</label>
                <description>Current program or function running on the appliance</description>
@@ -25,7 +25,7 @@
                <state readOnly="true"></state>
        </channel-type>
 
-       <channel-type id="phase" advanced="false">
+       <channel-type id="phase">
                <item-type>String</item-type>
                <label>Phase</label>
                <description>Current phase of the program running on the appliance</description>
@@ -36,6 +36,7 @@
                <item-type>DateTime</item-type>
                <label>Start Time</label>
                <description>Programmed start time of the program</description>
+               <category>Time</category>
                <state readOnly="true" pattern="%1$tH:%1$tM"></state>
        </channel-type>
 
                <item-type>DateTime</item-type>
                <label>Duration</label>
                <description>Duration of the program running on the appliance</description>
+               <category>Time</category>
                <state readOnly="true" pattern="%1$tH:%1$tM"></state>
        </channel-type>
 
-       <channel-type id="elapsed" advanced="true">
+       <channel-type id="elapsed">
                <item-type>DateTime</item-type>
                <label>Elapsed Time</label>
                <description>Time elapsed in the program running on the appliance</description>
+               <category>Time</category>
                <state readOnly="true" pattern="%1$tH:%1$tM"></state>
        </channel-type>
 
-       <channel-type id="finish" advanced="true">
+       <channel-type id="finish">
                <item-type>DateTime</item-type>
                <label>Finish Time</label>
                <description>Time to finish the program running on the appliance</description>
+               <category>Time</category>
                <state readOnly="true" pattern="%1$tH:%1$tM"></state>
        </channel-type>
 
-       <channel-type id="door" advanced="false">
+       <channel-type id="door">
                <item-type>Contact</item-type>
                <label>Door</label>
                <description>Current state of the door of the appliance</description>
                <state readOnly="true"></state>
        </channel-type>
 
-       <channel-type id="switch" advanced="false">
+       <channel-type id="switch">
                <item-type>Switch</item-type>
                <label>Switch</label>
                <description>Switch the appliance on or off</description>
        </channel-type>
 
-       <channel-type id="stop" advanced="false">
+       <channel-type id="stop">
                <item-type>Switch</item-type>
                <label>Stop</label>
                <description>Stop the appliance</description>
                <state readOnly="true"></state>
        </channel-type>
 
-       <channel-type id="target" advanced="true">
-               <item-type>Number</item-type>
-               <label>Target Temperature</label>
-               <description>Target temperature to be reached by the oven</description>
-               <state readOnly="true"></state>
+       <channel-type id="temperature" advanced="true">
+               <item-type>Number:Temperature</item-type>
+               <label>Temperature</label>
+               <description>Temperature reported by the appliance</description>
+               <category>Temperature</category>
+               <state readOnly="true" pattern="%.0f %unit%"/>
        </channel-type>
 
-       <channel-type id="measured" advanced="true">
-               <item-type>Number</item-type>
-               <label>Measured Temperature</label>
-               <description>Actual measured temperature in the oven</description>
-               <state readOnly="true"></state>
+       <channel-type id="currentTemperature">
+               <item-type>Number:Temperature</item-type>
+               <label>Current Temperature</label>
+               <description>Current temperature of the appliance</description>
+               <category>Temperature</category>
+               <state readOnly="true" pattern="%.0f %unit%"/>
        </channel-type>
 
-       <channel-type id="temp" advanced="true">
-               <item-type>Number</item-type>
-               <label>Temperature</label>
-               <description>Program temperature in the oven</description>
-               <state readOnly="true"></state>
+       <channel-type id="targetTemperature">
+               <item-type>Number:Temperature</item-type>
+               <label>Target Temperature</label>
+               <description>Target temperature to be reached by the appliance</description>
+               <category>Temperature</category>
+               <state readOnly="true" pattern="%.0f %unit%"/>
        </channel-type>
 
-       <channel-type id="supercool" advanced="false">
+       <channel-type id="supercool">
                <item-type>Switch</item-type>
                <label>Super Cool</label>
                <description>Start Super Cooling</description>
                <state readOnly="false"></state>
        </channel-type>
 
-       <channel-type id="current" advanced="false">
-               <item-type>Number</item-type>
-               <label>Current Temperature</label>
-               <description>Current temperature in the fridge</description>
-               <state readOnly="true"></state>
-       </channel-type>
-
-       <channel-type id="freezerstate" advanced="false">
+       <channel-type id="freezerstate">
                <item-type>String</item-type>
                <label>Status</label>
                <description>Current status of the freezer compartment</description>
                <state readOnly="true"></state>
        </channel-type>
 
-       <channel-type id="fridgestate" advanced="false">
+       <channel-type id="fridgestate">
                <item-type>String</item-type>
                <label>Status</label>
                <description>Current status of the fridge compartment</description>
                <state readOnly="true"></state>
        </channel-type>
 
-       <channel-type id="superfreeze" advanced="false">
+       <channel-type id="superfreeze">
                <item-type>Switch</item-type>
                <label>Super Freeze</label>
                <description>Start Super Freezing</description>
                <state readOnly="false"></state>
        </channel-type>
 
-       <channel-type id="freezercurrent" advanced="false">
-               <item-type>Number</item-type>
-               <label>Current Temperature</label>
-               <description>Current temperature in the freezer compartment</description>
-               <state readOnly="true"></state>
-       </channel-type>
-
-       <channel-type id="freezertarget" advanced="true">
-               <item-type>Number</item-type>
-               <label>Target Temperature</label>
-               <description>Target temperature to be reached by the freezer compartment</description>
-               <state readOnly="true"></state>
-       </channel-type>
-
-       <channel-type id="fridgecurrent" advanced="false">
-               <item-type>Number</item-type>
-               <label>Current Temperature</label>
-               <description>Current temperature in the fridge compartment</description>
-               <state readOnly="true"></state>
-       </channel-type>
-
-       <channel-type id="fridgetarget" advanced="true">
-               <item-type>Number</item-type>
-               <label>Target Temperature</label>
-               <description>Target temperature to be reached by the fridge compartment</description>
-               <state readOnly="true"></state>
-       </channel-type>
-
-       <channel-type id="plates" advanced="false">
+       <channel-type id="plates">
                <item-type>Number</item-type>
                <label>Plates</label>
                <description>Number of heating zones/plates on the hob</description>
                <state readOnly="true"></state>
        </channel-type>
 
-       <channel-type id="power" advanced="false">
+       <channel-type id="power">
                <item-type>Number</item-type>
                <label>Power Step</label>
                <description>Power level of the heating zone/plate</description>
                <state readOnly="true"></state>
        </channel-type>
 
-       <channel-type id="time" advanced="true">
+       <channel-type id="time">
                <item-type>String</item-type>
                <label>Remaining Time</label>
                <description>Remaining time of the heating zone/plate</description>
                <state readOnly="true"></state>
        </channel-type>
 
-       <channel-type id="ventilation" advanced="false">
+       <channel-type id="ventilation">
                <item-type>Number</item-type>
                <label>Ventilation Power</label>
                <description>Current ventilation power</description>
                <state readOnly="true"></state>
        </channel-type>
 
-       <channel-type id="powerConsumption" advanced="false">
+       <channel-type id="powerConsumption">
                <item-type>Number:Power</item-type>
                <label>Power Consumption</label>
                <description>Power consumption by the currently running program on the appliance</description>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
 
-       <channel-type id="waterConsumption" advanced="false">
+       <channel-type id="waterConsumption">
                <item-type>Number:Volume</item-type>
                <label>Water Consumption</label>
                <description>Water consumption by the currently running program on the appliance</description>
index a50007623b86b4c914c7536b308c12be73f8a32d..ec2ed3ac6eaf82dd01cf449d688813aa7dad5cda 100644 (file)
                <channels>
                        <channel id="state" typeId="state"/>
                        <channel id="supercool" typeId="supercool"/>
-                       <channel id="current" typeId="current"/>
-                       <channel id="target" typeId="target"/>
+                       <channel id="current" typeId="currentTemperature">
+                               <description>Current temperature in the fridge</description>
+                       </channel>
+                       <channel id="target" typeId="targetTemperature">
+                               <description>Target temperature to be reached by the fridge</description>
+                       </channel>
                        <channel id="door" typeId="door"/>
                        <channel id="start" typeId="switch"/>
                </channels>
index de6aa4371a52515809ebe963f9f5873c0d623a22..d024ef00c58bc729e18d3207d071a753942b63ca 100644 (file)
                        <channel id="fridgestate" typeId="fridgestate"/>
                        <channel id="supercool" typeId="supercool"/>
                        <channel id="superfreeze" typeId="superfreeze"/>
-                       <channel id="freezercurrent" typeId="freezercurrent"/>
-                       <channel id="freezertarget" typeId="freezertarget"/>
-                       <channel id="fridgecurrent" typeId="fridgecurrent"/>
-                       <channel id="fridgetarget" typeId="fridgetarget"/>
+                       <channel id="freezercurrent" typeId="currentTemperature">
+                               <description>Current temperature in the freezer compartment</description>
+                       </channel>
+                       <channel id="freezertarget" typeId="targetTemperature">
+                               <description>Target temperature to be reached by the freezer compartment</description>
+                       </channel>
+                       <channel id="fridgecurrent" typeId="currentTemperature">
+                               <description>Current temperature in the fridge compartment</description>
+                       </channel>
+                       <channel id="fridgetarget" typeId="targetTemperature">
+                               <description>Target temperature to be reached by the fridge compartment</description>
+                       </channel>
                        <channel id="door" typeId="door"/>
                        <channel id="start" typeId="switch"/>
                </channels>
index ac699106a29fb9d30f7fe24d3a26995df88a1c38..3c935d4d97c02e1777d34701382cdcc420d96c9c 100644 (file)
                        <channel id="duration" typeId="duration"/>
                        <channel id="elapsed" typeId="elapsed"/>
                        <channel id="finish" typeId="finish"/>
-                       <channel id="target" typeId="target"/>
-                       <channel id="measured" typeId="measured"/>
-                       <channel id="temp1" typeId="temp"/>
-                       <channel id="temp2" typeId="temp"/>
+                       <channel id="target" typeId="targetTemperature">
+                               <description>Target temperature to be reached by the oven</description>
+                       </channel>
+                       <channel id="measured" typeId="currentTemperature">
+                               <label>Measured Temperature</label>
+                               <description>Actual measured temperature in the oven</description>
+                       </channel>
+                       <channel id="temp1" typeId="temperature">
+                               <label>Program Temperature 1</label>
+                               <description>Program temperature in the oven</description>
+                       </channel>
+                       <channel id="temp2" typeId="temperature">
+                               <label>Program Temperature 2</label>
+                               <description>Program temperature in the oven</description>
+                       </channel>
                        <channel id="door" typeId="door"/>
                        <channel id="stop" typeId="stop"/>
                        <channel id="switch" typeId="switch"/>
index cb138659676aea0acb418fe300fd4ebe1322b4c9..f7bf77e7ff84653d32d407f1393bd0bc4cad45df 100644 (file)
                        <channel id="finish" typeId="finish"/>
                        <channel id="door" typeId="door"/>
                        <channel id="switch" typeId="switch"/>
-                       <channel id="target" typeId="target"/>
+                       <channel id="target" typeId="targetTemperature">
+                               <label>Temperature</label>
+                               <description>Temperature of the selected program</description>
+                       </channel>
                        <channel id="spinningspeed" typeId="spinningspeed"/>
                        <channel id="powerConsumption" typeId="powerConsumption"/>
                        <channel id="waterConsumption" typeId="waterConsumption"/>
index 5bb52b743e4a56aee316c5ac000f124cbfb5c3c9..88c2518aa6536b1e7e6c955a8a1be9c937ea1192 100644 (file)
@@ -15,7 +15,10 @@ package org.openhab.binding.miele.internal;
 import static org.junit.jupiter.api.Assertions.*;
 
 import org.junit.jupiter.api.Test;
+import org.openhab.core.library.types.QuantityType;
+import org.openhab.core.library.unit.SIUnits;
 import org.openhab.core.test.java.JavaTest;
+import org.openhab.core.types.UnDefType;
 
 /**
  * This class provides test cases for {@link
@@ -45,4 +48,24 @@ public class ExtendedDeviceStateUtilTest extends JavaTest {
         byte[] actual = ExtendedDeviceStateUtil.stringToBytes("\u0000\u0080\u0000");
         assertArrayEquals(expected, actual);
     }
+
+    @Test
+    public void getTemperatureStateWellFormedValueReturnsQuantityType() throws NumberFormatException {
+        assertEquals(new QuantityType<>(42, SIUnits.CELSIUS), ExtendedDeviceStateUtil.getTemperatureState("42"));
+    }
+
+    @Test
+    public void getTemperatureStateMagicValueReturnsUndefined() throws NumberFormatException {
+        assertEquals(UnDefType.UNDEF, ExtendedDeviceStateUtil.getTemperatureState("32768"));
+    }
+
+    @Test
+    public void getTemperatureStateNonNumericValueThrowsNumberFormatException() {
+        assertThrows(NumberFormatException.class, () -> ExtendedDeviceStateUtil.getTemperatureState("A"));
+    }
+
+    @Test
+    public void getTemperatureStateNullValueThrowsNumberFormatException() {
+        assertThrows(NumberFormatException.class, () -> ExtendedDeviceStateUtil.getTemperatureState(null));
+    }
 }