]> git.basschouten.com Git - openhab-addons.git/blob
5488dacb3ebc088185b5706e649b3e7db0b8651e
[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.magentatv.internal.config;
14
15 import static org.openhab.binding.magentatv.internal.MagentaTVBindingConstants.*;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18
19 /**
20  * The {@link MagentaTVDynamicConfig} extends MagentaTVThingConfiguration contains additional dynamic data
21  * runtime).
22  *
23  * @author Markus Michels - Initial contribution
24  */
25 @NonNullByDefault
26 public class MagentaTVDynamicConfig extends MagentaTVThingConfiguration {
27     protected String modelId = MODEL_MR400; // MR model
28     protected String hardwareVersion = "";
29     protected String firmwareVersion = "";
30     protected String friendlyName = ""; // Receiver's Friendly Name from UPnP descriptin
31     protected String descriptionUrl = MR401B_DEF_DESCRIPTION_URL; // Device description, usually from UPnP discovery
32     protected String localIP = ""; // Outbound IP for pairing/communication
33     protected String localMAC = ""; // used to compute the terminalID
34     protected String wakeOnLAN = ""; // Device supports Wake-on-LAN
35     protected String terminalID = ""; // terminalID for pairing process
36     protected String pairingCode = ""; // Input to the paring process
37     protected String verificationCode = ""; // Result of the paring process
38
39     public MagentaTVDynamicConfig() {
40     }
41
42     public MagentaTVDynamicConfig(MagentaTVThingConfiguration config) {
43         super.update(config);
44     }
45
46     public void updateNetwork(MagentaTVDynamicConfig network) {
47         this.setLocalIP(network.getLocalIP());
48         this.setLocalMAC(network.getLocalMAC());
49         this.setTerminalID(network.getTerminalID());
50     }
51
52     public String getModel() {
53         return modelId.toUpperCase();
54     }
55
56     public String getPort() {
57         return !port.isEmpty() ? port : isMR400() ? MR400_DEF_REMOTE_PORT : MR401B_DEF_REMOTE_PORT;
58     }
59
60     public void setPort(String port) {
61         if (modelId.contains(MODEL_MR400) && "49153".equals(port)) {
62             // overwrite port returned by discovery (invalid for this model)
63             this.port = MR400_DEF_REMOTE_PORT;
64         } else {
65             this.port = port;
66         }
67     }
68
69     public boolean isMR400() {
70         return modelId.equals(MODEL_MR400);
71     }
72
73     public void setModel(String modelId) {
74         this.modelId = modelId;
75     }
76
77     public String getWakeOnLAN() {
78         return wakeOnLAN;
79     }
80
81     public void setWakeOnLAN(String wakeOnLAN) {
82         this.wakeOnLAN = wakeOnLAN.toUpperCase();
83     }
84
85     public String getDescriptionUrl() {
86         if (descriptionUrl.equals(MR400_DEF_DESCRIPTION_URL)
87                 && !(port.equals(MR400_DEF_REMOTE_PORT) || "49153".equals(port))) {
88             // MR401B returns the wrong URL
89             return MR401B_DEF_DESCRIPTION_URL;
90         }
91         return descriptionUrl;
92     }
93
94     public void setDescriptionUrl(String descriptionUrl) {
95         this.descriptionUrl = getString(descriptionUrl);
96     }
97
98     public String getFriendlyName() {
99         return friendlyName;
100     }
101
102     public void setFriendlyName(String friendlyName) {
103         this.friendlyName = friendlyName;
104     }
105
106     public String getHardwareVersion() {
107         return hardwareVersion;
108     }
109
110     public void setHardwareVersion(String hardwareVersion) {
111         this.hardwareVersion = hardwareVersion;
112     }
113
114     public String getFirmwareVersion() {
115         return firmwareVersion;
116     }
117
118     public void setFirmwareVersion(String firmwareVersion) {
119         this.firmwareVersion = firmwareVersion;
120     }
121
122     public String getTerminalID() {
123         return terminalID;
124     }
125
126     public void setTerminalID(String terminalID) {
127         this.terminalID = terminalID.toUpperCase();
128     }
129
130     public String getPairingCode() {
131         return pairingCode;
132     }
133
134     public void setPairingCode(String pairingCode) {
135         this.pairingCode = pairingCode;
136     }
137
138     public String getVerificationCode() {
139         return verificationCode;
140     }
141
142     public void setVerificationCode(String verificationCode) {
143         this.verificationCode = verificationCode;
144     }
145
146     public String getLocalIP() {
147         return localIP;
148     }
149
150     public void setLocalIP(String localIP) {
151         this.localIP = localIP;
152     }
153
154     public String getLocalMAC() {
155         return localMAC;
156     }
157
158     public void setLocalMAC(String localMAC) {
159         this.localMAC = localMAC.toUpperCase();
160     }
161 }