]> git.basschouten.com Git - openhab-addons.git/blob
d9a629a44559dae97303c48c82824f74a02c7460
[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.library.types.OnOffType;
22 import org.openhab.core.thing.Thing;
23
24 /**
25  * ThingHandler implementation for the Miele coffee devices.
26  *
27  * @author Roland Edelhoff - Initial contribution
28  * @author Björn Lange - Switch from polling to SSE, add channel state wrappers
29  * @author Benjamin Bolte - Add info state channel and map signal flags from API
30  * @author Björn Lange - Add elapsed time channel
31  */
32 @NonNullByDefault
33 public class CoffeeSystemThingHandler extends AbstractMieleThingHandler {
34     /**
35      * Creates a new {@link CoffeeSystemThingHandler}.
36      *
37      * @param thing The thing to handle.
38      */
39     public CoffeeSystemThingHandler(Thing thing) {
40         super(thing);
41
42         updateState(channel(REMOTE_CONTROL_CAN_BE_STARTED), OnOffType.OFF);
43         updateState(channel(REMOTE_CONTROL_CAN_BE_STOPPED), OnOffType.OFF);
44     }
45
46     @Override
47     protected void updateDeviceState(DeviceChannelState device) {
48         updateState(channel(PROGRAM_ACTIVE), device.getProgramActive());
49         updateState(channel(PROGRAM_ACTIVE_RAW), device.getProgramActiveRaw());
50         updateState(channel(PROGRAM_PHASE), device.getProgramPhase());
51         updateState(channel(PROGRAM_PHASE_RAW), device.getProgramPhaseRaw());
52         updateState(channel(OPERATION_STATE), device.getOperationState());
53         updateState(channel(OPERATION_STATE_RAW), device.getOperationStateRaw());
54         updateState(channel(PROGRAM_ELAPSED_TIME), device.getProgramElapsedTime());
55         updateState(channel(POWER_ON_OFF), device.getPowerOnOff());
56         updateState(channel(ERROR_STATE), device.getErrorState());
57         updateState(channel(INFO_STATE), device.getInfoState());
58         updateState(channel(LIGHT_SWITCH), device.getLightSwitch());
59     }
60
61     @Override
62     protected void updateTransitionState(TransitionChannelState transition) {
63         updateState(channel(PROGRAM_REMAINING_TIME), transition.getProgramRemainingTime());
64         if (transition.hasFinishedChanged()) {
65             updateState(channel(FINISH_STATE), transition.getFinishState());
66         }
67     }
68
69     @Override
70     protected void updateActionState(ActionsChannelState actions) {
71         updateState(channel(REMOTE_CONTROL_CAN_BE_SWITCHED_ON), actions.getRemoteControlCanBeSwitchedOn());
72         updateState(channel(REMOTE_CONTROL_CAN_BE_SWITCHED_OFF), actions.getRemoteControlCanBeSwitchedOff());
73         updateState(channel(LIGHT_CAN_BE_CONTROLLED), actions.getLightCanBeControlled());
74     }
75 }