]> git.basschouten.com Git - openhab-addons.git/blob
b2bba68a8fe377b36c446cce4de8d8e0ceebb7df
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.Collections;
18 import java.util.Set;
19
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 public class WemoBridgeHandler extends BaseBridgeHandler {
38
39     public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_BRIDGE);
40
41     private final Logger logger = LoggerFactory.getLogger(WemoBridgeHandler.class);
42
43     public WemoBridgeHandler(Bridge bridge) {
44         super(bridge);
45         logger.debug("Creating a WemoBridgeHandler for thing '{}'", getThing().getUID());
46     }
47
48     @Override
49     public void initialize() {
50         logger.debug("Initializing WemoBridgeHandler");
51
52         Configuration configuration = getConfig();
53
54         if (configuration.get(UDN) != null) {
55             logger.trace("Initializing WemoBridgeHandler for UDN '{}'", configuration.get(UDN));
56             updateStatus(ThingStatus.ONLINE);
57         } else {
58             logger.debug("Cannot initalize WemoBridgeHandler. UDN not set.");
59             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR);
60         }
61     }
62
63     @Override
64     public void handleCommand(ChannelUID channelUID, Command command) {
65         // Not needed, all commands are handled in the {@link WemoLightHandler}
66     }
67 }