[miio] only change the name if it is the default one (#9312)

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
This commit is contained in:
Marcel 2020-12-09 14:23:18 -08:00 committed by GitHub
parent 654db27939
commit 6fe75cb288
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -490,9 +490,12 @@ public abstract class MiIoAbstractHandler extends BaseThingHandler implements Mi
this.pollingJob = null;
}
miIoScheduler.schedule(() -> {
ThingBuilder thingBuilder = editThing();
thingBuilder.withLabel(miDevice.getDescription());
updateThing(thingBuilder.build());
String label = getThing().getLabel();
if (label == null || label.startsWith("Xiaomi Mi Device")) {
ThingBuilder thingBuilder = editThing();
thingBuilder.withLabel(miDevice.getDescription());
updateThing(thingBuilder.build());
}
logger.info("Mi Device model {} identified as: {}. Does not match thingtype {}. Changing thingtype to {}",
modelId, miDevice.toString(), getThing().getThingTypeUID().toString(),
miDevice.getThingType().toString());