]> git.basschouten.com Git - openhab-addons.git/blob
c9eb7f218312c166eb475e41814b2225ddd8ece3
[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.wemo.internal.handler;
14
15 import static org.openhab.binding.wemo.internal.WemoBindingConstants.*;
16
17 import java.util.Set;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.openhab.core.config.core.Configuration;
21 import org.openhab.core.thing.Bridge;
22 import org.openhab.core.thing.ChannelUID;
23 import org.openhab.core.thing.ThingStatus;
24 import org.openhab.core.thing.ThingStatusDetail;
25 import org.openhab.core.thing.ThingTypeUID;
26 import org.openhab.core.thing.binding.BaseBridgeHandler;
27 import org.openhab.core.types.Command;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
30
31 /**
32  * {@link WemoBridgeHandler} is the handler for a wemo bridge and connects it to
33  * the framework.
34  *
35  * @author Hans-Jörg Merk - Initial contribution
36  */
37 @NonNullByDefault
38 public class WemoBridgeHandler extends BaseBridgeHandler {
39
40     public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_BRIDGE);
41
42     private final Logger logger = LoggerFactory.getLogger(WemoBridgeHandler.class);
43
44     public WemoBridgeHandler(Bridge bridge) {
45         super(bridge);
46         logger.debug("Creating a WemoBridgeHandler for thing '{}'", getThing().getUID());
47     }
48
49     @Override
50     public void initialize() {
51         logger.debug("Initializing WemoBridgeHandler");
52
53         Configuration configuration = getConfig();
54
55         if (configuration.get(UDN) != null) {
56             logger.trace("Initializing WemoBridgeHandler for UDN '{}'", configuration.get(UDN));
57             updateStatus(ThingStatus.ONLINE);
58         } else {
59             logger.debug("Cannot initalize WemoBridgeHandler. UDN not set.");
60             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
61                     "@text/config-status.error.missing-udn");
62         }
63     }
64
65     @Override
66     public void handleCommand(ChannelUID channelUID, Command command) {
67         // Not needed, all commands are handled in the {@link WemoLightHandler}
68     }
69 }