[miele] Fix auto-update for stop channel and synchronize switch channel with appliance state (#13071)
* Fix auto-update policy for stateless channel * Reflect appliance state in switch channel state Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
e0494bf44c
commit
cc3f9eac91
|
@ -448,7 +448,7 @@ DateTime Oven_ElapsedTime "Elapsed time" <time> {channel="miele:oven
|
|||
DateTime Oven_FinishTime "Remaining time" <time> {channel="miele:oven:home:oven:finish"}
|
||||
Number:Temperature Oven_CurrentTemperature <temperature> {channel="miele:oven:home:oven:measured"}
|
||||
Number:Temperature Oven_TargetTemperature <temperature> {channel="miele:oven:home:oven:target"}
|
||||
Switch Oven_Stop {channel="miele:oven:home:oven:stop", autoupdate="false"}
|
||||
Switch Oven_Stop {channel="miele:oven:home:oven:stop"}
|
||||
|
||||
String WashingMachine_State {channel="miele:washingmachine:home:washingmachine:state"}
|
||||
Number WashingMachine_RawState {channel="miele:washingmachine:home:washingmachine:rawState"}
|
||||
|
|
|
@ -52,6 +52,7 @@ public class MieleBindingConstants {
|
|||
public static final String PHASE_CHANNEL_ID = "rawPhase";
|
||||
public static final String SUPERCOOL_CHANNEL_ID = "supercool";
|
||||
public static final String SUPERFREEZE_CHANNEL_ID = "superfreeze";
|
||||
public static final String SWITCH_CHANNEL_ID = "switch";
|
||||
public static final String POWER_CONSUMPTION_CHANNEL_ID = "powerConsumption";
|
||||
public static final String WATER_CONSUMPTION_CHANNEL_ID = "waterConsumption";
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.openhab.binding.miele.internal.handler;
|
|||
import static org.openhab.binding.miele.internal.MieleBindingConstants.MIELE_DEVICE_CLASS_COFFEE_SYSTEM;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.binding.miele.internal.api.dto.DeviceProperty;
|
||||
import org.openhab.binding.miele.internal.exceptions.MieleRpcException;
|
||||
import org.openhab.core.i18n.LocaleProvider;
|
||||
import org.openhab.core.i18n.TranslationProvider;
|
||||
|
@ -100,4 +101,10 @@ public class CoffeeMachineHandler extends MieleApplianceHandler<CoffeeMachineCha
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAppliancePropertyChanged(DeviceProperty dp) {
|
||||
super.onAppliancePropertyChanged(dp);
|
||||
updateSwitchOnOffFromState(dp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import static org.openhab.binding.miele.internal.MieleBindingConstants.WATER_CON
|
|||
import java.math.BigDecimal;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.binding.miele.internal.api.dto.DeviceProperty;
|
||||
import org.openhab.binding.miele.internal.exceptions.MieleRpcException;
|
||||
import org.openhab.core.i18n.LocaleProvider;
|
||||
import org.openhab.core.i18n.TranslationProvider;
|
||||
|
@ -112,6 +113,12 @@ public class DishWasherHandler extends MieleApplianceHandler<DishwasherChannelSe
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAppliancePropertyChanged(DeviceProperty dp) {
|
||||
super.onAppliancePropertyChanged(dp);
|
||||
updateSwitchStartStopFromState(dp);
|
||||
}
|
||||
|
||||
public void onApplianceExtendedStateChanged(byte[] extendedDeviceState) {
|
||||
if (extendedDeviceState.length < EXTENDED_STATE_MIN_SIZE_BYTES) {
|
||||
logger.debug("Insufficient extended state data to extract consumption values: {}", extendedDeviceState);
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.openhab.binding.miele.internal.api.dto.DeviceProperty;
|
|||
import org.openhab.binding.miele.internal.api.dto.HomeDevice;
|
||||
import org.openhab.core.i18n.LocaleProvider;
|
||||
import org.openhab.core.i18n.TranslationProvider;
|
||||
import org.openhab.core.library.types.OnOffType;
|
||||
import org.openhab.core.thing.Bridge;
|
||||
import org.openhab.core.thing.ChannelUID;
|
||||
import org.openhab.core.thing.Thing;
|
||||
|
@ -288,6 +289,30 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
|||
updateState(channelUid, state);
|
||||
}
|
||||
|
||||
protected void updateSwitchOnOffFromState(DeviceProperty dp) {
|
||||
if (!STATE_PROPERTY_NAME.equals(dp.Name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Switch is trigger channel, but current state can be deduced from state.
|
||||
ChannelUID channelUid = new ChannelUID(getThing().getUID(), SWITCH_CHANNEL_ID);
|
||||
State state = OnOffType.from(!dp.Value.equals(String.valueOf(STATE_OFF)));
|
||||
logger.trace("Update state of {} to {} through '{}'", channelUid, state, dp.Name);
|
||||
updateState(channelUid, state);
|
||||
}
|
||||
|
||||
protected void updateSwitchStartStopFromState(DeviceProperty dp) {
|
||||
if (!STATE_PROPERTY_NAME.equals(dp.Name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Switch is trigger channel, but current state can be deduced from state.
|
||||
ChannelUID channelUid = new ChannelUID(getThing().getUID(), SWITCH_CHANNEL_ID);
|
||||
State state = OnOffType.from(dp.Value.equals(String.valueOf(STATE_RUNNING)));
|
||||
logger.trace("Update state of {} to {} through '{}'", channelUid, state, dp.Name);
|
||||
updateState(channelUid, state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update raw value channels for properties already mapped to text channels.
|
||||
* Currently ApplianceChannelSelector only supports 1:1 mapping from property
|
||||
|
|
|
@ -150,7 +150,6 @@ public enum OvenChannelSelector implements ApplianceChannelSelector {
|
|||
},
|
||||
DOOR("signalDoor", "door", OpenClosedType.class, false) {
|
||||
@Override
|
||||
|
||||
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||
if ("true".equals(s)) {
|
||||
return getState("OPEN");
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.openhab.binding.miele.internal.handler;
|
|||
import static org.openhab.binding.miele.internal.MieleBindingConstants.MIELE_DEVICE_CLASS_OVEN;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.binding.miele.internal.api.dto.DeviceProperty;
|
||||
import org.openhab.binding.miele.internal.exceptions.MieleRpcException;
|
||||
import org.openhab.core.i18n.LocaleProvider;
|
||||
import org.openhab.core.i18n.TranslationProvider;
|
||||
|
@ -106,4 +107,10 @@ public class OvenHandler extends MieleApplianceHandler<OvenChannelSelector> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAppliancePropertyChanged(DeviceProperty dp) {
|
||||
super.onAppliancePropertyChanged(dp);
|
||||
updateSwitchOnOffFromState(dp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.openhab.binding.miele.internal.handler;
|
|||
import static org.openhab.binding.miele.internal.MieleBindingConstants.MIELE_DEVICE_CLASS_TUMBLE_DRYER;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.binding.miele.internal.api.dto.DeviceProperty;
|
||||
import org.openhab.binding.miele.internal.exceptions.MieleRpcException;
|
||||
import org.openhab.core.i18n.LocaleProvider;
|
||||
import org.openhab.core.i18n.TranslationProvider;
|
||||
|
@ -100,4 +101,10 @@ public class TumbleDryerHandler extends MieleApplianceHandler<TumbleDryerChannel
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAppliancePropertyChanged(DeviceProperty dp) {
|
||||
super.onAppliancePropertyChanged(dp);
|
||||
updateSwitchStartStopFromState(dp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import static org.openhab.binding.miele.internal.MieleBindingConstants.WATER_CON
|
|||
import java.math.BigDecimal;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.binding.miele.internal.api.dto.DeviceProperty;
|
||||
import org.openhab.binding.miele.internal.exceptions.MieleRpcException;
|
||||
import org.openhab.core.i18n.LocaleProvider;
|
||||
import org.openhab.core.i18n.TranslationProvider;
|
||||
|
@ -114,6 +115,12 @@ public class WashingMachineHandler extends MieleApplianceHandler<WashingMachineC
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAppliancePropertyChanged(DeviceProperty dp) {
|
||||
super.onAppliancePropertyChanged(dp);
|
||||
updateSwitchStartStopFromState(dp);
|
||||
}
|
||||
|
||||
public void onApplianceExtendedStateChanged(byte[] extendedDeviceState) {
|
||||
if (extendedDeviceState.length < EXTENDED_STATE_MIN_SIZE_BYTES) {
|
||||
logger.debug("Insufficient extended state data to extract consumption values: {}", extendedDeviceState);
|
||||
|
|
|
@ -102,6 +102,7 @@
|
|||
<item-type>Switch</item-type>
|
||||
<label>Stop</label>
|
||||
<description>Stop the appliance</description>
|
||||
<autoUpdatePolicy>veto</autoUpdatePolicy>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="step" advanced="true">
|
||||
|
|
Loading…
Reference in New Issue