]> git.basschouten.com Git - openhab-addons.git/blob
1cc4f0accea52db9c990b5f57763f7696cb4172d
[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.sonyaudio.internal.handler;
14
15 import org.eclipse.jetty.websocket.client.WebSocketClient;
16 import org.openhab.core.library.types.StringType;
17 import org.openhab.core.thing.Thing;
18 import org.openhab.core.types.Command;
19
20 /**
21  * The {@link HtMt500Handler} is responsible for handling commands for HT-ST500, which are
22  * sent to one of the channels.
23  *
24  * @author David Ã…berg - Initial contribution
25  */
26 public class HtMt500Handler extends SonyAudioHandler {
27
28     public HtMt500Handler(Thing thing, WebSocketClient webSocketClient) {
29         super(thing, webSocketClient);
30     }
31
32     @Override
33     public String setInputCommand(Command command) {
34         switch (command.toString().toLowerCase()) {
35             case "btaudio":
36                 return "extInput:btAudio";
37             case "tv":
38                 return "extInput:tv";
39             case "analog":
40                 return "extInput:line";
41             case "usb":
42                 return "storage:usb1";
43             case "network":
44                 return "dlna:music";
45             case "cast":
46                 return "cast:audio";
47         }
48         return command.toString();
49     }
50
51     @Override
52     public StringType inputSource(String input) {
53         String in = input.toLowerCase();
54         if (in.contains("extinput:btaudio".toLowerCase())) {
55             return new StringType("btaudio");
56         }
57         if (in.contains("extinput:tv".toLowerCase())) {
58             return new StringType("tv");
59         }
60         if (in.contains("extinput:line".toLowerCase())) {
61             return new StringType("analog");
62         }
63         if (in.contains("storage:usb1".toLowerCase())) {
64             return new StringType("usb");
65         }
66         if (in.contains("dlna:music".toLowerCase())) {
67             return new StringType("network");
68         }
69         if (in.contains("cast:audio".toLowerCase())) {
70             return new StringType("cast");
71         }
72         return new StringType(input);
73     }
74 }