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