Skip to content

Commit

Permalink
Add clothing weight channel for washing machine
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
  • Loading branch information
jlaur committed Mar 12, 2024
1 parent ba0cf3f commit 4adeb36
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions bundles/org.openhab.binding.miele/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
| clothingWeight | Number:Mass | Read | Weight of the clothing inside the appliance |

##### Programs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 CLOTHING_WEIGHT_CHANNEL_ID = "clothingWeight";

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_XGW3000 = new ThingTypeUID(BINDING_ID, "xgw3000");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationPr
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),
CLOTHING_WEIGHT(EXTENDED_DEVICE_STATE_PROPERTY_NAME, CLOTHING_WEIGHT_CHANNEL_ID, QuantityType.class, false, true);

private final Logger logger = LoggerFactory.getLogger(WashingMachineChannelSelector.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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;
Expand All @@ -47,6 +48,7 @@
public class WashingMachineHandler extends MieleApplianceHandler<WashingMachineChannelSelector>
implements ExtendedDeviceStateListener {

private static final int CLOTHING_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;
Expand Down Expand Up @@ -136,5 +138,11 @@ public void onApplianceExtendedStateChanged(byte[] extendedDeviceState) {
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[CLOTHING_WEIGHT_BYTE_POSITION] & 0xff)
+ (extendedDeviceState[CLOTHING_WEIGHT_BYTE_POSITION + 1] & 0xff)),
SIUnits.GRAM);
updateExtendedState(CLOTHING_WEIGHT_CHANNEL_ID, weight);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ thing-type.config.miele.xgw3000.userName.description = Name of a registered Miel

# channel types

channel-type.miele.clothing-weight.label = Clothing Weight
channel-type.miele.clothing-weight.description = Weight of the clothing inside the appliance
channel-type.miele.currentTemperature.label = Current Temperature
channel-type.miele.currentTemperature.description = Current temperature of the appliance
channel-type.miele.door.label = Door
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,11 @@
<state readOnly="true" pattern="%.1f l"/>
</channel-type>

<channel-type id="clothing-weight" advanced="true">
<item-type>Number:Mass</item-type>
<label>Clothing Weight</label>
<description>Weight of the clothing inside the appliance</description>
<state readOnly="true" pattern="%.3f %unit%"/>
</channel-type>

</thing:thing-descriptions>
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@
<channel id="spinningspeed" typeId="spinningspeed"/>
<channel id="energyConsumption" typeId="energy-consumption"/>
<channel id="waterConsumption" typeId="water-consumption"/>
<channel id="clothingWeight" typeId="clothing-weight"/>
</channels>

<properties>
<property name="thingTypeVersion">2</property>
<property name="thingTypeVersion">3</property>
</properties>

<representation-property>uid</representation-property>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@
<type>miele:failure</type>
</add-channel>
</instruction-set>
<instruction-set targetVersion="3">
<add-channel id="clothingWeight">
<type>miele:clothing-weight</type>
</add-channel>
</instruction-set>
</thing-type>

</update:update-descriptions>

0 comments on commit 4adeb36

Please sign in to comment.