]> git.basschouten.com Git - openhab-addons.git/blob
74f48f360bebc1919f4c510824e389ddafa82251
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.yamahamusiccast.internal.dto;
14
15 import com.google.gson.annotations.SerializedName;
16
17 /**
18  * This class represents the UDP event received from the Yamaha model/device.
19  *
20  * @author Lennert Coopman - Initial contribution
21  * @author Florian Hotze - Add volume in decibel
22  */
23
24 public class UdpMessage {
25
26     @SerializedName("device_id")
27     private String deviceId;
28
29     public String getDeviceId() {
30         if (deviceId == null) {
31             deviceId = "";
32         }
33         return deviceId;
34     }
35
36     @SerializedName("main")
37     private Zone main;
38     @SerializedName("zone2")
39     private Zone zone2;
40     @SerializedName("zone3")
41     private Zone zone3;
42     @SerializedName("zone4")
43     private Zone zone4;
44     @SerializedName("netusb")
45     private NetUSB netusb;
46     @SerializedName("dist")
47     private Dist dist;
48
49     public Zone getMain() {
50         return main;
51     }
52
53     public Zone getZone2() {
54         return zone2;
55     }
56
57     public Zone getZone3() {
58         return zone3;
59     }
60
61     public Zone getZone4() {
62         return zone4;
63     }
64
65     public NetUSB getNetUSB() {
66         return netusb;
67     }
68
69     public Dist getDist() {
70         return dist;
71     }
72
73     public class Zone {
74         @SerializedName("power")
75         private String power;
76         @SerializedName("volume")
77         private int volume = 0;
78         @SerializedName("actual_volume")
79         private ActualVolume actualVolume;
80         @SerializedName("mute")
81         private String mute;
82         @SerializedName("input")
83         private String input;
84         @SerializedName("status_updated")
85         private String statusUpdated;
86
87         public String getPower() {
88             if (power == null) {
89                 power = "";
90             }
91             return power;
92         }
93
94         public String getMute() {
95             if (mute == null) {
96                 mute = "";
97             }
98             return mute;
99         }
100
101         public String getInput() {
102             if (input == null) {
103                 input = "";
104             }
105             return input;
106         }
107
108         public int getVolume() {
109             return volume;
110         }
111
112         /**
113          * Get the volume in decibel (dB).
114          * 
115          * @return volume in dB or -90 dB if not available
116          */
117         public float getVolumeDb() {
118             if (actualVolume == null)
119                 return -80f;
120             return actualVolume.getValue();
121         }
122
123         public String getstatusUpdated() {
124             if (statusUpdated == null) {
125                 statusUpdated = "";
126             }
127             return statusUpdated;
128         }
129     }
130
131     public class NetUSB {
132         @SerializedName("preset_control")
133         private PresetControl presetControl;
134         @SerializedName("play_info_updated")
135         private String playInfoUpdated;
136         @SerializedName("play_time")
137         private int playTime;
138
139         public PresetControl getPresetControl() {
140             return presetControl;
141         }
142
143         public String getPlayInfoUpdated() {
144             if (playInfoUpdated == null) {
145                 playInfoUpdated = "";
146             }
147             return playInfoUpdated;
148         }
149
150         public int getPlayTime() {
151             return playTime;
152         }
153     }
154
155     public class PresetControl {
156         @SerializedName("type")
157         private String type;
158         @SerializedName("num")
159         private int num = 1;
160         @SerializedName("result")
161         private String result;
162
163         public String getType() {
164             if (type == null) {
165                 type = "";
166             }
167             return type;
168         }
169
170         public String getResult() {
171             if (result == null) {
172                 result = "";
173             }
174             return result;
175         }
176
177         public int getNum() {
178             return num;
179         }
180     }
181
182     public class Dist {
183         @SerializedName("dist_info_updated")
184         private String distInfoUpdated;
185
186         public String getDistInfoUpdated() {
187             if (distInfoUpdated == null) {
188                 distInfoUpdated = "";
189             }
190             return distInfoUpdated;
191         }
192     }
193 }