]> git.basschouten.com Git - openhab-addons.git/blob
ba766bedf18fed5660c08b99cf2a0e4d0195f03c
[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.omnilink.internal;
14
15 import static org.openhab.binding.omnilink.internal.OmnilinkBindingConstants.*;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.omnilink.internal.handler.AudioSourceHandler;
20 import org.openhab.binding.omnilink.internal.handler.AudioZoneHandler;
21 import org.openhab.binding.omnilink.internal.handler.ButtonHandler;
22 import org.openhab.binding.omnilink.internal.handler.ConsoleHandler;
23 import org.openhab.binding.omnilink.internal.handler.HumiditySensorHandler;
24 import org.openhab.binding.omnilink.internal.handler.LockHandler;
25 import org.openhab.binding.omnilink.internal.handler.LuminaAreaHandler;
26 import org.openhab.binding.omnilink.internal.handler.OmniAreaHandler;
27 import org.openhab.binding.omnilink.internal.handler.OmnilinkBridgeHandler;
28 import org.openhab.binding.omnilink.internal.handler.TempSensorHandler;
29 import org.openhab.binding.omnilink.internal.handler.ThermostatHandler;
30 import org.openhab.binding.omnilink.internal.handler.UnitHandler;
31 import org.openhab.binding.omnilink.internal.handler.ZoneHandler;
32 import org.openhab.binding.omnilink.internal.handler.units.DimmableUnitHandler;
33 import org.openhab.binding.omnilink.internal.handler.units.FlagHandler;
34 import org.openhab.binding.omnilink.internal.handler.units.OutputHandler;
35 import org.openhab.binding.omnilink.internal.handler.units.UpbRoomHandler;
36 import org.openhab.binding.omnilink.internal.handler.units.dimmable.UpbUnitHandler;
37 import org.openhab.core.thing.Bridge;
38 import org.openhab.core.thing.Thing;
39 import org.openhab.core.thing.ThingTypeUID;
40 import org.openhab.core.thing.binding.BaseThingHandlerFactory;
41 import org.openhab.core.thing.binding.ThingHandler;
42 import org.openhab.core.thing.binding.ThingHandlerFactory;
43 import org.osgi.service.component.annotations.Component;
44
45 /**
46  * The {@link OmnilinkHandlerFactory} is responsible for creating things and thing
47  * handlers.
48  *
49  * @author Craig Hamilton - Initial contribution
50  * @author Ethan Dye - openHAB3 rewrite
51  */
52 @NonNullByDefault
53 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.omnilink")
54 public class OmnilinkHandlerFactory extends BaseThingHandlerFactory {
55
56     @Override
57     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
58         return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
59     }
60
61     @Override
62     protected @Nullable ThingHandler createHandler(Thing thing) {
63         ThingTypeUID thingTypeUID = thing.getThingTypeUID();
64
65         if (thingTypeUID.equals(THING_TYPE_AUDIO_SOURCE)) {
66             return new AudioSourceHandler(thing);
67         } else if (thingTypeUID.equals(THING_TYPE_AUDIO_ZONE)) {
68             return new AudioZoneHandler(thing);
69         } else if (thingTypeUID.equals(THING_TYPE_BRIDGE)) {
70             return new OmnilinkBridgeHandler((Bridge) thing);
71         } else if (thingTypeUID.equals(THING_TYPE_BUTTON)) {
72             return new ButtonHandler(thing);
73         } else if (thingTypeUID.equals(THING_TYPE_CONSOLE)) {
74             return new ConsoleHandler(thing);
75         } else if (thingTypeUID.equals(THING_TYPE_DIMMABLE)) {
76             return new DimmableUnitHandler(thing);
77         } else if (thingTypeUID.equals(THING_TYPE_FLAG)) {
78             return new FlagHandler(thing);
79         } else if (thingTypeUID.equals(THING_TYPE_HUMIDITY_SENSOR)) {
80             return new HumiditySensorHandler(thing);
81         } else if (thingTypeUID.equals(THING_TYPE_LOCK)) {
82             return new LockHandler(thing);
83         } else if (thingTypeUID.equals(THING_TYPE_LUMINA_AREA)) {
84             return new LuminaAreaHandler(thing);
85         } else if (thingTypeUID.equals(THING_TYPE_OMNI_AREA)) {
86             return new OmniAreaHandler(thing);
87         } else if (thingTypeUID.equals(THING_TYPE_OUTPUT)) {
88             return new OutputHandler(thing);
89         } else if (thingTypeUID.equals(THING_TYPE_ROOM)) {
90             return new UpbRoomHandler(thing);
91         } else if (thingTypeUID.equals(THING_TYPE_TEMP_SENSOR)) {
92             return new TempSensorHandler(thing);
93         } else if (thingTypeUID.equals(THING_TYPE_THERMOSTAT)) {
94             return new ThermostatHandler(thing);
95         } else if (thingTypeUID.equals(THING_TYPE_UNIT)) {
96             return new UnitHandler(thing);
97         } else if (thingTypeUID.equals(THING_TYPE_UNIT_UPB)) {
98             return new UpbUnitHandler(thing);
99         } else if (thingTypeUID.equals(THING_TYPE_ZONE)) {
100             return new ZoneHandler(thing);
101         } else {
102             return null;
103         }
104     }
105 }