]> git.basschouten.com Git - openhab-addons.git/blob
9daa7ef1f5f6b0ba18bf80662e281734a07d34ea
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.somfytahoma.internal;
14
15 import static org.openhab.binding.somfytahoma.internal.SomfyTahomaBindingConstants.*;
16
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.SomfyTahomaContactSensorHandler;
25 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaCurtainHandler;
26 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaDimmerLightHandler;
27 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaDockHandler;
28 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaDoorLockHandler;
29 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaElectricitySensorHandler;
30 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaExteriorHeatingSystemHandler;
31 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaExternalAlarmHandler;
32 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaGateHandler;
33 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaGatewayHandler;
34 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaHumiditySensorHandler;
35 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaInternalAlarmHandler;
36 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaLightSensorHandler;
37 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaMyfoxAlarmHandler;
38 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaMyfoxCameraHandler;
39 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaOccupancySensorHandler;
40 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaOnOffHandler;
41 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaOnOffHeatingSystemHandler;
42 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaPergolaHandler;
43 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaPodHandler;
44 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaRollerShutterHandler;
45 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaSilentRollerShutterHandler;
46 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaSirenHandler;
47 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaSmokeSensorHandler;
48 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaTemperatureSensorHandler;
49 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaThermostatHandler;
50 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaUnoRollerShutterHandler;
51 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaValveHeatingSystemHandler;
52 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaVenetianBlindHandler;
53 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaWaterSensorHandler;
54 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaWindowHandleHandler;
55 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaWindowHandler;
56 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaZwaveHeatingSystemHandler;
57 import org.openhab.core.io.net.http.HttpClientFactory;
58 import org.openhab.core.thing.Bridge;
59 import org.openhab.core.thing.Thing;
60 import org.openhab.core.thing.ThingTypeUID;
61 import org.openhab.core.thing.binding.BaseThingHandlerFactory;
62 import org.openhab.core.thing.binding.ThingHandler;
63 import org.openhab.core.thing.binding.ThingHandlerFactory;
64 import org.osgi.service.component.annotations.Activate;
65 import org.osgi.service.component.annotations.Component;
66 import org.osgi.service.component.annotations.Reference;
67 import org.slf4j.Logger;
68 import org.slf4j.LoggerFactory;
69
70 /**
71  * The {@link SomfyTahomaHandlerFactory} is responsible for creating things and thing
72  * handlers.
73  *
74  * @author Ondrej Pecta - Initial contribution
75  */
76 @NonNullByDefault
77 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.somfytahoma")
78 public class SomfyTahomaHandlerFactory extends BaseThingHandlerFactory {
79
80     private final Logger logger = LoggerFactory.getLogger(SomfyTahomaHandlerFactory.class);
81
82     private final HttpClientFactory httpClientFactory;
83     private final SomfyTahomaStateDescriptionOptionProvider stateDescriptionProvider;
84
85     @Activate
86     public SomfyTahomaHandlerFactory(@Reference HttpClientFactory httpClientFactory,
87             final @Reference SomfyTahomaStateDescriptionOptionProvider stateDescriptionProvider) {
88         this.httpClientFactory = httpClientFactory;
89         this.stateDescriptionProvider = stateDescriptionProvider;
90     }
91
92     @Override
93     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
94         return THING_TYPE_BRIDGE.equals(thingTypeUID) || SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
95     }
96
97     @Override
98     @Nullable
99     protected ThingHandler createHandler(Thing thing) {
100         ThingTypeUID thingTypeUID = thing.getThingTypeUID();
101
102         logger.debug("Creating handler for {}", thing.getThingTypeUID().getId());
103
104         if (thingTypeUID.equals(THING_TYPE_BRIDGE)) {
105             return new SomfyTahomaBridgeHandler((Bridge) thing, httpClientFactory);
106         } else if (thingTypeUID.equals(THING_TYPE_GATEWAY)) {
107             return new SomfyTahomaGatewayHandler(thing, stateDescriptionProvider);
108         } else if (thingTypeUID.equals(THING_TYPE_ROLLERSHUTTER)) {
109             return new SomfyTahomaRollerShutterHandler(thing);
110         } else if (thingTypeUID.equals(THING_TYPE_ROLLERSHUTTER_SILENT)) {
111             return new SomfyTahomaSilentRollerShutterHandler(thing);
112         } else if (thingTypeUID.equals(THING_TYPE_ROLLERSHUTTER_UNO)) {
113             return new SomfyTahomaUnoRollerShutterHandler(thing);
114         } else if (thingTypeUID.equals(THING_TYPE_SCREEN) || thingTypeUID.equals(THING_TYPE_EXTERIORSCREEN)) {
115             return new SomfyTahomaRollerShutterHandler(thing);
116         } else if (thingTypeUID.equals(THING_TYPE_VENETIANBLIND)
117                 || thingTypeUID.equals(THING_TYPE_EXTERIORVENETIANBLIND)) {
118             return new SomfyTahomaVenetianBlindHandler(thing);
119         } else if (thingTypeUID.equals(THING_TYPE_GARAGEDOOR)) {
120             return new SomfyTahomaRollerShutterHandler(thing);
121         } else if (thingTypeUID.equals(THING_TYPE_AWNING)) {
122             return new SomfyTahomaAwningHandler(thing);
123         } else if (thingTypeUID.equals(THING_TYPE_ACTIONGROUP)) {
124             return new SomfyTahomaActionGroupHandler(thing);
125         } else if (thingTypeUID.equals(THING_TYPE_ONOFF)) {
126             return new SomfyTahomaOnOffHandler(thing);
127         } else if (thingTypeUID.equals(THING_TYPE_LIGHT)) {
128             return new SomfyTahomaOnOffHandler(thing);
129         } else if (thingTypeUID.equals(THING_TYPE_DIMMER_LIGHT)) {
130             return new SomfyTahomaDimmerLightHandler(thing);
131         } else if (thingTypeUID.equals(THING_TYPE_LIGHTSENSOR)) {
132             return new SomfyTahomaLightSensorHandler(thing);
133         } else if (thingTypeUID.equals(THING_TYPE_SMOKESENSOR)) {
134             return new SomfyTahomaSmokeSensorHandler(thing);
135         } else if (thingTypeUID.equals(THING_TYPE_OCCUPANCYSENSOR)) {
136             return new SomfyTahomaOccupancySensorHandler(thing);
137         } else if (thingTypeUID.equals(THING_TYPE_CONTACTSENSOR)) {
138             return new SomfyTahomaContactSensorHandler(thing);
139         } else if (thingTypeUID.equals(THING_TYPE_WATERSENSOR)) {
140             return new SomfyTahomaWaterSensorHandler(thing);
141         } else if (thingTypeUID.equals(THING_TYPE_HUMIDITYSENSOR)) {
142             return new SomfyTahomaHumiditySensorHandler(thing);
143         } else if (thingTypeUID.equals(THING_TYPE_WINDOW)) {
144             return new SomfyTahomaWindowHandler(thing);
145         } else if (thingTypeUID.equals(THING_TYPE_INTERNAL_ALARM)) {
146             return new SomfyTahomaInternalAlarmHandler(thing);
147         } else if (thingTypeUID.equals(THING_TYPE_EXTERNAL_ALARM)) {
148             return new SomfyTahomaExternalAlarmHandler(thing);
149         } else if (thingTypeUID.equals(THING_TYPE_POD)) {
150             return new SomfyTahomaPodHandler(thing);
151         } else if (thingTypeUID.equals(THING_TYPE_VALVE_HEATING_SYSTEM)) {
152             return new SomfyTahomaValveHeatingSystemHandler(thing);
153         } else if (thingTypeUID.equals(THING_TYPE_ZWAVE_HEATING_SYSTEM)) {
154             return new SomfyTahomaZwaveHeatingSystemHandler(thing);
155         } else if (thingTypeUID.equals(THING_TYPE_ONOFF_HEATING_SYSTEM)) {
156             return new SomfyTahomaOnOffHeatingSystemHandler(thing);
157         } else if (thingTypeUID.equals(THING_TYPE_EXTERIOR_HEATING_SYSTEM)) {
158             return new SomfyTahomaExteriorHeatingSystemHandler(thing);
159         } else if (thingTypeUID.equals(THING_TYPE_DOOR_LOCK)) {
160             return new SomfyTahomaDoorLockHandler(thing);
161         } else if (thingTypeUID.equals(THING_TYPE_PERGOLA)) {
162             return new SomfyTahomaPergolaHandler(thing);
163         } else if (thingTypeUID.equals(THING_TYPE_BIOCLIMATIC_PERGOLA)) {
164             return new SomfyTahomaBioclimaticPergolaHandler(thing);
165         } else if (thingTypeUID.equals(THING_TYPE_WINDOW_HANDLE)) {
166             return new SomfyTahomaWindowHandleHandler(thing);
167         } else if (thingTypeUID.equals(THING_TYPE_TEMPERATURESENSOR)) {
168             return new SomfyTahomaTemperatureSensorHandler(thing);
169         } else if (thingTypeUID.equals(THING_TYPE_GATE)) {
170             return new SomfyTahomaGateHandler(thing);
171         } else if (thingTypeUID.equals(THING_TYPE_CURTAIN)) {
172             return new SomfyTahomaCurtainHandler(thing);
173         } else if (thingTypeUID.equals(THING_TYPE_ELECTRICITYSENSOR)) {
174             return new SomfyTahomaElectricitySensorHandler(thing);
175         } else if (thingTypeUID.equals(THING_TYPE_DOCK)) {
176             return new SomfyTahomaDockHandler(thing);
177         } else if (thingTypeUID.equals(THING_TYPE_SIREN)) {
178             return new SomfyTahomaSirenHandler(thing);
179         } else if (thingTypeUID.equals(THING_TYPE_ADJUSTABLE_SLATS_ROLLERSHUTTER)) {
180             return new SomfyTahomaAdjustableSlatsRollerShutterHandler(thing);
181         } else if (thingTypeUID.equals(THING_TYPE_MYFOX_CAMERA)) {
182             return new SomfyTahomaMyfoxCameraHandler(thing);
183         } else if (thingTypeUID.equals(THING_TYPE_MYFOX_ALARM)) {
184             return new SomfyTahomaMyfoxAlarmHandler(thing);
185         } else if (thingTypeUID.equals(THING_TYPE_THERMOSTAT)) {
186             return new SomfyTahomaThermostatHandler(thing);
187         } else {
188             return null;
189         }
190     }
191 }