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.tradfri.internal;
15 import static org.openhab.binding.tradfri.internal.TradfriBindingConstants.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.tradfri.internal.handler.TradfriAirPurifierHandler;
20 import org.openhab.binding.tradfri.internal.handler.TradfriBlindHandler;
21 import org.openhab.binding.tradfri.internal.handler.TradfriControllerHandler;
22 import org.openhab.binding.tradfri.internal.handler.TradfriGatewayHandler;
23 import org.openhab.binding.tradfri.internal.handler.TradfriLightHandler;
24 import org.openhab.binding.tradfri.internal.handler.TradfriPlugHandler;
25 import org.openhab.binding.tradfri.internal.handler.TradfriSensorHandler;
26 import org.openhab.core.thing.Bridge;
27 import org.openhab.core.thing.Thing;
28 import org.openhab.core.thing.ThingTypeUID;
29 import org.openhab.core.thing.binding.BaseThingHandlerFactory;
30 import org.openhab.core.thing.binding.ThingHandler;
31 import org.openhab.core.thing.binding.ThingHandlerFactory;
32 import org.osgi.service.component.annotations.Component;
35 * The {@link TradfriHandlerFactory} is responsible for creating things and thing handlers.
37 * @author Kai Kreuzer - Initial contribution
38 * @author Christoph Weitkamp - Added support for remote controller and motion sensor devices (read-only battery level)
39 * @author Manuel Raffel - Added support for blinds
41 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.tradfri")
43 public class TradfriHandlerFactory extends BaseThingHandlerFactory {
46 public boolean supportsThingType(ThingTypeUID thingTypeUID) {
47 return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
51 protected @Nullable ThingHandler createHandler(Thing thing) {
52 ThingTypeUID thingTypeUID = thing.getThingTypeUID();
54 if (GATEWAY_TYPE_UID.equals(thingTypeUID)) {
55 return new TradfriGatewayHandler((Bridge) thing);
56 } else if (THING_TYPE_DIMMER.equals(thingTypeUID) || THING_TYPE_REMOTE_CONTROL.equals(thingTypeUID)
57 || THING_TYPE_OPEN_CLOSE_REMOTE_CONTROL.equals(thingTypeUID)) {
58 return new TradfriControllerHandler(thing);
59 } else if (THING_TYPE_MOTION_SENSOR.equals(thingTypeUID)) {
60 return new TradfriSensorHandler(thing);
61 } else if (THING_TYPE_BLINDS.equals(thingTypeUID)) {
62 return new TradfriBlindHandler(thing);
63 } else if (SUPPORTED_LIGHT_TYPES_UIDS.contains(thingTypeUID)) {
64 return new TradfriLightHandler(thing);
65 } else if (SUPPORTED_PLUG_TYPES_UIDS.contains(thingTypeUID)) {
66 return new TradfriPlugHandler(thing);
67 } else if (THING_TYPE_AIR_PURIFIER.equals(thingTypeUID)) {
68 return new TradfriAirPurifierHandler(thing);