Fix coffee machine auto-discovery. (#11302)
Fixes #8779 Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
c3ac604cdb
commit
f4816f5449
|
@ -44,6 +44,9 @@ public class MieleBindingConstants {
|
|||
public static final ThingTypeUID THING_TYPE_WASHINGMACHINE = new ThingTypeUID(BINDING_ID, "washingmachine");
|
||||
public static final ThingTypeUID THING_TYPE_COFFEEMACHINE = new ThingTypeUID(BINDING_ID, "coffeemachine");
|
||||
|
||||
// Miele devices classes
|
||||
public static final String MIELE_DEVICE_CLASS_COFFEE_SYSTEM = "CoffeeSystem";
|
||||
|
||||
// Bridge config properties
|
||||
public static final String HOST = "ipAddress";
|
||||
public static final String INTERFACE = "interface";
|
||||
|
|
|
@ -153,19 +153,18 @@ public class MieleApplianceDiscoveryService extends AbstractDiscoveryService imp
|
|||
|
||||
private ThingUID getThingUID(HomeDevice appliance) {
|
||||
ThingUID bridgeUID = mieleBridgeHandler.getThing().getUID();
|
||||
String modelID = null;
|
||||
String modelId = null;
|
||||
|
||||
for (JsonElement dc : appliance.DeviceClasses) {
|
||||
String dcStr = dc.getAsString();
|
||||
if (dcStr.contains(MIELE_CLASS) && !dcStr.equals(MIELE_APPLIANCE_CLASS)) {
|
||||
modelID = dcStr.substring(MIELE_CLASS.length());
|
||||
modelId = dcStr.substring(MIELE_CLASS.length());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (modelID != null) {
|
||||
ThingTypeUID thingTypeUID = new ThingTypeUID(BINDING_ID,
|
||||
modelID.replaceAll("[^a-zA-Z0-9_]", "_").toLowerCase());
|
||||
if (modelId != null) {
|
||||
ThingTypeUID thingTypeUID = getThingTypeUidFromModelId(modelId);
|
||||
|
||||
if (getSupportedThingTypes().contains(thingTypeUID)) {
|
||||
ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID, appliance.getApplianceIdentifier().getId());
|
||||
|
@ -177,4 +176,19 @@ public class MieleApplianceDiscoveryService extends AbstractDiscoveryService imp
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private ThingTypeUID getThingTypeUidFromModelId(String modelId) {
|
||||
/*
|
||||
* Coffee machine CVA 6805 is reported as CoffeeSystem, but thing type is
|
||||
* coffeemachine. At least until it is known if any models are actually reported
|
||||
* as CoffeeMachine, we need this special mapping.
|
||||
*/
|
||||
if (modelId.equals(MIELE_DEVICE_CLASS_COFFEE_SYSTEM)) {
|
||||
return THING_TYPE_COFFEEMACHINE;
|
||||
}
|
||||
|
||||
String thingTypeId = modelId.replaceAll("[^a-zA-Z0-9_]", "_").toLowerCase();
|
||||
|
||||
return new ThingTypeUID(BINDING_ID, thingTypeId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
package org.openhab.binding.miele.internal.handler;
|
||||
|
||||
import static org.openhab.binding.miele.internal.MieleBindingConstants.APPLIANCE_ID;
|
||||
import static org.openhab.binding.miele.internal.MieleBindingConstants.MIELE_DEVICE_CLASS_COFFEE_SYSTEM;
|
||||
import static org.openhab.binding.miele.internal.MieleBindingConstants.PROTOCOL_PROPERTY_NAME;
|
||||
|
||||
import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier;
|
||||
|
@ -39,7 +40,7 @@ public class CoffeeMachineHandler extends MieleApplianceHandler<CoffeeMachineCha
|
|||
private final Logger logger = LoggerFactory.getLogger(CoffeeMachineHandler.class);
|
||||
|
||||
public CoffeeMachineHandler(Thing thing) {
|
||||
super(thing, CoffeeMachineChannelSelector.class, "CoffeeSystem");
|
||||
super(thing, CoffeeMachineChannelSelector.class, MIELE_DEVICE_CLASS_COFFEE_SYSTEM);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue