2 * Copyright (c) 2010-2021 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.somfytahoma.internal;
15 import static org.openhab.binding.somfytahoma.internal.SomfyTahomaBindingConstants.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.somfytahoma.internal.handler.*;
20 import org.openhab.core.io.net.http.HttpClientFactory;
21 import org.openhab.core.thing.Bridge;
22 import org.openhab.core.thing.Thing;
23 import org.openhab.core.thing.ThingTypeUID;
24 import org.openhab.core.thing.binding.BaseThingHandlerFactory;
25 import org.openhab.core.thing.binding.ThingHandler;
26 import org.openhab.core.thing.binding.ThingHandlerFactory;
27 import org.osgi.service.component.annotations.Activate;
28 import org.osgi.service.component.annotations.Component;
29 import org.osgi.service.component.annotations.Reference;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
34 * The {@link SomfyTahomaHandlerFactory} is responsible for creating things and thing
37 * @author Ondrej Pecta - Initial contribution
40 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.somfytahoma")
41 public class SomfyTahomaHandlerFactory extends BaseThingHandlerFactory {
43 private final Logger logger = LoggerFactory.getLogger(SomfyTahomaHandlerFactory.class);
45 private final HttpClientFactory httpClientFactory;
48 public SomfyTahomaHandlerFactory(@Reference HttpClientFactory httpClientFactory) {
49 this.httpClientFactory = httpClientFactory;
53 public boolean supportsThingType(ThingTypeUID thingTypeUID) {
54 return THING_TYPE_BRIDGE.equals(thingTypeUID) || SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
59 protected ThingHandler createHandler(Thing thing) {
60 ThingTypeUID thingTypeUID = thing.getThingTypeUID();
62 logger.debug("Creating handler for {}", thing.getThingTypeUID().getId());
64 if (thingTypeUID.equals(THING_TYPE_BRIDGE)) {
65 return new SomfyTahomaBridgeHandler((Bridge) thing, httpClientFactory);
66 } else if (thingTypeUID.equals(THING_TYPE_GATEWAY)) {
67 return new SomfyTahomaGatewayHandler(thing);
68 } else if (thingTypeUID.equals(THING_TYPE_ROLLERSHUTTER)) {
69 return new SomfyTahomaRollerShutterHandler(thing);
70 } else if (thingTypeUID.equals(THING_TYPE_ROLLERSHUTTER_SILENT)) {
71 return new SomfyTahomaSilentRollerShutterHandler(thing);
72 } else if (thingTypeUID.equals(THING_TYPE_ROLLERSHUTTER_UNO)) {
73 return new SomfyTahomaUnoRollerShutterHandler(thing);
74 } else if (thingTypeUID.equals(THING_TYPE_SCREEN) || thingTypeUID.equals(THING_TYPE_EXTERIORSCREEN)) {
75 return new SomfyTahomaRollerShutterHandler(thing);
76 } else if (thingTypeUID.equals(THING_TYPE_VENETIANBLIND)
77 || thingTypeUID.equals(THING_TYPE_EXTERIORVENETIANBLIND)) {
78 return new SomfyTahomaVenetianBlindHandler(thing);
79 } else if (thingTypeUID.equals(THING_TYPE_GARAGEDOOR)) {
80 return new SomfyTahomaRollerShutterHandler(thing);
81 } else if (thingTypeUID.equals(THING_TYPE_AWNING)) {
82 return new SomfyTahomaAwningHandler(thing);
83 } else if (thingTypeUID.equals(THING_TYPE_ACTIONGROUP)) {
84 return new SomfyTahomaActionGroupHandler(thing);
85 } else if (thingTypeUID.equals(THING_TYPE_ONOFF)) {
86 return new SomfyTahomaOnOffHandler(thing);
87 } else if (thingTypeUID.equals(THING_TYPE_LIGHT)) {
88 return new SomfyTahomaOnOffHandler(thing);
89 } else if (thingTypeUID.equals(THING_TYPE_DIMMER_LIGHT)) {
90 return new SomfyTahomaDimmerLightHandler(thing);
91 } else if (thingTypeUID.equals(THING_TYPE_LIGHTSENSOR)) {
92 return new SomfyTahomaLightSensorHandler(thing);
93 } else if (thingTypeUID.equals(THING_TYPE_SMOKESENSOR)) {
94 return new SomfyTahomaSmokeSensorHandler(thing);
95 } else if (thingTypeUID.equals(THING_TYPE_OCCUPANCYSENSOR)) {
96 return new SomfyTahomaOccupancySensorHandler(thing);
97 } else if (thingTypeUID.equals(THING_TYPE_CONTACTSENSOR)) {
98 return new SomfyTahomaContactSensorHandler(thing);
99 } else if (thingTypeUID.equals(THING_TYPE_WATERSENSOR)) {
100 return new SomfyTahomaWaterSensorHandler(thing);
101 } else if (thingTypeUID.equals(THING_TYPE_HUMIDITYSENSOR)) {
102 return new SomfyTahomaHumiditySensorHandler(thing);
103 } else if (thingTypeUID.equals(THING_TYPE_WINDOW)) {
104 return new SomfyTahomaWindowHandler(thing);
105 } else if (thingTypeUID.equals(THING_TYPE_INTERNAL_ALARM)) {
106 return new SomfyTahomaInternalAlarmHandler(thing);
107 } else if (thingTypeUID.equals(THING_TYPE_EXTERNAL_ALARM)) {
108 return new SomfyTahomaExternalAlarmHandler(thing);
109 } else if (thingTypeUID.equals(THING_TYPE_POD)) {
110 return new SomfyTahomaPodHandler(thing);
111 } else if (thingTypeUID.equals(THING_TYPE_VALVE_HEATING_SYSTEM)) {
112 return new SomfyTahomaValveHeatingSystemHandler(thing);
113 } else if (thingTypeUID.equals(THING_TYPE_ZWAVE_HEATING_SYSTEM)) {
114 return new SomfyTahomaZwaveHeatingSystemHandler(thing);
115 } else if (thingTypeUID.equals(THING_TYPE_ONOFF_HEATING_SYSTEM)) {
116 return new SomfyTahomaOnOffHeatingSystemHandler(thing);
117 } else if (thingTypeUID.equals(THING_TYPE_EXTERIOR_HEATING_SYSTEM)) {
118 return new SomfyTahomaExteriorHeatingSystemHandler(thing);
119 } else if (thingTypeUID.equals(THING_TYPE_DOOR_LOCK)) {
120 return new SomfyTahomaDoorLockHandler(thing);
121 } else if (thingTypeUID.equals(THING_TYPE_PERGOLA)) {
122 return new SomfyTahomaPergolaHandler(thing);
123 } else if (thingTypeUID.equals(THING_TYPE_WINDOW_HANDLE)) {
124 return new SomfyTahomaWindowHandleHandler(thing);
125 } else if (thingTypeUID.equals(THING_TYPE_TEMPERATURESENSOR)) {
126 return new SomfyTahomaTemperatureSensorHandler(thing);
127 } else if (thingTypeUID.equals(THING_TYPE_GATE)) {
128 return new SomfyTahomaGateHandler(thing);
129 } else if (thingTypeUID.equals(THING_TYPE_CURTAIN)) {
130 return new SomfyTahomaCurtainHandler(thing);
131 } else if (thingTypeUID.equals(THING_TYPE_ELECTRICITYSENSOR)) {
132 return new SomfyTahomaElectricitySensorHandler(thing);
133 } else if (thingTypeUID.equals(THING_TYPE_DOCK)) {
134 return new SomfyTahomaDockHandler(thing);
135 } else if (thingTypeUID.equals(THING_TYPE_SIREN)) {
136 return new SomfyTahomaSirenHandler(thing);
137 } else if (thingTypeUID.equals(THING_TYPE_ADJUSTABLE_SLATS_ROLLERSHUTTER)) {
138 return new SomfyTahomaAdjustableSlatsRollerShutterHandler(thing);
139 } else if (thingTypeUID.equals(THING_TYPE_MYFOX_CAMERA)) {
140 return new SomfyTahomaMyfoxCameraHandler(thing);
141 } else if (thingTypeUID.equals(THING_TYPE_MYFOX_ALARM)) {
142 return new SomfyTahomaMyfoxAlarmHandler(thing);
143 } else if (thingTypeUID.equals(THING_TYPE_THERMOSTAT)) {
144 return new SomfyTahomaThermostatHandler(thing);