[homeconnect] Don't reset washer temp / spin speed when exiting from active program (#10745)

Use the provided planned time for a washing program to set the channel "remaining_program_time_state" when no program is active

Fix #10744
Fix #10703

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
pull/10770/head
lolodomo 2021-05-28 15:02:18 +02:00 committed by GitHub
parent ac7b5eae4d
commit a736a2cafd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 49 additions and 29 deletions

View File

@ -76,6 +76,7 @@ public class HomeConnectBindingConstants {
public static final String EVENT_REMOTE_CONTROL_START_ALLOWED = STATUS_REMOTE_CONTROL_START_ALLOWED;
public static final String EVENT_REMOTE_CONTROL_ACTIVE = STATUS_REMOTE_CONTROL_ACTIVE;
public static final String EVENT_LOCAL_CONTROL_ACTIVE = STATUS_LOCAL_CONTROL_ACTIVE;
public static final String EVENT_FINISH_IN_RELATIVE = "BSH.Common.Option.FinishInRelative";
public static final String EVENT_REMAINING_PROGRAM_TIME = "BSH.Common.Option.RemainingProgramTime";
public static final String EVENT_PROGRAM_PROGRESS = "BSH.Common.Option.ProgramProgress";
public static final String EVENT_SETPOINT_TEMPERATURE = "Cooking.Oven.Option.SetpointTemperature";
@ -162,6 +163,7 @@ public class HomeConnectBindingConstants {
public static final String STATE_EVENT_PRESENT_STATE_OFF = "BSH.Common.EnumType.EventPresentState.Off";
// List of program options
public static final String OPTION_FINISH_IN_RELATIVE = "BSH.Common.Option.FinishInRelative";
public static final String OPTION_REMAINING_PROGRAM_TIME = "BSH.Common.Option.RemainingProgramTime";
public static final String OPTION_PROGRAM_PROGRESS = "BSH.Common.Option.ProgramProgress";
public static final String OPTION_ELAPSED_PROGRAM_TIME = "BSH.Common.Option.ElapsedProgramTime";

View File

@ -221,7 +221,7 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
command.toFullString(), getThingLabel(), getThingHaId(), e.getMessage());
updateStatus(OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR);
resetChannelsOnOfflineEvent();
resetProgramStateChannels();
resetProgramStateChannels(true);
} catch (CommunicationException e) {
logger.debug("Could not handle command {}. API communication problem! error={}, haId={}",
command.toFullString(), e.getMessage(), getThingHaId());
@ -241,7 +241,7 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
getThingHaId());
updateStatus(OFFLINE);
resetChannelsOnOfflineEvent();
resetProgramStateChannels();
resetProgramStateChannels(true);
} else if (isThingOnline() && CONNECTED.equals(event.getType())) {
logger.debug("Received CONNECTED event. Update power state channel. haId={}", getThingHaId());
getThingChannel(CHANNEL_POWER_STATE).ifPresent(c -> updateChannel(c.getUID()));
@ -528,7 +528,7 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
getThingLabel(), getThingHaId(), e.getMessage());
updateStatus(OFFLINE);
resetChannelsOnOfflineEvent();
resetProgramStateChannels();
resetProgramStateChannels(true);
} catch (CommunicationException e) {
logger.debug("API communication problem while trying to update! thing={}, haId={}, error={}",
getThingLabel(), getThingHaId(), e.getMessage());
@ -542,8 +542,10 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
/**
* Reset program related channels.
*
* @param offline true if the device is considered as OFFLINE
*/
protected void resetProgramStateChannels() {
protected void resetProgramStateChannels(boolean offline) {
logger.debug("Resetting active program channel states. thing={}, haId={}", getThingLabel(), getThingHaId());
}
@ -770,7 +772,7 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
if (STATE_POWER_ON.equals(event.getValue())) {
getThingChannel(CHANNEL_SELECTED_PROGRAM_STATE).ifPresent(c -> updateChannel(c.getUID()));
} else {
resetProgramStateChannels();
resetProgramStateChannels(true);
getThingChannel(CHANNEL_SELECTED_PROGRAM_STATE)
.ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
}
@ -798,7 +800,7 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
.ifPresent(c -> updateState(c.getUID(), new QuantityType<>(0, PERCENT)));
getThingChannel(CHANNEL_ACTIVE_PROGRAM_STATE).ifPresent(c -> updateChannel(c.getUID()));
} else if (STATE_OPERATION_READY.equals(event.getValue())) {
resetProgramStateChannels();
resetProgramStateChannels(false);
}
};
}
@ -809,7 +811,7 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
getThingChannel(CHANNEL_ACTIVE_PROGRAM_STATE).ifPresent(channel -> updateState(channel.getUID(),
value == null ? UnDefType.UNDEF : new StringType(mapStringType(value))));
if (event.getValue() == null) {
resetProgramStateChannels();
resetProgramStateChannels(false);
}
};
}
@ -1050,7 +1052,7 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
processProgramOptions(program.getOptions());
return new StringType(mapStringType(program.getKey()));
} else {
resetProgramStateChannels();
resetProgramStateChannels(false);
return UnDefType.UNDEF;
}
}
@ -1271,6 +1273,7 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
getThingChannel(CHANNEL_DURATION).ifPresent(channel -> updateState(channel.getUID(),
new QuantityType<>(option.getValueAsInt(), SECOND)));
break;
case OPTION_FINISH_IN_RELATIVE:
case OPTION_REMAINING_PROGRAM_TIME:
getThingChannel(CHANNEL_REMAINING_PROGRAM_TIME_STATE)
.ifPresent(channel -> updateState(channel.getUID(),

View File

@ -95,8 +95,8 @@ public class HomeConnectCoffeeMakerHandler extends AbstractHomeConnectThingHandl
}
@Override
protected void resetProgramStateChannels() {
super.resetProgramStateChannels();
protected void resetProgramStateChannels(boolean offline) {
super.resetProgramStateChannels(offline);
getThingChannel(CHANNEL_PROGRAM_PROGRESS_STATE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_ACTIVE_PROGRAM_STATE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
}

View File

@ -87,8 +87,8 @@ public class HomeConnectCooktopHandler extends AbstractHomeConnectThingHandler {
}
@Override
protected void resetProgramStateChannels() {
super.resetProgramStateChannels();
protected void resetProgramStateChannels(boolean offline) {
super.resetProgramStateChannels(offline);
getThingChannel(CHANNEL_ACTIVE_PROGRAM_STATE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
}
}

View File

@ -61,6 +61,7 @@ public class HomeConnectDishwasherHandler extends AbstractHomeConnectThingHandle
handlers.put(EVENT_REMOTE_CONTROL_ACTIVE, defaultBooleanEventHandler(CHANNEL_REMOTE_CONTROL_ACTIVE_STATE));
handlers.put(EVENT_REMOTE_CONTROL_START_ALLOWED,
defaultBooleanEventHandler(CHANNEL_REMOTE_START_ALLOWANCE_STATE));
handlers.put(EVENT_FINISH_IN_RELATIVE, defaultRemainingProgramTimeEventHandler());
handlers.put(EVENT_REMAINING_PROGRAM_TIME, defaultRemainingProgramTimeEventHandler());
handlers.put(EVENT_PROGRAM_PROGRESS, defaultPercentQuantityTypeEventHandler(CHANNEL_PROGRAM_PROGRESS_STATE));
handlers.put(EVENT_SELECTED_PROGRAM, defaultSelectedProgramStateEventHandler());
@ -91,8 +92,8 @@ public class HomeConnectDishwasherHandler extends AbstractHomeConnectThingHandle
}
@Override
protected void resetProgramStateChannels() {
super.resetProgramStateChannels();
protected void resetProgramStateChannels(boolean offline) {
super.resetProgramStateChannels(offline);
getThingChannel(CHANNEL_REMAINING_PROGRAM_TIME_STATE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_PROGRAM_PROGRESS_STATE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_ACTIVE_PROGRAM_STATE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));

View File

@ -69,6 +69,7 @@ public class HomeConnectDryerHandler extends AbstractHomeConnectThingHandler {
handlers.put(EVENT_REMOTE_CONTROL_ACTIVE, defaultBooleanEventHandler(CHANNEL_REMOTE_CONTROL_ACTIVE_STATE));
handlers.put(EVENT_REMOTE_CONTROL_START_ALLOWED,
defaultBooleanEventHandler(CHANNEL_REMOTE_START_ALLOWANCE_STATE));
handlers.put(EVENT_FINISH_IN_RELATIVE, defaultRemainingProgramTimeEventHandler());
handlers.put(EVENT_REMAINING_PROGRAM_TIME, defaultRemainingProgramTimeEventHandler());
handlers.put(EVENT_PROGRAM_PROGRESS, defaultPercentQuantityTypeEventHandler(CHANNEL_PROGRAM_PROGRESS_STATE));
handlers.put(EVENT_LOCAL_CONTROL_ACTIVE, defaultBooleanEventHandler(CHANNEL_LOCAL_CONTROL_ACTIVE_STATE));
@ -109,10 +110,13 @@ public class HomeConnectDryerHandler extends AbstractHomeConnectThingHandler {
}
@Override
protected void resetProgramStateChannels() {
super.resetProgramStateChannels();
protected void resetProgramStateChannels(boolean offline) {
super.resetProgramStateChannels(offline);
getThingChannel(CHANNEL_REMAINING_PROGRAM_TIME_STATE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_PROGRAM_PROGRESS_STATE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_ACTIVE_PROGRAM_STATE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
if (offline) {
getThingChannel(CHANNEL_DRYER_DRYING_TARGET).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
}
}
}

View File

@ -267,8 +267,8 @@ public class HomeConnectHoodHandler extends AbstractHomeConnectThingHandler {
}
@Override
protected void resetProgramStateChannels() {
super.resetProgramStateChannels();
protected void resetProgramStateChannels(boolean offline) {
super.resetProgramStateChannels(offline);
getThingChannel(CHANNEL_ACTIVE_PROGRAM_STATE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_HOOD_INTENSIVE_LEVEL).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_HOOD_VENTING_LEVEL).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));

View File

@ -111,6 +111,7 @@ public class HomeConnectOvenHandler extends AbstractHomeConnectThingHandler {
handlers.put(EVENT_REMOTE_CONTROL_START_ALLOWED,
defaultBooleanEventHandler(CHANNEL_REMOTE_START_ALLOWANCE_STATE));
handlers.put(EVENT_SELECTED_PROGRAM, defaultSelectedProgramStateEventHandler());
handlers.put(EVENT_FINISH_IN_RELATIVE, defaultRemainingProgramTimeEventHandler());
handlers.put(EVENT_REMAINING_PROGRAM_TIME, defaultRemainingProgramTimeEventHandler());
handlers.put(EVENT_PROGRAM_PROGRESS, defaultPercentQuantityTypeEventHandler(CHANNEL_PROGRAM_PROGRESS_STATE));
handlers.put(EVENT_ELAPSED_PROGRAM_TIME, defaultElapsedProgramTimeEventHandler());
@ -130,7 +131,7 @@ public class HomeConnectOvenHandler extends AbstractHomeConnectThingHandler {
if (STATE_POWER_ON.equals(event.getValue())) {
updateChannels();
} else {
resetProgramStateChannels();
resetProgramStateChannels(true);
getThingChannel(CHANNEL_SELECTED_PROGRAM_STATE)
.ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_ACTIVE_PROGRAM_STATE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
@ -222,8 +223,8 @@ public class HomeConnectOvenHandler extends AbstractHomeConnectThingHandler {
}
@Override
protected void resetProgramStateChannels() {
super.resetProgramStateChannels();
protected void resetProgramStateChannels(boolean offline) {
super.resetProgramStateChannels(offline);
getThingChannel(CHANNEL_REMAINING_PROGRAM_TIME_STATE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_PROGRAM_PROGRESS_STATE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_ELAPSED_PROGRAM_TIME).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));

View File

@ -88,6 +88,7 @@ public class HomeConnectWasherDryerHandler extends AbstractHomeConnectThingHandl
handlers.put(EVENT_REMOTE_CONTROL_ACTIVE, defaultBooleanEventHandler(CHANNEL_REMOTE_CONTROL_ACTIVE_STATE));
handlers.put(EVENT_REMOTE_CONTROL_START_ALLOWED,
defaultBooleanEventHandler(CHANNEL_REMOTE_START_ALLOWANCE_STATE));
handlers.put(EVENT_FINISH_IN_RELATIVE, defaultRemainingProgramTimeEventHandler());
handlers.put(EVENT_REMAINING_PROGRAM_TIME, defaultRemainingProgramTimeEventHandler());
handlers.put(EVENT_PROGRAM_PROGRESS, defaultPercentQuantityTypeEventHandler(CHANNEL_PROGRAM_PROGRESS_STATE));
handlers.put(EVENT_LOCAL_CONTROL_ACTIVE, defaultBooleanEventHandler(CHANNEL_LOCAL_CONTROL_ACTIVE_STATE));
@ -142,12 +143,15 @@ public class HomeConnectWasherDryerHandler extends AbstractHomeConnectThingHandl
}
@Override
protected void resetProgramStateChannels() {
super.resetProgramStateChannels();
protected void resetProgramStateChannels(boolean offline) {
super.resetProgramStateChannels(offline);
getThingChannel(CHANNEL_REMAINING_PROGRAM_TIME_STATE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_PROGRAM_PROGRESS_STATE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_ACTIVE_PROGRAM_STATE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_WASHER_TEMPERATURE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_WASHER_SPIN_SPEED).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
if (offline) {
getThingChannel(CHANNEL_WASHER_TEMPERATURE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_WASHER_SPIN_SPEED).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_DRYER_DRYING_TARGET).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
}
}
}

View File

@ -88,6 +88,7 @@ public class HomeConnectWasherHandler extends AbstractHomeConnectThingHandler {
handlers.put(EVENT_REMOTE_CONTROL_ACTIVE, defaultBooleanEventHandler(CHANNEL_REMOTE_CONTROL_ACTIVE_STATE));
handlers.put(EVENT_REMOTE_CONTROL_START_ALLOWED,
defaultBooleanEventHandler(CHANNEL_REMOTE_START_ALLOWANCE_STATE));
handlers.put(EVENT_FINISH_IN_RELATIVE, defaultRemainingProgramTimeEventHandler());
handlers.put(EVENT_REMAINING_PROGRAM_TIME, defaultRemainingProgramTimeEventHandler());
handlers.put(EVENT_PROGRAM_PROGRESS, defaultPercentQuantityTypeEventHandler(CHANNEL_PROGRAM_PROGRESS_STATE));
handlers.put(EVENT_LOCAL_CONTROL_ACTIVE, defaultBooleanEventHandler(CHANNEL_LOCAL_CONTROL_ACTIVE_STATE));
@ -149,12 +150,16 @@ public class HomeConnectWasherHandler extends AbstractHomeConnectThingHandler {
}
@Override
protected void resetProgramStateChannels() {
super.resetProgramStateChannels();
protected void resetProgramStateChannels(boolean offline) {
super.resetProgramStateChannels(offline);
getThingChannel(CHANNEL_REMAINING_PROGRAM_TIME_STATE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_PROGRAM_PROGRESS_STATE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_ACTIVE_PROGRAM_STATE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_WASHER_TEMPERATURE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_WASHER_SPIN_SPEED).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
if (offline) {
getThingChannel(CHANNEL_WASHER_TEMPERATURE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_WASHER_SPIN_SPEED).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_WASHER_IDOS1).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
getThingChannel(CHANNEL_WASHER_IDOS2).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
}
}
}