]> git.basschouten.com Git - openhab-addons.git/commitdiff
Add laundry weight channel for washing machine (#16514)
authorJacob Laursen <jacob-github@vindvejr.dk>
Tue, 12 Mar 2024 21:35:33 +0000 (22:35 +0100)
committerGitHub <noreply@github.com>
Tue, 12 Mar 2024 21:35:33 +0000 (22:35 +0100)
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
bundles/org.openhab.binding.miele/README.md
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/WashingMachineChannelSelector.java
bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/WashingMachineHandler.java
bundles/org.openhab.binding.miele/src/main/resources/OH-INF/i18n/miele.properties
bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/channeltypes.xml
bundles/org.openhab.binding.miele/src/main/resources/OH-INF/thing/washingmachine.xml
bundles/org.openhab.binding.miele/src/main/resources/OH-INF/update/instructions.xml

index 4dabad472324631f7e750a04e6785ed1085a4933..4100aa5deae76ba47ae528d1d4789e288daac8c0 100644 (file)
@@ -370,6 +370,7 @@ See oven.
 | spinningspeed       | String               | Read       | Spinning speed in the program running on the appliance               |
 | energyConsumption   | Number:Energy        | Read       | Energy consumption by the currently running program on the appliance |
 | waterConsumption    | Number:Volume        | Read       | Water consumption by the currently running program on the appliance  |
+| laundryWeight       | Number:Mass          | Read       | Weight of the laundry inside the appliance                           |
 
 ##### Programs
 
index 6e2ca632716ae8f4eceeb9f93e26d8dbb9ce6d34..43aaea984daa97238e1ee4ac29d8a97949d93c8f 100644 (file)
@@ -60,6 +60,7 @@ public class MieleBindingConstants {
     public static final String FINISH_CHANNEL_ID = "finish";
     public static final String ENERGY_CONSUMPTION_CHANNEL_ID = "energyConsumption";
     public static final String WATER_CONSUMPTION_CHANNEL_ID = "waterConsumption";
+    public static final String LAUNDRY_WEIGHT_CHANNEL_ID = "laundryWeight";
 
     // List of all Thing Type UIDs
     public static final ThingTypeUID THING_TYPE_XGW3000 = new ThingTypeUID(BINDING_ID, "xgw3000");
index b590e790fc579f67692d6dca77c2d1a6f24c6d64..ff7b092abc10790cac7049971f86ca092193b6c0 100644 (file)
@@ -143,7 +143,8 @@ public enum WashingMachineChannelSelector implements ApplianceChannelSelector {
     ENERGY_CONSUMPTION(EXTENDED_DEVICE_STATE_PROPERTY_NAME, ENERGY_CONSUMPTION_CHANNEL_ID, QuantityType.class, false,
             true),
     WATER_CONSUMPTION(EXTENDED_DEVICE_STATE_PROPERTY_NAME, WATER_CONSUMPTION_CHANNEL_ID, QuantityType.class, false,
-            true);
+            true),
+    LAUNDRY_WEIGHT(EXTENDED_DEVICE_STATE_PROPERTY_NAME, LAUNDRY_WEIGHT_CHANNEL_ID, QuantityType.class, false, true);
 
     private final Logger logger = LoggerFactory.getLogger(WashingMachineChannelSelector.class);
 
index 1100b9f8ac26d45ed776f7923d7445d921f9150c..e4e855f41e8ba522a3aa2ea933fea3a088f78c30 100644 (file)
@@ -24,6 +24,7 @@ import org.openhab.core.i18n.TimeZoneProvider;
 import org.openhab.core.i18n.TranslationProvider;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.QuantityType;
+import org.openhab.core.library.unit.SIUnits;
 import org.openhab.core.library.unit.Units;
 import org.openhab.core.thing.ChannelUID;
 import org.openhab.core.thing.Thing;
@@ -47,6 +48,7 @@ import com.google.gson.JsonElement;
 public class WashingMachineHandler extends MieleApplianceHandler<WashingMachineChannelSelector>
         implements ExtendedDeviceStateListener {
 
+    private static final int LAUNDRY_WEIGHT_BYTE_POSITION = 44;
     private static final int ENERGY_CONSUMPTION_BYTE_POSITION = 51;
     private static final int WATER_CONSUMPTION_BYTE_POSITION = 53;
     private static final int EXTENDED_STATE_MIN_SIZE_BYTES = 54;
@@ -136,5 +138,11 @@ public class WashingMachineHandler extends MieleApplianceHandler<WashingMachineC
         var litres = new QuantityType<>(BigDecimal.valueOf(extendedDeviceState[WATER_CONSUMPTION_BYTE_POSITION] & 0xff),
                 Units.LITRE);
         updateExtendedState(WATER_CONSUMPTION_CHANNEL_ID, litres);
+
+        var weight = new QuantityType<>(
+                BigDecimal.valueOf(256 * (extendedDeviceState[LAUNDRY_WEIGHT_BYTE_POSITION] & 0xff)
+                        + (extendedDeviceState[LAUNDRY_WEIGHT_BYTE_POSITION + 1] & 0xff)),
+                SIUnits.GRAM);
+        updateExtendedState(LAUNDRY_WEIGHT_CHANNEL_ID, weight);
     }
 }
index bf5106ca868f3aa28e7a65ea672d4fdff82c057b..598ff5392e5eb62a59c9925e1bea6428f5ec09ba 100644 (file)
@@ -85,6 +85,8 @@ channel-type.miele.heat.label = Remaining Heat
 channel-type.miele.heat.description = Remaining heat level of the heating zone/plate
 channel-type.miele.info.label = Signal Information
 channel-type.miele.info.description = Signals information, check appliance for details
+channel-type.miele.laundry-weight.label = Laundry Weight
+channel-type.miele.laundry-weight.description = Weight of the laundry inside the appliance
 channel-type.miele.phase.label = Phase
 channel-type.miele.phase.description = Current phase of the program running on the appliance
 channel-type.miele.plates.label = Plates
index 5bfc1e0b02a66a2c02331ba85506defdb5ad26c8..2b871ca58490ec5a1b6ccbab556801d66e0042c1 100644 (file)
                <state readOnly="true" pattern="%.1f l"/>
        </channel-type>
 
+       <channel-type id="laundry-weight" advanced="true">
+               <item-type>Number:Mass</item-type>
+               <label>Laundry Weight</label>
+               <description>Weight of the laundry inside the appliance</description>
+               <state readOnly="true" pattern="%.3f %unit%"/>
+       </channel-type>
+
 </thing:thing-descriptions>
index 18644917017b0e0b27d8a9f808395d769e9dc2d9..c34c88f64b9412f49a7047b0f7c606b856bbd402 100644 (file)
                        <channel id="spinningspeed" typeId="spinningspeed"/>
                        <channel id="energyConsumption" typeId="energy-consumption"/>
                        <channel id="waterConsumption" typeId="water-consumption"/>
+                       <channel id="laundryWeight" typeId="laundry-weight"/>
                </channels>
 
                <properties>
-                       <property name="thingTypeVersion">2</property>
+                       <property name="thingTypeVersion">3</property>
                </properties>
 
                <representation-property>uid</representation-property>
index fdcf1676355004da2abc17c331c3d78c48966421..c331c3314492874ff24c1545b4315c2782508a89 100644 (file)
                                <type>miele:failure</type>
                        </add-channel>
                </instruction-set>
+               <instruction-set targetVersion="3">
+                       <add-channel id="laundryWeight">
+                               <type>miele:laundry-weight</type>
+                       </add-channel>
+               </instruction-set>
        </thing-type>
 
 </update:update-descriptions>