2 * Copyright (c) 2010-2024 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.SomfyTahomaActionGroupHandler;
20 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaAdjustableSlatsRollerShutterHandler;
21 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaAwningHandler;
22 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaBioclimaticPergolaHandler;
23 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaBridgeHandler;
24 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaCarbonDioxideSensorHandler;
25 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaContactSensorHandler;
26 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaCurtainHandler;
27 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaDimmerLightHandler;
28 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaDockHandler;
29 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaDoorLockHandler;
30 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaElectricitySensorHandler;
31 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaExteriorHeatingSystemHandler;
32 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaExternalAlarmHandler;
33 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaGateHandler;
34 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaGatewayHandler;
35 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaHitachiATWHZHandler;
36 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaHitachiATWMCHandler;
37 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaHitachiDHWHandler;
38 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaHumiditySensorHandler;
39 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaInternalAlarmHandler;
40 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaLightSensorHandler;
41 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaMyfoxAlarmHandler;
42 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaMyfoxCameraHandler;
43 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaNoiseSensorHandler;
44 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaOccupancySensorHandler;
45 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaOnOffHandler;
46 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaOnOffHeatingSystemHandler;
47 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaPergolaHandler;
48 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaPodHandler;
49 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaRainSensorHandler;
50 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaRollerShutterHandler;
51 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaShutterHandler;
52 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaSilentRollerShutterHandler;
53 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaSirenHandler;
54 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaSmokeSensorHandler;
55 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaTemperatureSensorHandler;
56 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaThermostatHandler;
57 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaUnoRollerShutterHandler;
58 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaValveHeatingSystemHandler;
59 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaVenetianBlindHandler;
60 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaWaterHeatingSystemHandler;
61 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaWaterSensorHandler;
62 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaWindowHandleHandler;
63 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaWindowHandler;
64 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaZwaveHeatingSystemHandler;
65 import org.openhab.core.io.net.http.HttpClientFactory;
66 import org.openhab.core.thing.Bridge;
67 import org.openhab.core.thing.Thing;
68 import org.openhab.core.thing.ThingTypeUID;
69 import org.openhab.core.thing.binding.BaseThingHandlerFactory;
70 import org.openhab.core.thing.binding.ThingHandler;
71 import org.openhab.core.thing.binding.ThingHandlerFactory;
72 import org.osgi.service.component.annotations.Activate;
73 import org.osgi.service.component.annotations.Component;
74 import org.osgi.service.component.annotations.Reference;
75 import org.slf4j.Logger;
76 import org.slf4j.LoggerFactory;
79 * The {@link SomfyTahomaHandlerFactory} is responsible for creating things and thing
82 * @author Ondrej Pecta - Initial contribution
85 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.somfytahoma")
86 public class SomfyTahomaHandlerFactory extends BaseThingHandlerFactory {
88 private final Logger logger = LoggerFactory.getLogger(SomfyTahomaHandlerFactory.class);
90 private final HttpClientFactory httpClientFactory;
91 private final SomfyTahomaStateDescriptionOptionProvider stateDescriptionProvider;
94 public SomfyTahomaHandlerFactory(@Reference HttpClientFactory httpClientFactory,
95 final @Reference SomfyTahomaStateDescriptionOptionProvider stateDescriptionProvider) {
96 this.httpClientFactory = httpClientFactory;
97 this.stateDescriptionProvider = stateDescriptionProvider;
101 public boolean supportsThingType(ThingTypeUID thingTypeUID) {
102 return THING_TYPE_BRIDGE.equals(thingTypeUID) || SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
107 protected ThingHandler createHandler(Thing thing) {
108 ThingTypeUID thingTypeUID = thing.getThingTypeUID();
110 logger.debug("Creating handler for {}", thing.getThingTypeUID().getId());
112 if (thingTypeUID.equals(THING_TYPE_BRIDGE)) {
113 return new SomfyTahomaBridgeHandler((Bridge) thing, httpClientFactory);
114 } else if (thingTypeUID.equals(THING_TYPE_GATEWAY)) {
115 return new SomfyTahomaGatewayHandler(thing, stateDescriptionProvider);
116 } else if (thingTypeUID.equals(THING_TYPE_ROLLERSHUTTER)) {
117 return new SomfyTahomaRollerShutterHandler(thing);
118 } else if (thingTypeUID.equals(THING_TYPE_ROLLERSHUTTER_SILENT)) {
119 return new SomfyTahomaSilentRollerShutterHandler(thing);
120 } else if (thingTypeUID.equals(THING_TYPE_ROLLERSHUTTER_UNO)) {
121 return new SomfyTahomaUnoRollerShutterHandler(thing);
122 } else if (thingTypeUID.equals(THING_TYPE_SCREEN) || thingTypeUID.equals(THING_TYPE_EXTERIORSCREEN)) {
123 return new SomfyTahomaRollerShutterHandler(thing);
124 } else if (thingTypeUID.equals(THING_TYPE_SHUTTER)) {
125 return new SomfyTahomaShutterHandler(thing);
126 } else if (thingTypeUID.equals(THING_TYPE_VENETIANBLIND)
127 || thingTypeUID.equals(THING_TYPE_EXTERIORVENETIANBLIND)) {
128 return new SomfyTahomaVenetianBlindHandler(thing);
129 } else if (thingTypeUID.equals(THING_TYPE_GARAGEDOOR)) {
130 return new SomfyTahomaRollerShutterHandler(thing);
131 } else if (thingTypeUID.equals(THING_TYPE_AWNING)) {
132 return new SomfyTahomaAwningHandler(thing);
133 } else if (thingTypeUID.equals(THING_TYPE_ACTIONGROUP)) {
134 return new SomfyTahomaActionGroupHandler(thing);
135 } else if (thingTypeUID.equals(THING_TYPE_ONOFF)) {
136 return new SomfyTahomaOnOffHandler(thing);
137 } else if (thingTypeUID.equals(THING_TYPE_LIGHT)) {
138 return new SomfyTahomaOnOffHandler(thing);
139 } else if (thingTypeUID.equals(THING_TYPE_DIMMER_LIGHT)) {
140 return new SomfyTahomaDimmerLightHandler(thing);
141 } else if (thingTypeUID.equals(THING_TYPE_LIGHTSENSOR)) {
142 return new SomfyTahomaLightSensorHandler(thing);
143 } else if (thingTypeUID.equals(THING_TYPE_SMOKESENSOR)) {
144 return new SomfyTahomaSmokeSensorHandler(thing);
145 } else if (thingTypeUID.equals(THING_TYPE_OCCUPANCYSENSOR)) {
146 return new SomfyTahomaOccupancySensorHandler(thing);
147 } else if (thingTypeUID.equals(THING_TYPE_CONTACTSENSOR)) {
148 return new SomfyTahomaContactSensorHandler(thing);
149 } else if (thingTypeUID.equals(THING_TYPE_WATERSENSOR)) {
150 return new SomfyTahomaWaterSensorHandler(thing);
151 } else if (thingTypeUID.equals(THING_TYPE_HUMIDITYSENSOR)) {
152 return new SomfyTahomaHumiditySensorHandler(thing);
153 } else if (thingTypeUID.equals(THING_TYPE_WINDOW)) {
154 return new SomfyTahomaWindowHandler(thing);
155 } else if (thingTypeUID.equals(THING_TYPE_INTERNAL_ALARM)) {
156 return new SomfyTahomaInternalAlarmHandler(thing);
157 } else if (thingTypeUID.equals(THING_TYPE_EXTERNAL_ALARM)) {
158 return new SomfyTahomaExternalAlarmHandler(thing);
159 } else if (thingTypeUID.equals(THING_TYPE_POD)) {
160 return new SomfyTahomaPodHandler(thing);
161 } else if (thingTypeUID.equals(THING_TYPE_VALVE_HEATING_SYSTEM)) {
162 return new SomfyTahomaValveHeatingSystemHandler(thing);
163 } else if (thingTypeUID.equals(THING_TYPE_ZWAVE_HEATING_SYSTEM)) {
164 return new SomfyTahomaZwaveHeatingSystemHandler(thing);
165 } else if (thingTypeUID.equals(THING_TYPE_ONOFF_HEATING_SYSTEM)) {
166 return new SomfyTahomaOnOffHeatingSystemHandler(thing);
167 } else if (thingTypeUID.equals(THING_TYPE_EXTERIOR_HEATING_SYSTEM)) {
168 return new SomfyTahomaExteriorHeatingSystemHandler(thing);
169 } else if (thingTypeUID.equals(THING_TYPE_DOOR_LOCK)) {
170 return new SomfyTahomaDoorLockHandler(thing);
171 } else if (thingTypeUID.equals(THING_TYPE_PERGOLA)) {
172 return new SomfyTahomaPergolaHandler(thing);
173 } else if (thingTypeUID.equals(THING_TYPE_BIOCLIMATIC_PERGOLA)) {
174 return new SomfyTahomaBioclimaticPergolaHandler(thing);
175 } else if (thingTypeUID.equals(THING_TYPE_WINDOW_HANDLE)) {
176 return new SomfyTahomaWindowHandleHandler(thing);
177 } else if (thingTypeUID.equals(THING_TYPE_TEMPERATURESENSOR)) {
178 return new SomfyTahomaTemperatureSensorHandler(thing);
179 } else if (thingTypeUID.equals(THING_TYPE_GATE)) {
180 return new SomfyTahomaGateHandler(thing);
181 } else if (thingTypeUID.equals(THING_TYPE_CURTAIN)) {
182 return new SomfyTahomaCurtainHandler(thing);
183 } else if (thingTypeUID.equals(THING_TYPE_ELECTRICITYSENSOR)) {
184 return new SomfyTahomaElectricitySensorHandler(thing);
185 } else if (thingTypeUID.equals(THING_TYPE_DOCK)) {
186 return new SomfyTahomaDockHandler(thing);
187 } else if (thingTypeUID.equals(THING_TYPE_SIREN)) {
188 return new SomfyTahomaSirenHandler(thing);
189 } else if (thingTypeUID.equals(THING_TYPE_ADJUSTABLE_SLATS_ROLLERSHUTTER)) {
190 return new SomfyTahomaAdjustableSlatsRollerShutterHandler(thing);
191 } else if (thingTypeUID.equals(THING_TYPE_MYFOX_CAMERA)) {
192 return new SomfyTahomaMyfoxCameraHandler(thing);
193 } else if (thingTypeUID.equals(THING_TYPE_MYFOX_ALARM)) {
194 return new SomfyTahomaMyfoxAlarmHandler(thing);
195 } else if (thingTypeUID.equals(THING_TYPE_THERMOSTAT)) {
196 return new SomfyTahomaThermostatHandler(thing);
197 } else if (thingTypeUID.equals(THING_TYPE_WATERHEATINGSYSTEM)) {
198 return new SomfyTahomaWaterHeatingSystemHandler(thing);
199 } else if (thingTypeUID.equals(THING_TYPE_HITACHI_ATWHZ)) {
200 return new SomfyTahomaHitachiATWHZHandler(thing);
201 } else if (thingTypeUID.equals(THING_TYPE_HITACHI_DHW)) {
202 return new SomfyTahomaHitachiDHWHandler(thing);
203 } else if (thingTypeUID.equals(THING_TYPE_HITACHI_ATWMC)) {
204 return new SomfyTahomaHitachiATWMCHandler(thing);
205 } else if (thingTypeUID.equals(THING_TYPE_RAINSENSOR)) {
206 return new SomfyTahomaRainSensorHandler(thing);
207 } else if (thingTypeUID.equals(THING_TYPE_CARBON_DIOXIDE_SENSOR)) {
208 return new SomfyTahomaCarbonDioxideSensorHandler(thing);
209 } else if (thingTypeUID.equals(THING_TYPE_NOISE_SENSOR)) {
210 return new SomfyTahomaNoiseSensorHandler(thing);