]> git.basschouten.com Git - openhab-addons.git/blob
4a303b5badb1e604b3db77124d3b4692fef04fe7
[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.yamahareceiver.internal;
14
15 import java.util.Collections;
16 import java.util.Set;
17 import java.util.stream.Collectors;
18 import java.util.stream.Stream;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.core.thing.ThingTypeUID;
22
23 /**
24  * The {@link YamahaReceiverBindingConstants} class defines common constants, which are
25  * used across the whole binding.
26  *
27  * @author David Graeff - Initial contribution
28  * @author Tomasz Maruszak - DAB support, Spotify support, refactoring
29  */
30 @NonNullByDefault
31 public class YamahaReceiverBindingConstants {
32     public static final String BINDING_ID = "yamahareceiver";
33
34     // List of all Thing Type UIDs
35     public static final ThingTypeUID BRIDGE_THING_TYPE = new ThingTypeUID(BINDING_ID, "yamahaAV");
36     public static final ThingTypeUID ZONE_THING_TYPE = new ThingTypeUID(BINDING_ID, "zone");
37
38     public static final Set<ThingTypeUID> BRIDGE_THING_TYPES_UIDS = Set.of(BRIDGE_THING_TYPE);
39     public static final Set<ThingTypeUID> ZONE_THING_TYPES_UIDS = Set.of(ZONE_THING_TYPE);
40
41     // List of channel IDs for zone control (except power which is also a non-zone/bridge channel)
42     public static final String CHANNEL_POWER = "power";
43     public static final String CHANNEL_INPUT = "input";
44     public static final String CHANNEL_INPUT_TYPE_AVAILABLE = "availableinput";
45     public static final String CHANNEL_SURROUND = "surroundProgram";
46     public static final String CHANNEL_VOLUME = "volume";
47     public static final String CHANNEL_VOLUME_DB = "volumeDB";
48     public static final String CHANNEL_MUTE = "mute";
49     public static final String CHANNEL_SCENE = "scene";
50     public static final String CHANNEL_DIALOGUE_LEVEL = "dialogueLevel";
51     public static final String CHANNEL_HDMI1OUT = "hdmi1Out";
52     public static final String CHANNEL_HDMI2OUT = "hdmi2Out";
53
54     public static final String CHANNEL_PARTY_MODE = "party_mode";
55     public static final String CHANNEL_PARTY_MODE_MUTE = "party_mode_mute";
56     public static final String CHANNEL_PARTY_MODE_VOLUME = "party_mode_volume";
57
58     // List of channel IDs for navigation control: Read/Write
59     public static final String CHANNEL_NAVIGATION_MENU = "navigation_menu"; // Navigate either in the current menu
60                                                                             // or to the full menu path if "/" is used.
61     // List of channel IDs for navigation control: Write only
62     public static final String CHANNEL_NAVIGATION_UPDOWN = "navigation_updown"; // UpDown; Change current line
63     public static final String CHANNEL_NAVIGATION_LEFTRIGHT = "navigation_leftright"; // UpDown Type
64     public static final String CHANNEL_NAVIGATION_SELECT = "navigation_select"; // Switch Type
65     public static final String CHANNEL_NAVIGATION_BACK = "navigation_back"; // Switch Type
66     public static final String CHANNEL_NAVIGATION_BACKTOROOT = "navigation_backtoroot"; // Switch Type
67
68     // List of channel IDs for navigation control: Read only
69     public static final String CHANNEL_NAVIGATION_LEVEL = "navigation_level"; // DecType
70     public static final String CHANNEL_NAVIGATION_CURRENT_ITEM = "navigation_current_item"; // DecType
71     public static final String CHANNEL_NAVIGATION_TOTAL_ITEMS = "navigation_total_items"; // DecType
72
73     public static final Set<String> CHANNELS_NAVIGATION = Collections.unmodifiableSet(Stream
74             .of(CHANNEL_NAVIGATION_MENU, CHANNEL_NAVIGATION_CURRENT_ITEM, CHANNEL_NAVIGATION_UPDOWN,
75                     CHANNEL_NAVIGATION_LEFTRIGHT, CHANNEL_NAVIGATION_SELECT, CHANNEL_NAVIGATION_BACK,
76                     CHANNEL_NAVIGATION_BACKTOROOT, CHANNEL_NAVIGATION_LEVEL, CHANNEL_NAVIGATION_TOTAL_ITEMS)
77             .collect(Collectors.toSet()));
78
79     // List of channel IDs for Tuner DAB control
80     public static final String CHANNEL_TUNER_BAND = "tuner_band"; // band name for DAB tuner; RW
81
82     // List of channel IDs for playback control
83     public static final String CHANNEL_PLAYBACK_PRESET = "preset"; // Preset number; RW
84     public static final String CHANNEL_PLAYBACK_PRESET_TYPE_NAMED = "namedpreset"; // Preset number; RW
85     public static final String CHANNEL_PLAYBACK = "playback"; // Play,Pause,Stop,FastFW,Rewind,Next,Previous.
86                                                               // Will show the current state as String.
87     // List of channel IDs for playback control: Read only
88     public static final String CHANNEL_PLAYBACK_STATION = "playback_station";
89     public static final String CHANNEL_PLAYBACK_ARTIST = "playback_artist";
90     public static final String CHANNEL_PLAYBACK_ALBUM = "playback_album";
91     public static final String CHANNEL_PLAYBACK_SONG = "playback_song";
92     public static final String CHANNEL_PLAYBACK_SONG_IMAGE_URL = "playback_song_image_url";
93
94     public static final Set<String> CHANNELS_PLAYBACK = Collections.unmodifiableSet(
95             Stream.of(CHANNEL_PLAYBACK, CHANNEL_PLAYBACK_STATION, CHANNEL_PLAYBACK_ARTIST, CHANNEL_PLAYBACK_ALBUM,
96                     CHANNEL_PLAYBACK_SONG, CHANNEL_PLAYBACK_SONG_IMAGE_URL).collect(Collectors.toSet()));
97
98     public static final String UPNP_TYPE = "MediaRenderer";
99     public static final String UPNP_MANUFACTURER = "YAMAHA";
100
101     public static class Configs {
102         public static final String CONFIG_HOST_NAME = "host";
103         public static final String CONFIG_ZONE = "zone";
104     }
105
106     public static final String PROPERTY_VERSION = "version";
107     public static final String PROPERTY_ASSIGNED_NAME = "assigned_name";
108     public static final String PROPERTY_MENU_ERROR = "menu_error";
109     public static final String PROPERTY_LAST_PARSE_ERROR = "last_parse_error";
110
111     public static final String CHANNEL_GROUP_PLAYBACK = "playback_channels";
112     public static final String CHANNEL_GROUP_NAVIGATION = "navigation_channels";
113     public static final String CHANNEL_GROUP_ZONE = "zone_channels";
114
115     /**
116      * The names of this enum are part of the protocols!
117      * Receivers have different capabilities, some have 2 zones, some up to 4.
118      * Every receiver has a "Main_Zone".
119      */
120     public enum Zone {
121         Main_Zone,
122         Zone_2,
123         Zone_3,
124         Zone_4
125     }
126
127     /**
128      * Flags indicating if a feature is supported
129      */
130     public enum Feature {
131         DAB,
132         TUNER,
133         SPOTIFY,
134         BLUETOOTH,
135         AIRPLAY,
136         NET_RADIO,
137         USB,
138         /**
139          * Model RX-V3900 has this and it represents NET_RADIO and USB
140          */
141         NET_USB,
142         /**
143          * Model HTR-xxxx has a Zone_2 concept but realized as an extension to Main_Zone
144          */
145         ZONE_B
146     }
147
148     /** Retry time in ms if no response for menu navigation */
149     public static final int MENU_RETRY_DELAY = 500;
150
151     /** Max menu waiting in ms */
152     public static final int MENU_MAX_WAITING_TIME = 5000;
153
154     // List of known inputs
155     public static class Inputs {
156         public static final String INPUT_TUNER = "TUNER";
157         public static final String INPUT_SPOTIFY = "Spotify";
158         public static final String INPUT_BLUETOOTH = "Bluetooth";
159         public static final String INPUT_NET_RADIO = "NET RADIO";
160         // Note (TM): We should only 'NET RADIO' (as the canonical input name), the NET_RADIO seems to be only used in
161         // the XML nodes when commands are sent.
162         public static final String INPUT_NET_RADIO_LEGACY = "NET_RADIO";
163         public static final String INPUT_MUSIC_CAST_LINK = "MusicCast Link";
164         public static final String INPUT_SERVER = "SERVER";
165         public static final String INPUT_USB = "USB";
166         public static final String INPUT_IPOD_USB = "iPOD_USB";
167         public static final String INPUT_DOCK = "DOCK";
168         public static final String INPUT_PC = "PC";
169         public static final String INPUT_NAPSTER = "Napster";
170         public static final String INPUT_PANDORA = "Pandora";
171         public static final String INPUT_SIRIUS = "SIRIUS";
172         public static final String INPUT_RHAPSODY = "Rhapsody";
173         public static final String INPUT_IPOD = "iPod";
174         public static final String INPUT_HD_RADIO = "HD_RADIO";
175     }
176
177     /** Placeholder value that is used when the string channel value is not available */
178     public static final String VALUE_NA = "N/A";
179     /** Empty value that is used when the string channel value is not available */
180     public static final String VALUE_EMPTY = "";
181
182     public static class Models {
183         public static final String RX_A2000 = "RX-A2000";
184     }
185 }