]> git.basschouten.com Git - openhab-addons.git/blob
4cf0aa53416a197dcbb6973761904167ff08fc53
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.*;
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;
32
33 /**
34  * The {@link SomfyTahomaHandlerFactory} is responsible for creating things and thing
35  * handlers.
36  *
37  * @author Ondrej Pecta - Initial contribution
38  */
39 @NonNullByDefault
40 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.somfytahoma")
41 public class SomfyTahomaHandlerFactory extends BaseThingHandlerFactory {
42
43     private final Logger logger = LoggerFactory.getLogger(SomfyTahomaHandlerFactory.class);
44
45     private final HttpClientFactory httpClientFactory;
46
47     @Activate
48     public SomfyTahomaHandlerFactory(@Reference HttpClientFactory httpClientFactory) {
49         this.httpClientFactory = httpClientFactory;
50     }
51
52     @Override
53     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
54         return THING_TYPE_BRIDGE.equals(thingTypeUID) || SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
55     }
56
57     @Override
58     @Nullable
59     protected ThingHandler createHandler(Thing thing) {
60         ThingTypeUID thingTypeUID = thing.getThingTypeUID();
61
62         logger.debug("Creating handler for {}", thing.getThingTypeUID().getId());
63
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_HEATING_SYSTEM)) {
112             return new SomfyTahomaHeatingSystemHandler(thing);
113         } else if (thingTypeUID.equals(THING_TYPE_ONOFF_HEATING_SYSTEM)) {
114             return new SomfyTahomaOnOffHeatingSystemHandler(thing);
115         } else if (thingTypeUID.equals(THING_TYPE_EXTERIOR_HEATING_SYSTEM)) {
116             return new SomfyTahomaExteriorHeatingSystemHandler(thing);
117         } else if (thingTypeUID.equals(THING_TYPE_DOOR_LOCK)) {
118             return new SomfyTahomaDoorLockHandler(thing);
119         } else if (thingTypeUID.equals(THING_TYPE_PERGOLA)) {
120             return new SomfyTahomaPergolaHandler(thing);
121         } else if (thingTypeUID.equals(THING_TYPE_WINDOW_HANDLE)) {
122             return new SomfyTahomaWindowHandleHandler(thing);
123         } else if (thingTypeUID.equals(THING_TYPE_TEMPERATURESENSOR)) {
124             return new SomfyTahomaTemperatureSensorHandler(thing);
125         } else if (thingTypeUID.equals(THING_TYPE_GATE)) {
126             return new SomfyTahomaGateHandler(thing);
127         } else if (thingTypeUID.equals(THING_TYPE_CURTAIN)) {
128             return new SomfyTahomaCurtainHandler(thing);
129         } else if (thingTypeUID.equals(THING_TYPE_ELECTRICITYSENSOR)) {
130             return new SomfyTahomaElectricitySensorHandler(thing);
131         } else if (thingTypeUID.equals(THING_TYPE_DOCK)) {
132             return new SomfyTahomaDockHandler(thing);
133         } else if (thingTypeUID.equals(THING_TYPE_SIREN)) {
134             return new SomfyTahomaSirenHandler(thing);
135         } else if (thingTypeUID.equals(THING_TYPE_ADJUSTABLE_SLATS_ROLLERSHUTTER)) {
136             return new SomfyTahomaAdjustableSlatsRollerShutterHandler(thing);
137         } else if (thingTypeUID.equals(THING_TYPE_MYFOX_CAMERA)) {
138             return new SomfyTahomaMyfoxCameraHandler(thing);
139         } else if (thingTypeUID.equals(THING_TYPE_MYFOX_ALARM)) {
140             return new SomfyTahomaMyfoxAlarmHandler(thing);
141         } else if (thingTypeUID.equals(THING_TYPE_THERMOSTAT)) {
142             return new SomfyTahomaThermostatHandler(thing);
143         } else {
144             return null;
145         }
146     }
147 }