forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[miele] Add null annotations and improve error handling robustness (o…
…penhab#12497) * Add null annotations and improve error handling robustness * Fix compliancy with rule ConstantNameCheck Fixes openhab#12496 Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
- Loading branch information
Showing
35 changed files
with
993 additions
and
668 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...ing.miele/src/main/java/org/openhab/binding/miele/internal/api/dto/DeviceClassObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Copyright (c) 2010-2022 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.miele.internal.api.dto; | ||
|
||
import com.google.gson.JsonArray; | ||
|
||
/** | ||
* The {@link DeviceClassObject} class represents the DeviceClassObject node in the response JSON. | ||
* | ||
* @author Jacob Laursen - Initial contribution | ||
**/ | ||
public class DeviceClassObject { | ||
public String DeviceClassType; | ||
public JsonArray Operations; | ||
public String DeviceClass; | ||
public JsonArray Properties; | ||
|
||
public DeviceClassObject() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...inding.miele/src/main/java/org/openhab/binding/miele/internal/api/dto/DeviceProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Copyright (c) 2010-2022 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.miele.internal.api.dto; | ||
|
||
import com.google.gson.JsonObject; | ||
|
||
/** | ||
* The {@link DeviceProperty} class represents the DeviceProperty node in the response JSON. | ||
* | ||
* @author Jacob Laursen - Initial contribution | ||
**/ | ||
public class DeviceProperty { | ||
public String Name; | ||
public String Value; | ||
public int Polling; | ||
public JsonObject Metadata; | ||
|
||
public DeviceProperty() { | ||
} | ||
} |
103 changes: 103 additions & 0 deletions
103
...ab.binding.miele/src/main/java/org/openhab/binding/miele/internal/api/dto/HomeDevice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/** | ||
* Copyright (c) 2010-2022 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.miele.internal.api.dto; | ||
|
||
import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier; | ||
import org.openhab.binding.miele.internal.MieleBindingConstants; | ||
|
||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
|
||
/** | ||
* The {@link HomeDevice} class represents the HomeDevice node in the response JSON. | ||
* | ||
* @author Jacob Laursen - Initial contribution | ||
**/ | ||
public class HomeDevice { | ||
|
||
private static final String MIELE_APPLIANCE_CLASS = "com.miele.xgw3000.gateway.hdm.deviceclasses.MieleAppliance"; | ||
|
||
public String Name; | ||
public String Status; | ||
public String ParentUID; | ||
public String ProtocolAdapterName; | ||
public String Vendor; | ||
public String UID; | ||
public String Type; | ||
public JsonArray DeviceClasses; | ||
public String Version; | ||
public String TimestampAdded; | ||
public JsonObject Error; | ||
public JsonObject Properties; | ||
|
||
public HomeDevice() { | ||
} | ||
|
||
public FullyQualifiedApplianceIdentifier getApplianceIdentifier() { | ||
return new FullyQualifiedApplianceIdentifier(this.UID); | ||
} | ||
|
||
public String getSerialNumber() { | ||
return Properties.get("serial.number").getAsString(); | ||
} | ||
|
||
public String getFirmwareVersion() { | ||
return Properties.get("firmware.version").getAsString(); | ||
} | ||
|
||
public String getRemoteUid() { | ||
JsonElement remoteUid = Properties.get("remote.uid"); | ||
if (remoteUid == null) { | ||
// remote.uid and serial.number seems to be the same. If remote.uid | ||
// is missing for some reason, it makes sense to provide fallback | ||
// to serial number. | ||
return getSerialNumber(); | ||
} | ||
return remoteUid.getAsString(); | ||
} | ||
|
||
public String getConnectionType() { | ||
JsonElement connectionType = Properties.get("connection.type"); | ||
if (connectionType == null) { | ||
return null; | ||
} | ||
return connectionType.getAsString(); | ||
} | ||
|
||
public String getConnectionBaudRate() { | ||
JsonElement baudRate = Properties.get("connection.baud.rate"); | ||
if (baudRate == null) { | ||
return null; | ||
} | ||
return baudRate.getAsString(); | ||
} | ||
|
||
public String getApplianceModel() { | ||
JsonElement model = Properties.get("miele.model"); | ||
if (model == null) { | ||
return ""; | ||
} | ||
return model.getAsString(); | ||
} | ||
|
||
public String getDeviceClass() { | ||
for (JsonElement dc : DeviceClasses) { | ||
String dcStr = dc.getAsString(); | ||
if (dcStr.contains(MieleBindingConstants.MIELE_CLASS) && !dcStr.equals(MIELE_APPLIANCE_CLASS)) { | ||
return dcStr.substring(MieleBindingConstants.MIELE_CLASS.length()); | ||
} | ||
} | ||
return null; | ||
} | ||
} |
Oops, something went wrong.