From 5dd8b421767a8fa23ac9c5ac4136280b6959b7e7 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Thu, 30 Sep 2021 21:16:53 +0200 Subject: [PATCH 01/12] Improvements for temperature channels Fixes #11317 Signed-off-by: Jacob Laursen --- .../internal/ExtendedDeviceStateUtil.java | 17 ++++++ .../handler/FridgeChannelSelector.java | 20 +++++-- .../handler/FridgeFreezerChannelSelector.java | 28 ++++++--- .../internal/handler/OvenChannelSelector.java | 28 ++++++--- .../WashingMachineChannelSelector.java | 15 ++++- .../resources/OH-INF/thing/channeltypes.xml | 58 ++----------------- .../main/resources/OH-INF/thing/fridge.xml | 10 +++- .../resources/OH-INF/thing/fridgefreezer.xml | 20 +++++-- .../src/main/resources/OH-INF/thing/oven.xml | 20 +++++-- .../resources/OH-INF/thing/washingmachine.xml | 5 +- .../internal/ExtendedDeviceStateUtilTest.java | 7 +++ 11 files changed, 138 insertions(+), 90 deletions(-) diff --git a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtil.java b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtil.java index f8c1692243ba0..323ed4e74dcff 100644 --- a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtil.java +++ b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtil.java @@ -14,6 +14,11 @@ 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 @@ */ 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 static String bytesToHex(byte[] bytes) { 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 (s.equals(TEMPERATURE_UNDEFINED)) { + return UnDefType.UNDEF; + } + int temperature = Integer.parseInt(s); + return new QuantityType<>(temperature, SIUnits.CELSIUS); + } } diff --git a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/FridgeChannelSelector.java b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/FridgeChannelSelector.java index 5efdd859d9078..20aa018be5333 100644 --- a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/FridgeChannelSelector.java +++ b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/FridgeChannelSelector.java @@ -17,10 +17,11 @@ 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 State getState(String s) { return null; } + public State getTemperatureState(String s) { + try { + return ExtendedDeviceStateUtil.getTemperatureState(s); + } catch (Exception e) { + logger.error("An exception occurred while converting '{}' into a State", s); + return null; + } + } + public String getMieleEnum(String s, DeviceMetaData dmd) { if (dmd.MieleEnum != null) { for (Entry enumEntry : dmd.MieleEnum.entrySet()) { diff --git a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/FridgeFreezerChannelSelector.java b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/FridgeFreezerChannelSelector.java index 26a32701408b1..1925174766b21 100644 --- a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/FridgeFreezerChannelSelector.java +++ b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/FridgeFreezerChannelSelector.java @@ -18,10 +18,11 @@ 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 State getState(String s) { return null; } + public State getTemperatureState(String s) { + try { + return ExtendedDeviceStateUtil.getTemperatureState(s); + } catch (Exception e) { + logger.error("An exception occurred while converting '{}' into a State", s); + return null; + } + } + public String getMieleEnum(String s, DeviceMetaData dmd) { if (dmd.MieleEnum != null) { for (Entry enumEntry : dmd.MieleEnum.entrySet()) { diff --git a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/OvenChannelSelector.java b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/OvenChannelSelector.java index bf93d57e51566..403e6a23edc76 100644 --- a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/OvenChannelSelector.java +++ b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/OvenChannelSelector.java @@ -18,11 +18,12 @@ 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 State getState(String s, DeviceMetaData dmd) { 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 State getState(String s) { return null; } + public State getTemperatureState(String s) { + try { + return ExtendedDeviceStateUtil.getTemperatureState(s); + } catch (Exception e) { + logger.error("An exception occurred while converting '{}' into a State", s); + return null; + } + } + public String getMieleEnum(String s, DeviceMetaData dmd) { if (dmd.MieleEnum != null) { for (Entry enumEntry : dmd.MieleEnum.entrySet()) { diff --git a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/WashingMachineChannelSelector.java b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/WashingMachineChannelSelector.java index 18b50e4f7cf40..89d349c1252f6 100644 --- a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/WashingMachineChannelSelector.java +++ b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/WashingMachineChannelSelector.java @@ -23,9 +23,9 @@ 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 State getState(String s, DeviceMetaData dmd) { 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) { @@ -223,6 +223,15 @@ public State getState(String s) { return null; } + public State getTemperatureState(String s) { + try { + return ExtendedDeviceStateUtil.getTemperatureState(s); + } catch (Exception e) { + logger.error("An exception occurred while converting '{}' into a State", s); + return null; + } + } + public String getMieleEnum(String s, DeviceMetaData dmd) { if (dmd.MieleEnum != null) { for (Entry enumEntry : dmd.MieleEnum.entrySet()) { diff --git a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml index 72721267faf53..349941736790c 100644 --- a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml +++ b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml @@ -86,25 +86,12 @@ - - Number - - Target temperature to be reached by the oven - - - - - Number - - Actual measured temperature in the oven - - - - - Number + + Number:Temperature - Program temperature in the oven - + Temperature reported by the appliance + Temperature + @@ -114,13 +101,6 @@ - - Number - - Current temperature in the fridge - - - String @@ -142,34 +122,6 @@ - - Number - - Current temperature in the freezer compartment - - - - - Number - - Target temperature to be reached by the freezer compartment - - - - - Number - - Current temperature in the fridge compartment - - - - - Number - - Target temperature to be reached by the fridge compartment - - - Number diff --git a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/fridge.xml b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/fridge.xml index a50007623b86b..2d9ffddd06319 100644 --- a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/fridge.xml +++ b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/fridge.xml @@ -16,8 +16,14 @@ - - + + + Current temperature in the fridge + + + + Target temperature to be reached by the fridge + diff --git a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/fridgefreezer.xml b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/fridgefreezer.xml index de6aa4371a525..14680b3e2eb66 100644 --- a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/fridgefreezer.xml +++ b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/fridgefreezer.xml @@ -19,10 +19,22 @@ - - - - + + + Current temperature in the freezer compartment + + + + Target temperature to be reached by the freezer compartment + + + + Current temperature in the fridge compartment + + + + Target temperature to be reached by the fridge compartment + diff --git a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/oven.xml b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/oven.xml index ac699106a29fb..a1501b334301d 100644 --- a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/oven.xml +++ b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/oven.xml @@ -22,10 +22,22 @@ - - - - + + + Target temperature to be reached by the oven + + + + Actual measured temperature in the oven + + + + Program temperature in the oven + + + + Program temperature in the oven + diff --git a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/washingmachine.xml b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/washingmachine.xml index cb138659676ae..bbd4f3774c32d 100644 --- a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/washingmachine.xml +++ b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/washingmachine.xml @@ -24,7 +24,10 @@ - + + + Temperature of the selected program + diff --git a/bundles/org.openhab.binding.miele/src/test/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtilTest.java b/bundles/org.openhab.binding.miele/src/test/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtilTest.java index 5bb52b743e4a5..5621d360d0673 100644 --- a/bundles/org.openhab.binding.miele/src/test/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtilTest.java +++ b/bundles/org.openhab.binding.miele/src/test/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtilTest.java @@ -15,6 +15,8 @@ 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; /** @@ -45,4 +47,9 @@ public void stringToBytesWhenTopBitIsUsedReturnsSingleByte() { 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")); + } } From fcf6e34a0c9c4d53adfa3c61b2001ae8e3c666d3 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Thu, 30 Sep 2021 21:18:55 +0200 Subject: [PATCH 02/12] Added jlaur as miele binding maintainer Signed-off-by: Jacob Laursen --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index 1913885694c0e..e95e3a802299a 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -168,7 +168,7 @@ /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 From 77ddcb80fe5e8ae2bfe40252781fb7ab59609710 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Thu, 30 Sep 2021 21:41:44 +0200 Subject: [PATCH 03/12] Fix spinning speed for washing machines Fixes #11317 Signed-off-by: Jacob Laursen --- .../miele/internal/handler/WashingMachineChannelSelector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/WashingMachineChannelSelector.java b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/WashingMachineChannelSelector.java index 89d349c1252f6..266d7714eb4ba 100644 --- a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/WashingMachineChannelSelector.java +++ b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/WashingMachineChannelSelector.java @@ -126,7 +126,7 @@ public State getState(String s, DeviceMetaData dmd) { 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) { From ece4a51e3f54892d6defbdb239f22d3af25d4903 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Thu, 30 Sep 2021 21:56:40 +0200 Subject: [PATCH 04/12] Added time as category for DateTime-related channels Fixes #11317 Signed-off-by: Jacob Laursen --- .../src/main/resources/OH-INF/thing/channeltypes.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml index 349941736790c..30002c046ad4e 100644 --- a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml +++ b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml @@ -36,6 +36,7 @@ DateTime Programmed start time of the program + Time @@ -43,6 +44,7 @@ DateTime Duration of the program running on the appliance + Time @@ -50,6 +52,7 @@ DateTime Time elapsed in the program running on the appliance + Time @@ -57,6 +60,7 @@ DateTime Time to finish the program running on the appliance + Time From aa35e6eac5e9aa31bef12d06ed27f95284b4530d Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Thu, 30 Sep 2021 22:10:02 +0200 Subject: [PATCH 05/12] Elapsed/remaining time channels are no longer marked as advanced. Fixes #11317 Signed-off-by: Jacob Laursen --- .../resources/OH-INF/thing/channeltypes.xml | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml index 30002c046ad4e..7dcbb227f9aa5 100644 --- a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml +++ b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml @@ -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"> - + String Current status of the appliance - + String Current program or function running on the appliance @@ -25,7 +25,7 @@ - + String Current phase of the program running on the appliance @@ -48,7 +48,7 @@ - + DateTime Time elapsed in the program running on the appliance @@ -56,7 +56,7 @@ - + DateTime Time to finish the program running on the appliance @@ -64,20 +64,20 @@ - + Contact Current state of the door of the appliance - + Switch Switch the appliance on or off - + Switch Stop the appliance @@ -98,42 +98,42 @@ - + Switch Start Super Cooling - + String Current status of the freezer compartment - + String Current status of the fridge compartment - + Switch Start Super Freezing - + Number Number of heating zones/plates on the hob - + Number Power level of the heating zone/plate @@ -147,14 +147,14 @@ - + String Remaining time of the heating zone/plate - + Number Current ventilation power @@ -168,14 +168,14 @@ - + Number:Power Power consumption by the currently running program on the appliance - + Number:Volume Water consumption by the currently running program on the appliance From 9d81090b0d0f9d2531d0c5b9aeb9bde3aa687194 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Thu, 30 Sep 2021 22:16:05 +0200 Subject: [PATCH 06/12] Fixed type for temperature item examples. Signed-off-by: Jacob Laursen --- bundles/org.openhab.binding.miele/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.binding.miele/README.md b/bundles/org.openhab.binding.miele/README.md index e8e3a715eb8b3..1a71c52920e42 100644 --- a/bundles/org.openhab.binding.miele/README.md +++ b/bundles/org.openhab.binding.miele/README.md @@ -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"} ``` From 9c6e64d1c5cf4af56841723c39914a3fd935ff2a Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Thu, 30 Sep 2021 23:03:30 +0200 Subject: [PATCH 07/12] Document all states (cross-appliance). Signed-off-by: Jacob Laursen --- .../miele/internal/MieleBindingConstants.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/MieleBindingConstants.java b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/MieleBindingConstants.java index 97af65635dbfa..d9fd24ae909b0 100644 --- a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/MieleBindingConstants.java +++ b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/MieleBindingConstants.java @@ -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"; From 3b044a90f43633c222d8bebf051fc21807707835 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Sat, 2 Oct 2021 12:01:51 +0200 Subject: [PATCH 08/12] Improved error handling for getTemperatureState Signed-off-by: Jacob Laursen --- .../miele/internal/handler/FridgeChannelSelector.java | 6 +++--- .../internal/handler/FridgeFreezerChannelSelector.java | 6 +++--- .../binding/miele/internal/handler/OvenChannelSelector.java | 6 +++--- .../internal/handler/WashingMachineChannelSelector.java | 6 +++--- .../binding/miele/internal/ExtendedDeviceStateUtilTest.java | 5 +++++ 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/FridgeChannelSelector.java b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/FridgeChannelSelector.java index 20aa018be5333..6fc1244efb53e 100644 --- a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/FridgeChannelSelector.java +++ b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/FridgeChannelSelector.java @@ -146,9 +146,9 @@ public State getState(String s) { public State getTemperatureState(String s) { try { return ExtendedDeviceStateUtil.getTemperatureState(s); - } catch (Exception e) { - logger.error("An exception occurred while converting '{}' into a State", s); - return null; + } catch (NumberFormatException e) { + logger.warn("An exception occurred while converting '{}' into a State", s); + return UnDefType.UNDEF; } } diff --git a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/FridgeFreezerChannelSelector.java b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/FridgeFreezerChannelSelector.java index 1925174766b21..60d76e29bbc5a 100644 --- a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/FridgeFreezerChannelSelector.java +++ b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/FridgeFreezerChannelSelector.java @@ -164,9 +164,9 @@ public State getState(String s) { public State getTemperatureState(String s) { try { return ExtendedDeviceStateUtil.getTemperatureState(s); - } catch (Exception e) { - logger.error("An exception occurred while converting '{}' into a State", s); - return null; + } catch (NumberFormatException e) { + logger.warn("An exception occurred while converting '{}' into a State", s); + return UnDefType.UNDEF; } } diff --git a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/OvenChannelSelector.java b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/OvenChannelSelector.java index 403e6a23edc76..4e8858e4157dd 100644 --- a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/OvenChannelSelector.java +++ b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/OvenChannelSelector.java @@ -220,9 +220,9 @@ public State getState(String s) { public State getTemperatureState(String s) { try { return ExtendedDeviceStateUtil.getTemperatureState(s); - } catch (Exception e) { - logger.error("An exception occurred while converting '{}' into a State", s); - return null; + } catch (NumberFormatException e) { + logger.warn("An exception occurred while converting '{}' into a State", s); + return UnDefType.UNDEF; } } diff --git a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/WashingMachineChannelSelector.java b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/WashingMachineChannelSelector.java index 266d7714eb4ba..294cfb61af9b8 100644 --- a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/WashingMachineChannelSelector.java +++ b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/WashingMachineChannelSelector.java @@ -226,9 +226,9 @@ public State getState(String s) { public State getTemperatureState(String s) { try { return ExtendedDeviceStateUtil.getTemperatureState(s); - } catch (Exception e) { - logger.error("An exception occurred while converting '{}' into a State", s); - return null; + } catch (NumberFormatException e) { + logger.warn("An exception occurred while converting '{}' into a State", s); + return UnDefType.UNDEF; } } diff --git a/bundles/org.openhab.binding.miele/src/test/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtilTest.java b/bundles/org.openhab.binding.miele/src/test/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtilTest.java index 5621d360d0673..1f6cd5f02de12 100644 --- a/bundles/org.openhab.binding.miele/src/test/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtilTest.java +++ b/bundles/org.openhab.binding.miele/src/test/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtilTest.java @@ -52,4 +52,9 @@ public void stringToBytesWhenTopBitIsUsedReturnsSingleByte() { public void getTemperatureStateWellFormedValueReturnsQuantityType() throws NumberFormatException { assertEquals(new QuantityType<>(42, SIUnits.CELSIUS), ExtendedDeviceStateUtil.getTemperatureState("42")); } + + @Test + public void getTemperatureStateNonNumericValueThrowsNumberFormatException() { + assertThrows(NumberFormatException.class, () -> ExtendedDeviceStateUtil.getTemperatureState("A")); + } } From e9276fec277d649e905e7dc46fa9b0c40095e3da Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Sat, 2 Oct 2021 12:32:15 +0200 Subject: [PATCH 09/12] Split current/target temperature into two channel types for label reuse Signed-off-by: Jacob Laursen --- .../main/resources/OH-INF/thing/channeltypes.xml | 16 ++++++++++++++++ .../src/main/resources/OH-INF/thing/fridge.xml | 6 ++---- .../resources/OH-INF/thing/fridgefreezer.xml | 12 ++++-------- .../src/main/resources/OH-INF/thing/oven.xml | 5 ++--- .../resources/OH-INF/thing/washingmachine.xml | 2 +- 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml index 7dcbb227f9aa5..d5e9a7c65183a 100644 --- a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml +++ b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml @@ -98,6 +98,22 @@ + + Number:Temperature + + Current temperature of the appliance + Temperature + + + + + Number:Temperature + + Target temperature to be reached by the appliance + Temperature + + + Switch diff --git a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/fridge.xml b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/fridge.xml index 2d9ffddd06319..ec2ed3ac6eaf8 100644 --- a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/fridge.xml +++ b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/fridge.xml @@ -16,12 +16,10 @@ - - + Current temperature in the fridge - - + Target temperature to be reached by the fridge diff --git a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/fridgefreezer.xml b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/fridgefreezer.xml index 14680b3e2eb66..d024ef00c58bc 100644 --- a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/fridgefreezer.xml +++ b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/fridgefreezer.xml @@ -19,20 +19,16 @@ - - + Current temperature in the freezer compartment - - + Target temperature to be reached by the freezer compartment - - + Current temperature in the fridge compartment - - + Target temperature to be reached by the fridge compartment diff --git a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/oven.xml b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/oven.xml index a1501b334301d..e5c8dd315db90 100644 --- a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/oven.xml +++ b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/oven.xml @@ -22,11 +22,10 @@ - - + Target temperature to be reached by the oven - + Actual measured temperature in the oven diff --git a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/washingmachine.xml b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/washingmachine.xml index bbd4f3774c32d..f7bf77e7ff846 100644 --- a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/washingmachine.xml +++ b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/washingmachine.xml @@ -24,7 +24,7 @@ - + Temperature of the selected program From 58f0569aef251a2716b8a35275f444616b4b5467 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Sat, 2 Oct 2021 12:45:10 +0200 Subject: [PATCH 10/12] Fix possible NullPointerException Signed-off-by: Jacob Laursen --- .../miele/internal/ExtendedDeviceStateUtil.java | 2 +- .../miele/internal/ExtendedDeviceStateUtilTest.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtil.java b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtil.java index 323ed4e74dcff..dfe1fd0411c98 100644 --- a/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtil.java +++ b/bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtil.java @@ -57,7 +57,7 @@ public static byte[] stringToBytes(String input) { * Convert string to Number:Temperature state with unit Celcius */ public static State getTemperatureState(String s) throws NumberFormatException { - if (s.equals(TEMPERATURE_UNDEFINED)) { + if (TEMPERATURE_UNDEFINED.equals(s)) { return UnDefType.UNDEF; } int temperature = Integer.parseInt(s); diff --git a/bundles/org.openhab.binding.miele/src/test/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtilTest.java b/bundles/org.openhab.binding.miele/src/test/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtilTest.java index 1f6cd5f02de12..88c2518aa6536 100644 --- a/bundles/org.openhab.binding.miele/src/test/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtilTest.java +++ b/bundles/org.openhab.binding.miele/src/test/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtilTest.java @@ -18,6 +18,7 @@ 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 @@ -53,8 +54,18 @@ public void getTemperatureStateWellFormedValueReturnsQuantityType() throws Numbe 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)); + } } From ee09a4ca980eb894ae0a137d326c466cb78a71ab Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Sat, 2 Oct 2021 13:33:39 +0200 Subject: [PATCH 11/12] Distinguish between oven program temperatures Signed-off-by: Jacob Laursen --- .../src/main/resources/OH-INF/thing/oven.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/oven.xml b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/oven.xml index e5c8dd315db90..3c935d4d97c02 100644 --- a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/oven.xml +++ b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/oven.xml @@ -30,11 +30,11 @@ Actual measured temperature in the oven - + Program temperature in the oven - + Program temperature in the oven From ff8da26dc1ccdcd55beb20429b508b909c48d6a6 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Sat, 2 Oct 2021 14:02:08 +0200 Subject: [PATCH 12/12] Mark oven program temperature 1 and 2 as advanced. Fixes #11317 Signed-off-by: Jacob Laursen --- .../src/main/resources/OH-INF/thing/channeltypes.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml index d5e9a7c65183a..92fde09740ff8 100644 --- a/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml +++ b/bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml @@ -90,7 +90,7 @@ - + Number:Temperature Temperature reported by the appliance