Fix broken things file support. (#11218)
Fixes #8877 Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
@@ -143,8 +143,7 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplianceStateChanged(String UID, DeviceClassObject dco) {
|
public void onApplianceStateChanged(String UID, DeviceClassObject dco) {
|
||||||
String myUID = (getThing().getProperties().get(PROTOCOL_PROPERTY_NAME))
|
String myUID = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
||||||
+ (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
|
||||||
String modelID = StringUtils.right(dco.DeviceClass,
|
String modelID = StringUtils.right(dco.DeviceClass,
|
||||||
dco.DeviceClass.length() - new String("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele").length());
|
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
|
@Override
|
||||||
public void onAppliancePropertyChanged(String UID, DeviceProperty dp) {
|
public void onAppliancePropertyChanged(String UID, DeviceProperty dp) {
|
||||||
String myUID = (getThing().getProperties().get(PROTOCOL_PROPERTY_NAME))
|
String myUID = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
||||||
+ (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
|
||||||
|
|
||||||
if (myUID.equals(UID)) {
|
if (myUID.equals(UID)) {
|
||||||
try {
|
try {
|
||||||
@@ -230,7 +228,7 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
|||||||
@Override
|
@Override
|
||||||
public void onApplianceRemoved(HomeDevice appliance) {
|
public void onApplianceRemoved(HomeDevice appliance) {
|
||||||
if (uid != null) {
|
if (uid != null) {
|
||||||
if (uid.equals(appliance.UID)) {
|
if (uid.equals(appliance.getApplianceId())) {
|
||||||
updateStatus(ThingStatus.OFFLINE);
|
updateStatus(ThingStatus.OFFLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -239,7 +237,11 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
|||||||
@Override
|
@Override
|
||||||
public void onApplianceAdded(HomeDevice appliance) {
|
public void onApplianceAdded(HomeDevice appliance) {
|
||||||
if (uid != null) {
|
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);
|
updateStatus(ThingStatus.ONLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -266,8 +266,14 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
|
|||||||
|
|
||||||
for (Thing appliance : getThing().getThings()) {
|
for (Thing appliance : getThing().getThings()) {
|
||||||
if (appliance.getStatus() == ThingStatus.ONLINE) {
|
if (appliance.getStatus() == ThingStatus.ONLINE) {
|
||||||
String UID = appliance.getProperties().get(PROTOCOL_PROPERTY_NAME)
|
String applianceId = (String) appliance.getConfiguration().getProperties()
|
||||||
+ (String) appliance.getConfiguration().getProperties().get(APPLIANCE_ID);
|
.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];
|
Object[] args = new Object[2];
|
||||||
args[0] = UID;
|
args[0] = UID;
|
||||||
@@ -280,7 +286,7 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
|
|||||||
DeviceClassObject dco = gson.fromJson(obj, DeviceClassObject.class);
|
DeviceClassObject dco = gson.fromJson(obj, DeviceClassObject.class);
|
||||||
|
|
||||||
for (ApplianceStatusListener listener : applianceStatusListeners) {
|
for (ApplianceStatusListener listener : applianceStatusListeners) {
|
||||||
listener.onApplianceStateChanged(UID, dco);
|
listener.onApplianceStateChanged(applianceId, dco);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.debug("An exception occurred while quering an appliance : '{}'",
|
logger.debug("An exception occurred while quering an appliance : '{}'",
|
||||||
|
|||||||
Reference in New Issue
Block a user