]> git.basschouten.com Git - openhab-addons.git/blob
bd1448841cd22aa6ab8136ebbceb6216d78f3e6b
[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 Status request requested from the Yamaha model/device via the API.
19  *
20  * @author Lennert Coopman - Initial contribution
21  * @author Florian Hotze - Add volume in decibel
22  */
23
24 public class Status {
25
26     @SerializedName("response_code")
27     private String responseCode;
28
29     @SerializedName("power")
30     private String power;
31
32     @SerializedName("mute")
33     private String mute;
34
35     @SerializedName("volume")
36     private int volume;
37
38     @SerializedName("actual_volume")
39     private ActualVolume actualVolume;
40
41     @SerializedName("max_volume")
42     private int maxVolume = 1;
43
44     @SerializedName("input")
45     private String input;
46
47     @SerializedName("sound_program")
48     private String soundProgram;
49
50     @SerializedName("sleep")
51     private int sleep = 0;
52
53     public String getResponseCode() {
54         if (responseCode == null) {
55             responseCode = "";
56         }
57         return responseCode;
58     }
59
60     public String getPower() {
61         if (power == null) {
62             power = "";
63         }
64         return power;
65     }
66
67     public String getMute() {
68         if (mute == null) {
69             mute = "";
70         }
71         return mute;
72     }
73
74     public int getVolume() {
75         return volume;
76     }
77
78     /**
79      * Get the volume in decibel (dB).
80      * 
81      * @return volume in dB or -90 dB if not available
82      */
83     public float getVolumeDb() {
84         if (actualVolume == null)
85             return -90f;
86         return actualVolume.getValue();
87     }
88
89     public int getMaxVolume() {
90         // if no value is returned, set to 1 to avoid division by zero
91         if (maxVolume == 0) {
92             maxVolume = 1;
93         }
94         return maxVolume;
95     }
96
97     public String getInput() {
98         if (input == null) {
99             input = "";
100         }
101         return input;
102     }
103
104     public String getSoundProgram() {
105         if (soundProgram == null) {
106             soundProgram = "";
107         }
108         return soundProgram;
109     }
110
111     public int getSleep() {
112         return sleep;
113     }
114 }