Fix broken things file support. (#11218)

Fixes #8877

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
jlaur 2021-09-08 20:34:08 +02:00 committed by GitHub
parent bb1ad2a453
commit 5ae581f4e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 9 deletions

View File

@ -143,8 +143,7 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
@Override
public void onApplianceStateChanged(String UID, DeviceClassObject dco) {
String myUID = (getThing().getProperties().get(PROTOCOL_PROPERTY_NAME))
+ (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
String myUID = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
String modelID = StringUtils.right(dco.DeviceClass,
dco.DeviceClass.length() - new String("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele").length());
@ -167,8 +166,7 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
@Override
public void onAppliancePropertyChanged(String UID, DeviceProperty dp) {
String myUID = (getThing().getProperties().get(PROTOCOL_PROPERTY_NAME))
+ (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
String myUID = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
if (myUID.equals(UID)) {
try {
@ -230,7 +228,7 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
@Override
public void onApplianceRemoved(HomeDevice appliance) {
if (uid != null) {
if (uid.equals(appliance.UID)) {
if (uid.equals(appliance.getApplianceId())) {
updateStatus(ThingStatus.OFFLINE);
}
}
@ -239,7 +237,11 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
@Override
public void onApplianceAdded(HomeDevice appliance) {
if (uid != null) {
if (uid.equals(appliance.UID)) {
if (uid.equals(appliance.getApplianceId())) {
Map<String, String> properties = editProperties();
properties.put(PROTOCOL_PROPERTY_NAME, appliance.getProtocol());
updateProperties(properties);
updateStatus(ThingStatus.ONLINE);
}
}

View File

@ -266,8 +266,14 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
for (Thing appliance : getThing().getThings()) {
if (appliance.getStatus() == ThingStatus.ONLINE) {
String UID = appliance.getProperties().get(PROTOCOL_PROPERTY_NAME)
+ (String) appliance.getConfiguration().getProperties().get(APPLIANCE_ID);
String applianceId = (String) appliance.getConfiguration().getProperties()
.get(APPLIANCE_ID);
String protocol = appliance.getProperties().get(PROTOCOL_PROPERTY_NAME);
if (protocol == null) {
logger.error("Protocol property is missing for {}", applianceId);
continue;
}
String UID = protocol + applianceId;
Object[] args = new Object[2];
args[0] = UID;
@ -280,7 +286,7 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
DeviceClassObject dco = gson.fromJson(obj, DeviceClassObject.class);
for (ApplianceStatusListener listener : applianceStatusListeners) {
listener.onApplianceStateChanged(UID, dco);
listener.onApplianceStateChanged(applianceId, dco);
}
} catch (Exception e) {
logger.debug("An exception occurred while quering an appliance : '{}'",