}
}
+ protected void handlePowerCommand(final ChannelUID channelUID, final Command command,
+ final HomeConnectApiClient apiClient, String stateNotOn)
+ throws CommunicationException, AuthorizationException, ApplianceOfflineException {
+ if (command instanceof OnOffType && CHANNEL_POWER_STATE.equals(channelUID.getId())) {
+ apiClient.setPowerState(getThingHaId(), OnOffType.ON.equals(command) ? STATE_POWER_ON : stateNotOn);
+ }
+ }
+
private int getCurrentBrightness(final ChannelUID channelUID, final HomeConnectApiClient apiClient)
throws CommunicationException, AuthorizationException, ApplianceOfflineException {
String id = channelUID.getId();
import org.openhab.binding.homeconnect.internal.client.exception.AuthorizationException;
import org.openhab.binding.homeconnect.internal.client.exception.CommunicationException;
import org.openhab.binding.homeconnect.internal.type.HomeConnectDynamicStateDescriptionProvider;
-import org.openhab.core.library.types.OnOffType;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.types.Command;
super.handleCommand(channelUID, command, apiClient);
// turn coffee maker on and standby
- if (command instanceof OnOffType && CHANNEL_POWER_STATE.equals(channelUID.getId())) {
- apiClient.setPowerState(getThingHaId(),
- OnOffType.ON.equals(command) ? STATE_POWER_ON : STATE_POWER_STANDBY);
- }
+ handlePowerCommand(channelUID, command, apiClient, STATE_POWER_STANDBY);
}
@Override
import java.util.Map;
import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.binding.homeconnect.internal.client.HomeConnectApiClient;
+import org.openhab.binding.homeconnect.internal.client.exception.ApplianceOfflineException;
+import org.openhab.binding.homeconnect.internal.client.exception.AuthorizationException;
+import org.openhab.binding.homeconnect.internal.client.exception.CommunicationException;
import org.openhab.binding.homeconnect.internal.type.HomeConnectDynamicStateDescriptionProvider;
+import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
+import org.openhab.core.types.Command;
import org.openhab.core.types.UnDefType;
/**
});
}
+ @Override
+ protected void handleCommand(final ChannelUID channelUID, final Command command,
+ final HomeConnectApiClient apiClient)
+ throws CommunicationException, AuthorizationException, ApplianceOfflineException {
+ super.handleCommand(channelUID, command, apiClient);
+
+ handlePowerCommand(channelUID, command, apiClient, STATE_POWER_OFF);
+ }
+
@Override
public String toString() {
return "HomeConnectCooktopHandler [haId: " + getThingHaId() + "]";
import org.openhab.binding.homeconnect.internal.client.exception.AuthorizationException;
import org.openhab.binding.homeconnect.internal.client.exception.CommunicationException;
import org.openhab.binding.homeconnect.internal.type.HomeConnectDynamicStateDescriptionProvider;
-import org.openhab.core.library.types.OnOffType;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.types.Command;
throws CommunicationException, AuthorizationException, ApplianceOfflineException {
super.handleCommand(channelUID, command, apiClient);
- if (command instanceof OnOffType) {
- if (CHANNEL_POWER_STATE.equals(channelUID.getId())) {
- apiClient.setPowerState(getThingHaId(),
- OnOffType.ON.equals(command) ? STATE_POWER_ON : STATE_POWER_OFF);
- }
- }
+ handlePowerCommand(channelUID, command, apiClient, STATE_POWER_OFF);
handleLightCommands(channelUID, command, apiClient);
}
throws CommunicationException, AuthorizationException, ApplianceOfflineException {
super.handleCommand(channelUID, command, apiClient);
- if (command instanceof OnOffType) {
- if (CHANNEL_POWER_STATE.equals(channelUID.getId())) {
- apiClient.setPowerState(getThingHaId(),
- OnOffType.ON.equals(command) ? STATE_POWER_ON : STATE_POWER_OFF);
- }
- }
+ handlePowerCommand(channelUID, command, apiClient, STATE_POWER_OFF);
// light commands
handleLightCommands(channelUID, command, apiClient);
throws CommunicationException, AuthorizationException, ApplianceOfflineException {
super.handleCommand(channelUID, command, apiClient);
- // turn coffee maker on and standby
- if (command instanceof OnOffType && CHANNEL_POWER_STATE.equals(channelUID.getId())) {
- apiClient.setPowerState(getThingHaId(),
- OnOffType.ON.equals(command) ? STATE_POWER_ON : STATE_POWER_STANDBY);
- }
+ handlePowerCommand(channelUID, command, apiClient, STATE_POWER_STANDBY);
String operationState = getOperationState();
if (operationState != null && INACTIVE_STATE.contains(operationState) && command instanceof QuantityType) {