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.gardena.internal.handler;
15 import static org.openhab.binding.gardena.internal.GardenaBindingConstants.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.core.i18n.TimeZoneProvider;
20 import org.openhab.core.io.net.http.HttpClientFactory;
21 import org.openhab.core.io.net.http.WebSocketFactory;
22 import org.openhab.core.thing.Bridge;
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.Activate;
29 import org.osgi.service.component.annotations.Component;
30 import org.osgi.service.component.annotations.Reference;
33 * The {@link GardenaHandlerFactory} is responsible for creating Gardena things and thing handlers.
35 * @author Gerhard Riegler - Initial contribution
38 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.gardena")
39 public class GardenaHandlerFactory extends BaseThingHandlerFactory {
40 private HttpClientFactory httpClientFactory;
41 private WebSocketFactory webSocketFactory;
42 private TimeZoneProvider timeZoneProvider;
45 public GardenaHandlerFactory(final @Reference HttpClientFactory httpClientFactory,
46 final @Reference WebSocketFactory webSocketFactory, final @Reference TimeZoneProvider timeZoneProvider) {
47 this.httpClientFactory = httpClientFactory;
48 this.webSocketFactory = webSocketFactory;
49 this.timeZoneProvider = timeZoneProvider;
53 public boolean supportsThingType(ThingTypeUID thingTypeUID) {
54 return BINDING_ID.equals(thingTypeUID.getBindingId());
58 protected @Nullable ThingHandler createHandler(Thing thing) {
59 if (THING_TYPE_ACCOUNT.equals(thing.getThingTypeUID())) {
60 return new GardenaAccountHandler((Bridge) thing, httpClientFactory, webSocketFactory, timeZoneProvider);
62 return new GardenaThingHandler(thing, timeZoneProvider);