2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.miele.internal.api.dto;
15 import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier;
16 import org.openhab.binding.miele.internal.MieleBindingConstants;
18 import com.google.gson.JsonArray;
19 import com.google.gson.JsonElement;
20 import com.google.gson.JsonObject;
23 * The {@link HomeDevice} class represents the HomeDevice node in the response JSON.
25 * @author Jacob Laursen - Initial contribution
27 public class HomeDevice {
29 private static final String MIELE_APPLIANCE_CLASS = "com.miele.xgw3000.gateway.hdm.deviceclasses.MieleAppliance";
33 public String ParentUID;
34 public String ProtocolAdapterName;
38 public JsonArray DeviceClasses;
39 public String Version;
40 public String TimestampAdded;
41 public JsonObject Error;
42 public JsonObject Properties;
47 public FullyQualifiedApplianceIdentifier getApplianceIdentifier() {
48 return new FullyQualifiedApplianceIdentifier(this.UID);
51 public String getSerialNumber() {
52 return Properties.get("serial.number").getAsString();
55 public String getFirmwareVersion() {
56 return Properties.get("firmware.version").getAsString();
59 public String getRemoteUid() {
60 JsonElement remoteUid = Properties.get("remote.uid");
61 if (remoteUid == null) {
62 // remote.uid and serial.number seems to be the same. If remote.uid
63 // is missing for some reason, it makes sense to provide fallback
65 return getSerialNumber();
67 return remoteUid.getAsString();
70 public String getConnectionType() {
71 JsonElement connectionType = Properties.get("connection.type");
72 if (connectionType == null) {
75 return connectionType.getAsString();
78 public String getConnectionBaudRate() {
79 JsonElement baudRate = Properties.get("connection.baud.rate");
80 if (baudRate == null) {
83 return baudRate.getAsString();
86 public String getApplianceModel() {
87 JsonElement model = Properties.get("miele.model");
91 return model.getAsString();
94 public String getDeviceClass() {
95 for (JsonElement dc : DeviceClasses) {
96 String dcStr = dc.getAsString();
97 if (dcStr.contains(MieleBindingConstants.MIELE_CLASS) && !dcStr.equals(MIELE_APPLIANCE_CLASS)) {
98 return dcStr.substring(MieleBindingConstants.MIELE_CLASS.length());