2 * Copyright (c) 2010-2023 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.cm11a.internal;
15 import static org.openhab.binding.cm11a.internal.CM11ABindingConstants.*;
19 import org.openhab.binding.cm11a.internal.handler.Cm11aApplianceHandler;
20 import org.openhab.binding.cm11a.internal.handler.Cm11aBridgeHandler;
21 import org.openhab.binding.cm11a.internal.handler.Cm11aLampHandler;
22 import org.openhab.core.thing.Bridge;
23 import org.openhab.core.thing.Thing;
24 import org.openhab.core.thing.ThingTypeUID;
25 import org.openhab.core.thing.binding.BaseThingHandlerFactory;
26 import org.openhab.core.thing.binding.ThingHandler;
27 import org.openhab.core.thing.binding.ThingHandlerFactory;
28 import org.osgi.service.component.annotations.Component;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
33 * The {@link Cm11aHandlerFactory} is responsible for creating things and thing
36 * @author Bob Raker - Initial contribution
38 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.cm11a")
39 public class Cm11aHandlerFactory extends BaseThingHandlerFactory {
41 private final Logger logger = LoggerFactory.getLogger(Cm11aHandlerFactory.class);
43 private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_SWITCH, THING_TYPE_DIMMER);
46 public boolean supportsThingType(ThingTypeUID thingTypeUID) {
47 return THING_TYPE_CM11A.equals(thingTypeUID) || SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
51 protected ThingHandler createHandler(Thing thing) {
52 ThingTypeUID thingTypeUID = thing.getThingTypeUID();
53 logger.trace("**** Cm11AHandlerFactory.createHandler for {}", thingTypeUID.getAsString());
55 if (thingTypeUID.equals(THING_TYPE_CM11A)) {
56 return new Cm11aBridgeHandler((Bridge) thing);
57 } else if (thingTypeUID.equals(THING_TYPE_SWITCH)) {
58 return new Cm11aApplianceHandler(thing);
59 } else if (thingTypeUID.equals(THING_TYPE_DIMMER)) {
60 return new Cm11aLampHandler(thing);