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.sonyaudio.internal;
15 import org.eclipse.jetty.websocket.client.WebSocketClient;
16 import org.openhab.binding.sonyaudio.internal.handler.HtCt800Handler;
17 import org.openhab.binding.sonyaudio.internal.handler.HtMt500Handler;
18 import org.openhab.binding.sonyaudio.internal.handler.HtSt5000Handler;
19 import org.openhab.binding.sonyaudio.internal.handler.HtZ9fHandler;
20 import org.openhab.binding.sonyaudio.internal.handler.HtZf9Handler;
21 import org.openhab.binding.sonyaudio.internal.handler.SrsZr5Handler;
22 import org.openhab.binding.sonyaudio.internal.handler.StrDn1080Handler;
23 import org.openhab.core.io.net.http.WebSocketFactory;
24 import org.openhab.core.thing.Thing;
25 import org.openhab.core.thing.ThingTypeUID;
26 import org.openhab.core.thing.binding.BaseThingHandlerFactory;
27 import org.openhab.core.thing.binding.ThingHandler;
28 import org.openhab.core.thing.binding.ThingHandlerFactory;
29 import org.osgi.service.component.annotations.Component;
30 import org.osgi.service.component.annotations.Reference;
33 * The {@link SonyAudioHandlerFactory} is responsible for creating things and thing
36 * @author David - Initial contribution
38 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.sonyaudio")
39 public class SonyAudioHandlerFactory extends BaseThingHandlerFactory {
41 private WebSocketClient webSocketClient;
44 public boolean supportsThingType(ThingTypeUID thingTypeUID) {
45 return SonyAudioBindingConstants.SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
49 protected ThingHandler createHandler(Thing thing) {
50 ThingTypeUID thingTypeUID = thing.getThingTypeUID();
52 switch (thingTypeUID.getId()) {
53 case SonyAudioBindingConstants.SONY_TYPE_STRDN1080:
54 return new StrDn1080Handler(thing, webSocketClient);
55 case SonyAudioBindingConstants.SONY_TYPE_HTCT800:
56 return new HtCt800Handler(thing, webSocketClient);
57 case SonyAudioBindingConstants.SONY_TYPE_HTST5000:
58 return new HtSt5000Handler(thing, webSocketClient);
59 case SonyAudioBindingConstants.SONY_TYPE_HTZ9F:
60 return new HtZ9fHandler(thing, webSocketClient);
61 case SonyAudioBindingConstants.SONY_TYPE_HTZF9:
62 return new HtZf9Handler(thing, webSocketClient);
63 case SonyAudioBindingConstants.SONY_TYPE_HTMT500:
64 return new HtMt500Handler(thing, webSocketClient);
65 case SonyAudioBindingConstants.SONY_TYPE_SRSZR5:
66 return new SrsZr5Handler(thing, webSocketClient);
73 protected void setWebSocketFactory(WebSocketFactory webSocketFactory) {
74 this.webSocketClient = webSocketFactory.getCommonWebSocketClient();
77 protected void unsetWebSocketFactory(WebSocketFactory webSocketFactory) {
78 this.webSocketClient = null;