2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.atlona.internal;
15 import static org.openhab.binding.atlona.internal.AtlonaBindingConstants.*;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.binding.atlona.internal.pro3.AtlonaPro3Capabilities;
22 import org.openhab.binding.atlona.internal.pro3.AtlonaPro3Handler;
23 import org.openhab.core.thing.Thing;
24 import org.openhab.core.thing.ThingTypeUID;
25 import org.openhab.core.thing.binding.BaseThingHandlerFactory;
26 import org.openhab.core.thing.binding.ThingHandler;
27 import org.openhab.core.thing.binding.ThingHandlerFactory;
28 import org.osgi.service.component.annotations.Component;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
33 * The {@link org.openhab.binding.atlona.internal.AtlonaHandlerFactory} is responsible for creating things and thing
36 * @author Tim Roberts - Initial contribution
37 * @author Michael Lobstein - Add support for AT-PRO3HD 44/66 M
40 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.atlona")
41 public class AtlonaHandlerFactory extends BaseThingHandlerFactory {
43 private final Logger logger = LoggerFactory.getLogger(AtlonaHandlerFactory.class);
46 * The set of supported Atlona products
48 private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_PRO3_44M, THING_TYPE_PRO3_66M,
49 THING_TYPE_PRO3_88M, THING_TYPE_PRO3_1616M, THING_TYPE_PRO3HD_44M, THING_TYPE_PRO3HD_66M);
54 * Simply returns true if the given thingTypeUID is within {@link #SUPPORTED_THING_TYPES_UIDS}
57 public boolean supportsThingType(ThingTypeUID thingTypeUID) {
58 return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
64 * Creates the handler for the given thing given its thingTypeUID
67 protected @Nullable ThingHandler createHandler(Thing thing) {
68 ThingTypeUID thingTypeUID = thing.getThingTypeUID();
70 if (thingTypeUID.equals(THING_TYPE_PRO3_44M)) {
71 return new AtlonaPro3Handler(thing, new AtlonaPro3Capabilities(5, 3, Set.of(5), true));
74 if (thingTypeUID.equals(THING_TYPE_PRO3_66M)) {
75 return new AtlonaPro3Handler(thing, new AtlonaPro3Capabilities(8, 4, Set.of(6, 8), true));
78 if (thingTypeUID.equals(THING_TYPE_PRO3_88M)) {
79 return new AtlonaPro3Handler(thing, new AtlonaPro3Capabilities(10, 6, Set.of(8, 10), true));
82 if (thingTypeUID.equals(THING_TYPE_PRO3_1616M)) {
83 return new AtlonaPro3Handler(thing, new AtlonaPro3Capabilities(5, 3, Set.of(17, 18, 19, 20), true));
86 if (thingTypeUID.equals(THING_TYPE_PRO3HD_44M)) {
87 return new AtlonaPro3Handler(thing, new AtlonaPro3Capabilities(0, 0, Set.of(1, 2, 3, 4), false));
90 if (thingTypeUID.equals(THING_TYPE_PRO3HD_66M)) {
91 return new AtlonaPro3Handler(thing, new AtlonaPro3Capabilities(0, 0, Set.of(1, 2, 3, 4, 5, 6), false));
94 logger.warn("Unknown binding: {}: {}", thingTypeUID.getId(), thingTypeUID.getBindingId());