Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[miele] Fix broken things file support #11218

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {

@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());

Expand All @@ -167,8 +166,7 @@ public void onApplianceStateChanged(String UID, DeviceClassObject dco) {

@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 {
Expand Down Expand Up @@ -230,7 +228,7 @@ public void onAppliancePropertyChanged(String UID, DeviceProperty dp) {
@Override
public void onApplianceRemoved(HomeDevice appliance) {
if (uid != null) {
if (uid.equals(appliance.UID)) {
if (uid.equals(appliance.getApplianceId())) {
updateStatus(ThingStatus.OFFLINE);
}
}
Expand All @@ -239,7 +237,11 @@ public void onApplianceRemoved(HomeDevice appliance) {
@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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,14 @@ public void run() {

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;
Expand All @@ -280,7 +286,7 @@ public void run() {
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 : '{}'",
Expand Down