2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.mielecloud.internal.handler;
15 import static org.openhab.binding.mielecloud.internal.MieleCloudBindingConstants.Channels.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.mielecloud.internal.handler.channel.ActionsChannelState;
19 import org.openhab.binding.mielecloud.internal.handler.channel.DeviceChannelState;
20 import org.openhab.binding.mielecloud.internal.handler.channel.TransitionChannelState;
21 import org.openhab.binding.mielecloud.internal.webservice.api.json.ProcessAction;
22 import org.openhab.core.library.types.OnOffType;
23 import org.openhab.core.thing.ChannelUID;
24 import org.openhab.core.thing.Thing;
25 import org.openhab.core.types.Command;
28 * ThingHandler implementation for the Miele cooling devices.
30 * @author Roland Edelhoff - Initial contribution
31 * @author Björn Lange - Add channel state wrappers
32 * @author Benjamin Bolte - Add door state and door alarm, add info state channel and map signal flags from API
35 public class CoolingDeviceThingHandler extends AbstractMieleThingHandler {
37 * Creates a new {@link CoolingDeviceThingHandler}.
39 * @param thing The thing to handle.
41 public CoolingDeviceThingHandler(Thing thing) {
46 public void handleCommand(ChannelUID channelUID, Command command) {
47 super.handleCommand(channelUID, command);
49 if (!OnOffType.ON.equals(command) && !OnOffType.OFF.equals(command)) {
53 switch (channelUID.getId()) {
54 case FRIDGE_SUPER_COOL:
55 triggerProcessAction(OnOffType.ON.equals(command) ? ProcessAction.START_SUPERCOOLING
56 : ProcessAction.STOP_SUPERCOOLING);
59 case FREEZER_SUPER_FREEZE:
60 triggerProcessAction(OnOffType.ON.equals(command) ? ProcessAction.START_SUPERFREEZING
61 : ProcessAction.STOP_SUPERFREEZING);
67 protected void updateDeviceState(DeviceChannelState device) {
68 updateState(channel(OPERATION_STATE), device.getOperationState());
69 updateState(channel(OPERATION_STATE_RAW), device.getOperationStateRaw());
70 updateState(channel(FRIDGE_SUPER_COOL), device.getFridgeSuperCool());
71 updateState(channel(FREEZER_SUPER_FREEZE), device.getFreezerSuperFreeze());
72 updateState(channel(FRIDGE_TEMPERATURE_TARGET), device.getFridgeTemperatureTarget());
73 updateState(channel(FREEZER_TEMPERATURE_TARGET), device.getFreezerTemperatureTarget());
74 updateState(channel(FRIDGE_TEMPERATURE_CURRENT), device.getFridgeTemperatureCurrent());
75 updateState(channel(FREEZER_TEMPERATURE_CURRENT), device.getFreezerTemperatureCurrent());
76 updateState(channel(ERROR_STATE), device.getErrorState());
77 updateState(channel(INFO_STATE), device.getInfoState());
78 updateState(channel(DOOR_STATE), device.getDoorState());
79 updateState(channel(DOOR_ALARM), device.getDoorAlarm());
83 protected void updateTransitionState(TransitionChannelState transition) {
87 protected void updateActionState(ActionsChannelState actions) {
88 updateState(channel(SUPER_COOL_CAN_BE_CONTROLLED), actions.getSuperCoolCanBeControlled());
89 updateState(channel(SUPER_FREEZE_CAN_BE_CONTROLLED), actions.getSuperFreezeCanBeControlled());