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