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