2 * Copyright (c) 2010-2021 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.homeconnect.internal.handler;
15 import static org.openhab.binding.homeconnect.internal.HomeConnectBindingConstants.*;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.openhab.binding.homeconnect.internal.type.HomeConnectDynamicStateDescriptionProvider;
21 import org.openhab.core.thing.Thing;
22 import org.openhab.core.types.UnDefType;
25 * The {@link HomeConnectCooktopHandler} is responsible for handling commands, which are
26 * sent to one of the channels of a hood.
28 * @author Jonas BrĂ¼stel - Initial contribution
31 public class HomeConnectCooktopHandler extends AbstractHomeConnectThingHandler {
33 public HomeConnectCooktopHandler(Thing thing,
34 HomeConnectDynamicStateDescriptionProvider dynamicStateDescriptionProvider) {
35 super(thing, dynamicStateDescriptionProvider);
39 protected void configureChannelUpdateHandlers(Map<String, ChannelUpdateHandler> handlers) {
40 // register default update handlers
41 handlers.put(CHANNEL_OPERATION_STATE, defaultOperationStateChannelUpdateHandler());
42 handlers.put(CHANNEL_POWER_STATE, defaultPowerStateChannelUpdateHandler());
43 handlers.put(CHANNEL_REMOTE_CONTROL_ACTIVE_STATE, defaultRemoteControlActiveStateChannelUpdateHandler());
44 handlers.put(CHANNEL_LOCAL_CONTROL_ACTIVE_STATE, defaultLocalControlActiveStateChannelUpdateHandler());
45 handlers.put(CHANNEL_SELECTED_PROGRAM_STATE, defaultSelectedProgramStateUpdateHandler());
46 handlers.put(CHANNEL_ACTIVE_PROGRAM_STATE, defaultActiveProgramStateUpdateHandler());
50 protected void configureEventHandlers(Map<String, EventHandler> handlers) {
51 // register default SSE event handlers
52 handlers.put(EVENT_REMOTE_CONTROL_START_ALLOWED,
53 defaultBooleanEventHandler(CHANNEL_REMOTE_START_ALLOWANCE_STATE));
54 handlers.put(EVENT_REMOTE_CONTROL_ACTIVE, defaultBooleanEventHandler(CHANNEL_REMOTE_CONTROL_ACTIVE_STATE));
55 handlers.put(EVENT_LOCAL_CONTROL_ACTIVE, defaultBooleanEventHandler(CHANNEL_LOCAL_CONTROL_ACTIVE_STATE));
56 handlers.put(EVENT_OPERATION_STATE, defaultOperationStateEventHandler());
57 handlers.put(EVENT_SELECTED_PROGRAM, defaultSelectedProgramStateEventHandler());
58 handlers.put(EVENT_POWER_STATE, defaultPowerStateEventHandler());
60 // specific SSE event handlers
61 handlers.put(EVENT_ACTIVE_PROGRAM, (event) -> {
62 defaultActiveProgramEventHandler().handle(event);
63 if (event.getValue() != null) {
64 getThingChannel(CHANNEL_ACTIVE_PROGRAM_STATE).ifPresent((c) -> updateChannel(c.getUID()));
70 public String toString() {
71 return "HomeConnectCooktopHandler [haId: " + getThingHaId() + "]";
75 protected void resetProgramStateChannels() {
76 super.resetProgramStateChannels();
77 getThingChannel(CHANNEL_ACTIVE_PROGRAM_STATE).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));