]> git.basschouten.com Git - openhab-addons.git/blob
0d0d5cea1808e48eba932f3236afe0d92d8ea696
[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 HtZ9fHandler} is responsible for handling commands for HT-Z9F, which are
22  * sent to one of the channels.
23  *
24  * @author David Ã…berg - Initial contribution
25  */
26 public class HtZ9fHandler extends SonyAudioHandler {
27
28     public HtZ9fHandler(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 "hdmi1":
40                 return "extInput:hdmi?port=1";
41             case "hdmi2":
42                 return "extInput:hdmi?port=2";
43             case "analog":
44                 return "extInput:line";
45             case "usb":
46                 return "storage:usb1";
47             case "network":
48                 return "dlna:music";
49             case "cast":
50                 return "cast:audio";
51         }
52         return command.toString();
53     }
54
55     @Override
56     public StringType inputSource(String input) {
57         String in = input.toLowerCase();
58         if (in.contains("extinput:btaudio".toLowerCase())) {
59             return new StringType("btaudio");
60         }
61         if (in.contains("extinput:tv".toLowerCase())) {
62             return new StringType("tv");
63         }
64         if (in.contains("extinput:hdmi?port=1".toLowerCase())) {
65             return new StringType("hdmi1");
66         }
67         if (in.contains("extinput:hdmi?port=2".toLowerCase())) {
68             return new StringType("hdmi2");
69         }
70         if (in.contains("extinput:line".toLowerCase())) {
71             return new StringType("analog");
72         }
73         if (in.contains("storage:usb1".toLowerCase())) {
74             return new StringType("usb");
75         }
76         if (in.contains("dlna:music".toLowerCase())) {
77             return new StringType("network");
78         }
79         if (in.contains("cast:audio".toLowerCase())) {
80             return new StringType("cast");
81         }
82         return new StringType(input);
83     }
84 }