]> git.basschouten.com Git - openhab-addons.git/blob
238e830f0adeb6148adcccb13fbca78140f96935
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.mielecloud.internal.handler;
14
15 import static org.openhab.binding.mielecloud.internal.MieleCloudBindingConstants.Channels.*;
16
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.core.thing.Thing;
22
23 /**
24  * ThingHandler implementation for the Miele oven devices.
25  *
26  * @author Roland Edelhoff - Initial contribution
27  * @author Björn Lange - Add channel state wrappers
28  * @author Benjamin Bolte - Add pre-heat finished channel, add info state channel and map signal flags from API
29  * @author Björn Lange - Add elapsed time channel
30  */
31 @NonNullByDefault
32 public class OvenDeviceThingHandler extends AbstractMieleThingHandler {
33     /**
34      * Creates a new {@link OvenDeviceThingHandler}.
35      *
36      * @param thing The thing to handle.
37      */
38     public OvenDeviceThingHandler(Thing thing) {
39         super(thing);
40     }
41
42     @Override
43     protected void updateDeviceState(DeviceChannelState device) {
44         updateState(channel(PROGRAM_ACTIVE), device.getProgramActive());
45         updateState(channel(PROGRAM_ACTIVE_RAW), device.getProgramActiveRaw());
46         updateState(channel(PROGRAM_PHASE), device.getProgramPhase());
47         updateState(channel(PROGRAM_PHASE_RAW), device.getProgramPhaseRaw());
48         updateState(channel(OPERATION_STATE), device.getOperationState());
49         updateState(channel(OPERATION_STATE_RAW), device.getOperationStateRaw());
50         updateState(channel(PROGRAM_START_STOP), device.getProgramStartStop());
51         updateState(channel(DELAYED_START_TIME), device.getDelayedStartTime());
52         updateState(channel(PROGRAM_ELAPSED_TIME), device.getProgramElapsedTime());
53         updateState(channel(PRE_HEAT_FINISHED), device.hasPreHeatFinished());
54         updateState(channel(TEMPERATURE_TARGET), device.getTemperatureTarget());
55         updateState(channel(TEMPERATURE_CURRENT), device.getTemperatureCurrent());
56         updateState(channel(POWER_ON_OFF), device.getPowerOnOff());
57         updateState(channel(ERROR_STATE), device.getErrorState());
58         updateState(channel(INFO_STATE), device.getInfoState());
59         updateState(channel(LIGHT_SWITCH), device.getLightSwitch());
60         updateState(channel(DOOR_STATE), device.getDoorState());
61     }
62
63     @Override
64     protected void updateTransitionState(TransitionChannelState transition) {
65         updateState(channel(PROGRAM_REMAINING_TIME), transition.getProgramRemainingTime());
66         updateState(channel(PROGRAM_PROGRESS), transition.getProgramProgress());
67         if (transition.hasFinishedChanged()) {
68             updateState(channel(FINISH_STATE), transition.getFinishState());
69         }
70     }
71
72     @Override
73     protected void updateActionState(ActionsChannelState actions) {
74         updateState(channel(REMOTE_CONTROL_CAN_BE_STARTED), actions.getRemoteControlCanBeStarted());
75         updateState(channel(REMOTE_CONTROL_CAN_BE_STOPPED), actions.getRemoteControlCanBeStopped());
76         updateState(channel(REMOTE_CONTROL_CAN_BE_SWITCHED_ON), actions.getRemoteControlCanBeSwitchedOn());
77         updateState(channel(REMOTE_CONTROL_CAN_BE_SWITCHED_OFF), actions.getRemoteControlCanBeSwitchedOff());
78         updateState(channel(LIGHT_CAN_BE_CONTROLLED), actions.getLightCanBeControlled());
79     }
80 }