2 * Copyright (c) 2010-2024 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.nikohomecontrol.internal;
15 import static org.openhab.binding.nikohomecontrol.internal.NikoHomeControlBindingConstants.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.nikohomecontrol.internal.handler.NikoHomeControlAccessHandler;
20 import org.openhab.binding.nikohomecontrol.internal.handler.NikoHomeControlActionHandler;
21 import org.openhab.binding.nikohomecontrol.internal.handler.NikoHomeControlAlarmHandler;
22 import org.openhab.binding.nikohomecontrol.internal.handler.NikoHomeControlBridgeHandler1;
23 import org.openhab.binding.nikohomecontrol.internal.handler.NikoHomeControlBridgeHandler2;
24 import org.openhab.binding.nikohomecontrol.internal.handler.NikoHomeControlMeterHandler;
25 import org.openhab.binding.nikohomecontrol.internal.handler.NikoHomeControlThermostatHandler;
26 import org.openhab.core.i18n.TimeZoneProvider;
27 import org.openhab.core.net.NetworkAddressService;
28 import org.openhab.core.thing.Bridge;
29 import org.openhab.core.thing.Thing;
30 import org.openhab.core.thing.ThingTypeUID;
31 import org.openhab.core.thing.binding.BaseThingHandlerFactory;
32 import org.openhab.core.thing.binding.ThingHandler;
33 import org.openhab.core.thing.binding.ThingHandlerFactory;
34 import org.osgi.service.component.annotations.Activate;
35 import org.osgi.service.component.annotations.Component;
36 import org.osgi.service.component.annotations.Reference;
39 * The {@link NikoHomeControlHandlerFactory} is responsible for creating things and thing
42 * @author Mark Herwege - Initial Contribution
46 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.nikohomecontrol")
47 public class NikoHomeControlHandlerFactory extends BaseThingHandlerFactory {
49 private final NetworkAddressService networkAddressService;
50 private final TimeZoneProvider timeZoneProvider;
53 public NikoHomeControlHandlerFactory(final @Reference NetworkAddressService networkAddressService,
54 final @Reference TimeZoneProvider timeZoneProvider) {
56 this.networkAddressService = networkAddressService;
57 this.timeZoneProvider = timeZoneProvider;
61 public boolean supportsThingType(ThingTypeUID thingTypeUID) {
62 return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID) || BRIDGE_THING_TYPES_UIDS.contains(thingTypeUID);
66 protected @Nullable ThingHandler createHandler(Thing thing) {
67 if (BRIDGE_THING_TYPES_UIDS.contains(thing.getThingTypeUID())) {
68 if (BRIDGEII_THING_TYPE.equals(thing.getThingTypeUID())) {
69 return new NikoHomeControlBridgeHandler2((Bridge) thing, networkAddressService, timeZoneProvider);
71 return new NikoHomeControlBridgeHandler1((Bridge) thing, timeZoneProvider);
73 } else if (ACTION_THING_TYPES_UIDS.contains(thing.getThingTypeUID())) {
74 return new NikoHomeControlActionHandler(thing);
75 } else if (THERMOSTAT_THING_TYPES_UIDS.contains(thing.getThingTypeUID())) {
76 return new NikoHomeControlThermostatHandler(thing);
77 } else if (METER_THING_TYPES_UIDS.contains(thing.getThingTypeUID())) {
78 return new NikoHomeControlMeterHandler(thing);
79 } else if (ACCESS_THING_TYPES_UIDS.contains(thing.getThingTypeUID())) {
80 return new NikoHomeControlAccessHandler(thing);
81 } else if (ALARM_THING_TYPES_UIDS.contains(thing.getThingTypeUID())) {
82 return new NikoHomeControlAlarmHandler(thing);