[miele] Fix multicast and multi-protocol support (ZigBee/Wi-Fi) (#11244)
* Fix multicast and multi-protocol support (ZigBee/Wi-Fi) * Fix channel description referring to hood but also used for oven and other appliances. * Fix auto-discovery finding already configured things through files. Fixes #11242 Fixes #11243 Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
4aa1f14600
commit
0c021ec795
|
@ -0,0 +1,64 @@
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2010-2021 Contributors to the openHAB project
|
||||||
|
*
|
||||||
|
* See the NOTICE file(s) distributed with this work for additional
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
|
*/
|
||||||
|
package org.openhab.binding.miele.internal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link FullyQualifiedApplianceIdentifier} class represents a fully qualified appliance identifier.
|
||||||
|
* Example: "hdm:ZigBee:0123456789abcdef#210"
|
||||||
|
*
|
||||||
|
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
||||||
|
*/
|
||||||
|
public class FullyQualifiedApplianceIdentifier {
|
||||||
|
private String uid;
|
||||||
|
private String protocol;
|
||||||
|
private String applianceId;
|
||||||
|
|
||||||
|
public FullyQualifiedApplianceIdentifier(String uid) {
|
||||||
|
this.uid = uid;
|
||||||
|
|
||||||
|
int separatorPosition = this.uid.lastIndexOf(':') + 1;
|
||||||
|
this.protocol = uid.substring(0, separatorPosition);
|
||||||
|
this.applianceId = uid.substring(separatorPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FullyQualifiedApplianceIdentifier(String applianceId, String protocol) {
|
||||||
|
this.uid = protocol + applianceId;
|
||||||
|
this.protocol = protocol;
|
||||||
|
this.applianceId = applianceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return UID of appliance (e.g. "hdm:ZigBee:0123456789abcdef#210")
|
||||||
|
*/
|
||||||
|
public String getUid() {
|
||||||
|
return this.uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Appliance ID without protocol adapter information (e.g. "0123456789abcdef#210")
|
||||||
|
*/
|
||||||
|
public String getApplianceId() {
|
||||||
|
return this.applianceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return this.getApplianceId().replaceAll("[^a-zA-Z0-9_]", "_");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Protocol prefix of fully qualified appliance identifier (e.g. "hdmi:ZigBee:"")
|
||||||
|
*/
|
||||||
|
public String getProtocol() {
|
||||||
|
return this.protocol;
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ import org.openhab.core.thing.ThingTypeUID;
|
||||||
*
|
*
|
||||||
* @author Karel Goderis - Initial contribution
|
* @author Karel Goderis - Initial contribution
|
||||||
* @author Martin Lepsy - added constants for support of WiFi devices & protocol
|
* @author Martin Lepsy - added constants for support of WiFi devices & protocol
|
||||||
|
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class MieleBindingConstants {
|
public class MieleBindingConstants {
|
||||||
|
@ -28,9 +29,8 @@ public class MieleBindingConstants {
|
||||||
public static final String BINDING_ID = "miele";
|
public static final String BINDING_ID = "miele";
|
||||||
public static final String APPLIANCE_ID = "uid";
|
public static final String APPLIANCE_ID = "uid";
|
||||||
public static final String DEVICE_CLASS = "dc";
|
public static final String DEVICE_CLASS = "dc";
|
||||||
public static final String HDM_LAN = "hdm:LAN:";
|
|
||||||
public static final String HDM_ZIGBEE = "hdm:ZigBee:";
|
|
||||||
public static final String PROTOCOL_PROPERTY_NAME = "protocol";
|
public static final String PROTOCOL_PROPERTY_NAME = "protocol";
|
||||||
|
public static final String SERIAL_NUMBER_PROPERTY_NAME = "serialNumber";
|
||||||
|
|
||||||
// List of all Thing Type UIDs
|
// List of all Thing Type UIDs
|
||||||
public static final ThingTypeUID THING_TYPE_XGW3000 = new ThingTypeUID(BINDING_ID, "xgw3000");
|
public static final ThingTypeUID THING_TYPE_XGW3000 = new ThingTypeUID(BINDING_ID, "xgw3000");
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier;
|
||||||
import org.openhab.binding.miele.internal.handler.ApplianceStatusListener;
|
import org.openhab.binding.miele.internal.handler.ApplianceStatusListener;
|
||||||
import org.openhab.binding.miele.internal.handler.MieleApplianceHandler;
|
import org.openhab.binding.miele.internal.handler.MieleApplianceHandler;
|
||||||
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler;
|
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler;
|
||||||
|
@ -42,6 +43,7 @@ import com.google.gson.JsonElement;
|
||||||
*
|
*
|
||||||
* @author Karel Goderis - Initial contribution
|
* @author Karel Goderis - Initial contribution
|
||||||
* @author Martin Lepsy - Added protocol information in order so support WiFi devices
|
* @author Martin Lepsy - Added protocol information in order so support WiFi devices
|
||||||
|
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
||||||
*/
|
*/
|
||||||
public class MieleApplianceDiscoveryService extends AbstractDiscoveryService implements ApplianceStatusListener {
|
public class MieleApplianceDiscoveryService extends AbstractDiscoveryService implements ApplianceStatusListener {
|
||||||
|
|
||||||
|
@ -101,8 +103,10 @@ public class MieleApplianceDiscoveryService extends AbstractDiscoveryService imp
|
||||||
ThingUID bridgeUID = mieleBridgeHandler.getThing().getUID();
|
ThingUID bridgeUID = mieleBridgeHandler.getThing().getUID();
|
||||||
Map<String, Object> properties = new HashMap<>(2);
|
Map<String, Object> properties = new HashMap<>(2);
|
||||||
|
|
||||||
properties.put(PROTOCOL_PROPERTY_NAME, appliance.getProtocol());
|
FullyQualifiedApplianceIdentifier applianceIdentifier = appliance.getApplianceIdentifier();
|
||||||
properties.put(APPLIANCE_ID, appliance.getApplianceId());
|
properties.put(PROTOCOL_PROPERTY_NAME, applianceIdentifier.getProtocol());
|
||||||
|
properties.put(APPLIANCE_ID, applianceIdentifier.getApplianceId());
|
||||||
|
properties.put(SERIAL_NUMBER_PROPERTY_NAME, appliance.getSerialNumber());
|
||||||
|
|
||||||
for (JsonElement dc : appliance.DeviceClasses) {
|
for (JsonElement dc : appliance.DeviceClasses) {
|
||||||
String dcStr = dc.getAsString();
|
String dcStr = dc.getAsString();
|
||||||
|
@ -113,7 +117,8 @@ public class MieleApplianceDiscoveryService extends AbstractDiscoveryService imp
|
||||||
}
|
}
|
||||||
|
|
||||||
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties)
|
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties)
|
||||||
.withBridge(bridgeUID).withLabel((String) properties.get(DEVICE_CLASS)).build();
|
.withBridge(bridgeUID).withLabel((String) properties.get(DEVICE_CLASS))
|
||||||
|
.withRepresentationProperty(APPLIANCE_ID).build();
|
||||||
|
|
||||||
thingDiscovered(discoveryResult);
|
thingDiscovered(discoveryResult);
|
||||||
} else {
|
} else {
|
||||||
|
@ -132,12 +137,17 @@ public class MieleApplianceDiscoveryService extends AbstractDiscoveryService imp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplianceStateChanged(String uid, DeviceClassObject dco) {
|
public void onApplianceStateChanged(FullyQualifiedApplianceIdentifier applianceIdentifier, DeviceClassObject dco) {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAppliancePropertyChanged(String uid, DeviceProperty dp) {
|
public void onAppliancePropertyChanged(FullyQualifiedApplianceIdentifier applianceIdentifier, DeviceProperty dp) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAppliancePropertyChanged(String serialNumber, DeviceProperty dp) {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +168,7 @@ public class MieleApplianceDiscoveryService extends AbstractDiscoveryService imp
|
||||||
modelID.replaceAll("[^a-zA-Z0-9_]", "_").toLowerCase());
|
modelID.replaceAll("[^a-zA-Z0-9_]", "_").toLowerCase());
|
||||||
|
|
||||||
if (getSupportedThingTypes().contains(thingTypeUID)) {
|
if (getSupportedThingTypes().contains(thingTypeUID)) {
|
||||||
ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID, appliance.getId());
|
ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID, appliance.getApplianceIdentifier().getId());
|
||||||
return thingUID;
|
return thingUID;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -39,7 +39,7 @@ import org.slf4j.LoggerFactory;
|
||||||
*
|
*
|
||||||
* @author Karel Goderis - Initial contribution
|
* @author Karel Goderis - Initial contribution
|
||||||
* @author Martin Lepsy - Added check for Miele gateway for cleaner discovery
|
* @author Martin Lepsy - Added check for Miele gateway for cleaner discovery
|
||||||
*
|
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class MieleMDNSDiscoveryParticipant implements MDNSDiscoveryParticipant {
|
public class MieleMDNSDiscoveryParticipant implements MDNSDiscoveryParticipant {
|
||||||
|
@ -83,8 +83,7 @@ public class MieleMDNSDiscoveryParticipant implements MDNSDiscoveryParticipant {
|
||||||
}
|
}
|
||||||
|
|
||||||
return DiscoveryResultBuilder.create(uid).withProperties(properties)
|
return DiscoveryResultBuilder.create(uid).withProperties(properties)
|
||||||
.withRepresentationProperty(MieleBindingConstants.HOST).withLabel("Miele XGW3000 Gateway")
|
.withRepresentationProperty(MieleBindingConstants.HOST).withLabel("Miele XGW3000").build();
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
*/
|
*/
|
||||||
package org.openhab.binding.miele.internal.handler;
|
package org.openhab.binding.miele.internal.handler;
|
||||||
|
|
||||||
|
import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier;
|
||||||
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceClassObject;
|
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceClassObject;
|
||||||
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceProperty;
|
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceProperty;
|
||||||
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.HomeDevice;
|
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.HomeDevice;
|
||||||
|
@ -22,24 +23,33 @@ import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.HomeDevice;
|
||||||
* an appliance has been removed or added.
|
* an appliance has been removed or added.
|
||||||
*
|
*
|
||||||
* @author Karel Goderis - Initial contribution
|
* @author Karel Goderis - Initial contribution
|
||||||
|
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
||||||
*/
|
*/
|
||||||
public interface ApplianceStatusListener {
|
public interface ApplianceStatusListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called whenever the state of the given appliance has changed.
|
* This method is called whenever the state of the given appliance has changed.
|
||||||
*
|
*
|
||||||
* @param uid the UID of the aplliance that has changed
|
* @param applianceIdentifier the fully qualified identifier of the appliance that has changed
|
||||||
* @param dco the POJO containing the new state (properties and/or operations)
|
* @param dco the POJO containing the new state (properties and/or operations)
|
||||||
*/
|
*/
|
||||||
void onApplianceStateChanged(String uid, DeviceClassObject dco);
|
void onApplianceStateChanged(FullyQualifiedApplianceIdentifier applianceIdentifier, DeviceClassObject dco);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called whenever a "property" of the given appliance has changed.
|
* This method is called whenever a "property" of the given appliance has changed.
|
||||||
*
|
*
|
||||||
* @param uid the UID of the aplliance that has changed
|
* @param applianceIdentifier the fully qualified identifier of the appliance that has changed
|
||||||
* @param dco the POJO containing the new state of the property
|
* @param dco the POJO containing the new state of the property
|
||||||
*/
|
*/
|
||||||
void onAppliancePropertyChanged(String uid, DeviceProperty dp);
|
void onAppliancePropertyChanged(FullyQualifiedApplianceIdentifier applianceIdentifier, DeviceProperty dp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called whenever a "property" of the given appliance has changed.
|
||||||
|
*
|
||||||
|
* @param serialNumber The serial number of the appliance that has changed
|
||||||
|
* @param dco the POJO containing the new state of the property
|
||||||
|
*/
|
||||||
|
void onAppliancePropertyChanged(String serialNumber, DeviceProperty dp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method us called whenever an appliance is removed.
|
* This method us called whenever an appliance is removed.
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
package org.openhab.binding.miele.internal.handler;
|
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.APPLIANCE_ID;
|
||||||
|
import static org.openhab.binding.miele.internal.MieleBindingConstants.PROTOCOL_PROPERTY_NAME;
|
||||||
|
|
||||||
|
import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier;
|
||||||
import org.openhab.core.library.types.OnOffType;
|
import org.openhab.core.library.types.OnOffType;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
|
@ -30,6 +32,7 @@ import com.google.gson.JsonElement;
|
||||||
*
|
*
|
||||||
* @author Stephan Esch - Initial contribution
|
* @author Stephan Esch - Initial contribution
|
||||||
* @author Martin Lepsy - fixed handling of empty JSON results
|
* @author Martin Lepsy - fixed handling of empty JSON results
|
||||||
|
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
||||||
*/
|
*/
|
||||||
public class CoffeeMachineHandler extends MieleApplianceHandler<CoffeeMachineChannelSelector> {
|
public class CoffeeMachineHandler extends MieleApplianceHandler<CoffeeMachineChannelSelector> {
|
||||||
|
|
||||||
|
@ -44,7 +47,9 @@ public class CoffeeMachineHandler extends MieleApplianceHandler<CoffeeMachineCha
|
||||||
super.handleCommand(channelUID, command);
|
super.handleCommand(channelUID, command);
|
||||||
|
|
||||||
String channelID = channelUID.getId();
|
String channelID = channelUID.getId();
|
||||||
String uid = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
String applianceId = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
||||||
|
String protocol = getThing().getProperties().get(PROTOCOL_PROPERTY_NAME);
|
||||||
|
var applianceIdentifier = new FullyQualifiedApplianceIdentifier(applianceId, protocol);
|
||||||
|
|
||||||
CoffeeMachineChannelSelector selector = (CoffeeMachineChannelSelector) getValueSelectorFromChannelID(channelID);
|
CoffeeMachineChannelSelector selector = (CoffeeMachineChannelSelector) getValueSelectorFromChannelID(channelID);
|
||||||
JsonElement result = null;
|
JsonElement result = null;
|
||||||
|
@ -54,9 +59,9 @@ public class CoffeeMachineHandler extends MieleApplianceHandler<CoffeeMachineCha
|
||||||
switch (selector) {
|
switch (selector) {
|
||||||
case SWITCH: {
|
case SWITCH: {
|
||||||
if (command.equals(OnOffType.ON)) {
|
if (command.equals(OnOffType.ON)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "switchOn");
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "switchOn");
|
||||||
} else if (command.equals(OnOffType.OFF)) {
|
} else if (command.equals(OnOffType.OFF)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "switchOff");
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "switchOff");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
package org.openhab.binding.miele.internal.handler;
|
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.APPLIANCE_ID;
|
||||||
|
import static org.openhab.binding.miele.internal.MieleBindingConstants.PROTOCOL_PROPERTY_NAME;
|
||||||
|
|
||||||
|
import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier;
|
||||||
import org.openhab.core.library.types.OnOffType;
|
import org.openhab.core.library.types.OnOffType;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
|
@ -31,6 +33,7 @@ import com.google.gson.JsonElement;
|
||||||
* @author Karel Goderis - Initial contribution
|
* @author Karel Goderis - Initial contribution
|
||||||
* @author Kai Kreuzer - fixed handling of REFRESH commands
|
* @author Kai Kreuzer - fixed handling of REFRESH commands
|
||||||
* @author Martin Lepsy - fixed handling of empty JSON results
|
* @author Martin Lepsy - fixed handling of empty JSON results
|
||||||
|
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
||||||
*/
|
*/
|
||||||
public class DishWasherHandler extends MieleApplianceHandler<DishwasherChannelSelector> {
|
public class DishWasherHandler extends MieleApplianceHandler<DishwasherChannelSelector> {
|
||||||
|
|
||||||
|
@ -45,7 +48,9 @@ public class DishWasherHandler extends MieleApplianceHandler<DishwasherChannelSe
|
||||||
super.handleCommand(channelUID, command);
|
super.handleCommand(channelUID, command);
|
||||||
|
|
||||||
String channelID = channelUID.getId();
|
String channelID = channelUID.getId();
|
||||||
String uid = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
String applianceId = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
||||||
|
String protocol = getThing().getProperties().get(PROTOCOL_PROPERTY_NAME);
|
||||||
|
var applianceIdentifier = new FullyQualifiedApplianceIdentifier(applianceId, protocol);
|
||||||
|
|
||||||
DishwasherChannelSelector selector = (DishwasherChannelSelector) getValueSelectorFromChannelID(channelID);
|
DishwasherChannelSelector selector = (DishwasherChannelSelector) getValueSelectorFromChannelID(channelID);
|
||||||
JsonElement result = null;
|
JsonElement result = null;
|
||||||
|
@ -55,9 +60,9 @@ public class DishWasherHandler extends MieleApplianceHandler<DishwasherChannelSe
|
||||||
switch (selector) {
|
switch (selector) {
|
||||||
case SWITCH: {
|
case SWITCH: {
|
||||||
if (command.equals(OnOffType.ON)) {
|
if (command.equals(OnOffType.ON)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "start");
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "start");
|
||||||
} else if (command.equals(OnOffType.OFF)) {
|
} else if (command.equals(OnOffType.OFF)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "stop");
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "stop");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
package org.openhab.binding.miele.internal.handler;
|
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.APPLIANCE_ID;
|
||||||
|
import static org.openhab.binding.miele.internal.MieleBindingConstants.PROTOCOL_PROPERTY_NAME;
|
||||||
|
|
||||||
|
import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier;
|
||||||
import org.openhab.core.library.types.OnOffType;
|
import org.openhab.core.library.types.OnOffType;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
|
@ -30,6 +32,7 @@ import com.google.gson.JsonElement;
|
||||||
* @author Karel Goderis - Initial contribution
|
* @author Karel Goderis - Initial contribution
|
||||||
* @author Kai Kreuzer - fixed handling of REFRESH commands
|
* @author Kai Kreuzer - fixed handling of REFRESH commands
|
||||||
* @author Martin Lepsy - fixed handling of empty JSON results
|
* @author Martin Lepsy - fixed handling of empty JSON results
|
||||||
|
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
||||||
*/
|
*/
|
||||||
public class FridgeFreezerHandler extends MieleApplianceHandler<FridgeFreezerChannelSelector> {
|
public class FridgeFreezerHandler extends MieleApplianceHandler<FridgeFreezerChannelSelector> {
|
||||||
|
|
||||||
|
@ -44,7 +47,9 @@ public class FridgeFreezerHandler extends MieleApplianceHandler<FridgeFreezerCha
|
||||||
super.handleCommand(channelUID, command);
|
super.handleCommand(channelUID, command);
|
||||||
|
|
||||||
String channelID = channelUID.getId();
|
String channelID = channelUID.getId();
|
||||||
String uid = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
String applianceId = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
||||||
|
String protocol = getThing().getProperties().get(PROTOCOL_PROPERTY_NAME);
|
||||||
|
var applianceIdentifier = new FullyQualifiedApplianceIdentifier(applianceId, protocol);
|
||||||
|
|
||||||
FridgeFreezerChannelSelector selector = (FridgeFreezerChannelSelector) getValueSelectorFromChannelID(channelID);
|
FridgeFreezerChannelSelector selector = (FridgeFreezerChannelSelector) getValueSelectorFromChannelID(channelID);
|
||||||
JsonElement result = null;
|
JsonElement result = null;
|
||||||
|
@ -54,17 +59,17 @@ public class FridgeFreezerHandler extends MieleApplianceHandler<FridgeFreezerCha
|
||||||
switch (selector) {
|
switch (selector) {
|
||||||
case SUPERCOOL: {
|
case SUPERCOOL: {
|
||||||
if (command.equals(OnOffType.ON)) {
|
if (command.equals(OnOffType.ON)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "startSuperCooling");
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "startSuperCooling");
|
||||||
} else if (command.equals(OnOffType.OFF)) {
|
} else if (command.equals(OnOffType.OFF)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "stopSuperCooling");
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "stopSuperCooling");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SUPERFREEZE: {
|
case SUPERFREEZE: {
|
||||||
if (command.equals(OnOffType.ON)) {
|
if (command.equals(OnOffType.ON)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "startSuperFreezing");
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "startSuperFreezing");
|
||||||
} else if (command.equals(OnOffType.OFF)) {
|
} else if (command.equals(OnOffType.OFF)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "stopSuperFreezing");
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "stopSuperFreezing");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
package org.openhab.binding.miele.internal.handler;
|
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.APPLIANCE_ID;
|
||||||
|
import static org.openhab.binding.miele.internal.MieleBindingConstants.PROTOCOL_PROPERTY_NAME;
|
||||||
|
|
||||||
|
import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier;
|
||||||
import org.openhab.core.library.types.OnOffType;
|
import org.openhab.core.library.types.OnOffType;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
|
@ -30,6 +32,7 @@ import com.google.gson.JsonElement;
|
||||||
*
|
*
|
||||||
* @author Karel Goderis - Initial contribution
|
* @author Karel Goderis - Initial contribution
|
||||||
* @author Martin Lepsy - fixed handling of empty JSON results
|
* @author Martin Lepsy - fixed handling of empty JSON results
|
||||||
|
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
||||||
*/
|
*/
|
||||||
public class FridgeHandler extends MieleApplianceHandler<FridgeChannelSelector> {
|
public class FridgeHandler extends MieleApplianceHandler<FridgeChannelSelector> {
|
||||||
|
|
||||||
|
@ -44,7 +47,9 @@ public class FridgeHandler extends MieleApplianceHandler<FridgeChannelSelector>
|
||||||
super.handleCommand(channelUID, command);
|
super.handleCommand(channelUID, command);
|
||||||
|
|
||||||
String channelID = channelUID.getId();
|
String channelID = channelUID.getId();
|
||||||
String uid = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
String applianceId = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
||||||
|
String protocol = getThing().getProperties().get(PROTOCOL_PROPERTY_NAME);
|
||||||
|
var applianceIdentifier = new FullyQualifiedApplianceIdentifier(applianceId, protocol);
|
||||||
|
|
||||||
FridgeChannelSelector selector = (FridgeChannelSelector) getValueSelectorFromChannelID(channelID);
|
FridgeChannelSelector selector = (FridgeChannelSelector) getValueSelectorFromChannelID(channelID);
|
||||||
JsonElement result = null;
|
JsonElement result = null;
|
||||||
|
@ -54,15 +59,15 @@ public class FridgeHandler extends MieleApplianceHandler<FridgeChannelSelector>
|
||||||
switch (selector) {
|
switch (selector) {
|
||||||
case SUPERCOOL: {
|
case SUPERCOOL: {
|
||||||
if (command.equals(OnOffType.ON)) {
|
if (command.equals(OnOffType.ON)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "startSuperCooling");
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "startSuperCooling");
|
||||||
} else if (command.equals(OnOffType.OFF)) {
|
} else if (command.equals(OnOffType.OFF)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "stopSuperCooling");
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "stopSuperCooling");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case START: {
|
case START: {
|
||||||
if (command.equals(OnOffType.ON)) {
|
if (command.equals(OnOffType.ON)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "start");
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "start");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
package org.openhab.binding.miele.internal.handler;
|
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.APPLIANCE_ID;
|
||||||
|
import static org.openhab.binding.miele.internal.MieleBindingConstants.PROTOCOL_PROPERTY_NAME;
|
||||||
|
|
||||||
|
import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier;
|
||||||
import org.openhab.core.library.types.OnOffType;
|
import org.openhab.core.library.types.OnOffType;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
|
@ -30,7 +32,8 @@ import com.google.gson.JsonElement;
|
||||||
* @author Karel Goderis - Initial contribution
|
* @author Karel Goderis - Initial contribution
|
||||||
* @author Kai Kreuzer - fixed handling of REFRESH commands
|
* @author Kai Kreuzer - fixed handling of REFRESH commands
|
||||||
* @author Martin Lepsy - fixed handling of empty JSON results
|
* @author Martin Lepsy - fixed handling of empty JSON results
|
||||||
*/
|
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
||||||
|
**/
|
||||||
public class HoodHandler extends MieleApplianceHandler<HoodChannelSelector> {
|
public class HoodHandler extends MieleApplianceHandler<HoodChannelSelector> {
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(HoodHandler.class);
|
private final Logger logger = LoggerFactory.getLogger(HoodHandler.class);
|
||||||
|
@ -44,7 +47,9 @@ public class HoodHandler extends MieleApplianceHandler<HoodChannelSelector> {
|
||||||
super.handleCommand(channelUID, command);
|
super.handleCommand(channelUID, command);
|
||||||
|
|
||||||
String channelID = channelUID.getId();
|
String channelID = channelUID.getId();
|
||||||
String uid = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
String applianceId = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
||||||
|
String protocol = getThing().getProperties().get(PROTOCOL_PROPERTY_NAME);
|
||||||
|
var applianceIdentifier = new FullyQualifiedApplianceIdentifier(applianceId, protocol);
|
||||||
|
|
||||||
HoodChannelSelector selector = (HoodChannelSelector) getValueSelectorFromChannelID(channelID);
|
HoodChannelSelector selector = (HoodChannelSelector) getValueSelectorFromChannelID(channelID);
|
||||||
JsonElement result = null;
|
JsonElement result = null;
|
||||||
|
@ -54,15 +59,15 @@ public class HoodHandler extends MieleApplianceHandler<HoodChannelSelector> {
|
||||||
switch (selector) {
|
switch (selector) {
|
||||||
case LIGHT: {
|
case LIGHT: {
|
||||||
if (command.equals(OnOffType.ON)) {
|
if (command.equals(OnOffType.ON)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "startLighting");
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "startLighting");
|
||||||
} else if (command.equals(OnOffType.OFF)) {
|
} else if (command.equals(OnOffType.OFF)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "stopLighting");
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "stopLighting");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case STOP: {
|
case STOP: {
|
||||||
if (command.equals(OnOffType.ON)) {
|
if (command.equals(OnOffType.ON)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "stop");
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "stop");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier;
|
||||||
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceClassObject;
|
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceClassObject;
|
||||||
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceMetaData;
|
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceMetaData;
|
||||||
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceProperty;
|
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceProperty;
|
||||||
|
@ -52,6 +53,7 @@ import com.google.gson.JsonParser;
|
||||||
*
|
*
|
||||||
* @author Karel Goderis - Initial contribution
|
* @author Karel Goderis - Initial contribution
|
||||||
* @author Martin Lepsy - Added check for JsonNull result
|
* @author Martin Lepsy - Added check for JsonNull result
|
||||||
|
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
||||||
*/
|
*/
|
||||||
public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannelSelector> extends BaseThingHandler
|
public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannelSelector> extends BaseThingHandler
|
||||||
implements ApplianceStatusListener {
|
implements ApplianceStatusListener {
|
||||||
|
@ -65,7 +67,7 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
||||||
|
|
||||||
protected Gson gson = new Gson();
|
protected Gson gson = new Gson();
|
||||||
|
|
||||||
protected String uid;
|
protected String applianceId;
|
||||||
protected MieleBridgeHandler bridgeHandler;
|
protected MieleBridgeHandler bridgeHandler;
|
||||||
private Class<E> selectorType;
|
private Class<E> selectorType;
|
||||||
protected String modelID;
|
protected String modelID;
|
||||||
|
@ -103,9 +105,9 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
logger.debug("Initializing Miele appliance handler.");
|
logger.debug("Initializing Miele appliance handler.");
|
||||||
final String uid = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
final String applianceId = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
||||||
if (uid != null) {
|
if (applianceId != null) {
|
||||||
this.uid = uid;
|
this.applianceId = applianceId;
|
||||||
if (getMieleBridgeHandler() != null) {
|
if (getMieleBridgeHandler() != null) {
|
||||||
ThingStatusInfo statusInfo = getBridge().getStatusInfo();
|
ThingStatusInfo statusInfo = getBridge().getStatusInfo();
|
||||||
updateStatus(statusInfo.getStatus(), statusInfo.getStatusDetail(), statusInfo.getDescription());
|
updateStatus(statusInfo.getStatus(), statusInfo.getStatusDetail(), statusInfo.getDescription());
|
||||||
|
@ -123,12 +125,12 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
logger.debug("Handler disposes. Unregistering listener.");
|
logger.debug("Handler disposes. Unregistering listener.");
|
||||||
if (uid != null) {
|
if (applianceId != null) {
|
||||||
MieleBridgeHandler bridgeHandler = getMieleBridgeHandler();
|
MieleBridgeHandler bridgeHandler = getMieleBridgeHandler();
|
||||||
if (bridgeHandler != null) {
|
if (bridgeHandler != null) {
|
||||||
getMieleBridgeHandler().unregisterApplianceStatusListener(this);
|
getMieleBridgeHandler().unregisterApplianceStatusListener(this);
|
||||||
}
|
}
|
||||||
uid = null;
|
applianceId = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,12 +144,13 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplianceStateChanged(String UID, DeviceClassObject dco) {
|
public void onApplianceStateChanged(FullyQualifiedApplianceIdentifier applicationIdentifier,
|
||||||
String myUID = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
DeviceClassObject dco) {
|
||||||
|
String myApplianceId = (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());
|
||||||
|
|
||||||
if (myUID.equals(UID)) {
|
if (myApplianceId.equals(applicationIdentifier.getApplianceId())) {
|
||||||
if (modelID.equals(this.modelID)) {
|
if (modelID.equals(this.modelID)) {
|
||||||
for (JsonElement prop : dco.Properties.getAsJsonArray()) {
|
for (JsonElement prop : dco.Properties.getAsJsonArray()) {
|
||||||
try {
|
try {
|
||||||
|
@ -155,7 +158,7 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
||||||
dp.Value = StringUtils.trim(dp.Value);
|
dp.Value = StringUtils.trim(dp.Value);
|
||||||
dp.Value = StringUtils.strip(dp.Value);
|
dp.Value = StringUtils.strip(dp.Value);
|
||||||
|
|
||||||
onAppliancePropertyChanged(UID, dp);
|
onAppliancePropertyChanged(applicationIdentifier, dp);
|
||||||
} catch (Exception p) {
|
} catch (Exception p) {
|
||||||
// Ignore - this is due to an unrecognized and not yet reverse-engineered array property
|
// Ignore - this is due to an unrecognized and not yet reverse-engineered array property
|
||||||
}
|
}
|
||||||
|
@ -165,85 +168,107 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAppliancePropertyChanged(String UID, DeviceProperty dp) {
|
public void onAppliancePropertyChanged(String serialNumber, DeviceProperty dp) {
|
||||||
String myUID = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
String mySerialNumber = getThing().getProperties().get(SERIAL_NUMBER_PROPERTY_NAME);
|
||||||
|
if (!mySerialNumber.equals(serialNumber)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (myUID.equals(UID)) {
|
this.onAppliancePropertyChanged(dp);
|
||||||
try {
|
}
|
||||||
DeviceMetaData dmd = null;
|
|
||||||
if (dp.Metadata == null) {
|
@Override
|
||||||
String metadata = metaDataCache.get(new StringBuilder().append(dp.Name).toString().trim());
|
public void onAppliancePropertyChanged(FullyQualifiedApplianceIdentifier applicationIdentifier, DeviceProperty dp) {
|
||||||
if (metadata != null) {
|
String myApplianceId = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
||||||
JsonObject jsonMetaData = (JsonObject) JsonParser.parseString(metadata);
|
|
||||||
dmd = gson.fromJson(jsonMetaData, DeviceMetaData.class);
|
if (!myApplianceId.equals(applicationIdentifier.getApplianceId())) {
|
||||||
// only keep the enum, if any - that's all we care for events we receive via multicast
|
return;
|
||||||
// all other fields are nulled
|
}
|
||||||
dmd.LocalizedID = null;
|
|
||||||
dmd.LocalizedValue = null;
|
this.onAppliancePropertyChanged(dp);
|
||||||
dmd.Filter = null;
|
}
|
||||||
dmd.description = null;
|
|
||||||
}
|
private void onAppliancePropertyChanged(DeviceProperty dp) {
|
||||||
}
|
try {
|
||||||
if (dp.Metadata != null) {
|
DeviceMetaData dmd = null;
|
||||||
String metadata = StringUtils.replace(dp.Metadata.toString(), "enum", "MieleEnum");
|
if (dp.Metadata == null) {
|
||||||
|
String metadata = metaDataCache.get(new StringBuilder().append(dp.Name).toString().trim());
|
||||||
|
if (metadata != null) {
|
||||||
JsonObject jsonMetaData = (JsonObject) JsonParser.parseString(metadata);
|
JsonObject jsonMetaData = (JsonObject) JsonParser.parseString(metadata);
|
||||||
dmd = gson.fromJson(jsonMetaData, DeviceMetaData.class);
|
dmd = gson.fromJson(jsonMetaData, DeviceMetaData.class);
|
||||||
metaDataCache.put(new StringBuilder().append(dp.Name).toString().trim(), metadata);
|
// only keep the enum, if any - that's all we care for events we receive via multicast
|
||||||
|
// all other fields are nulled
|
||||||
|
dmd.LocalizedID = null;
|
||||||
|
dmd.LocalizedValue = null;
|
||||||
|
dmd.Filter = null;
|
||||||
|
dmd.description = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplianceChannelSelector selector = null;
|
|
||||||
try {
|
|
||||||
selector = getValueSelectorFromMieleID(dp.Name);
|
|
||||||
} catch (Exception h) {
|
|
||||||
logger.trace("{} is not a valid channel for a {}", dp.Name, modelID);
|
|
||||||
}
|
|
||||||
|
|
||||||
String dpValue = StringUtils.trim(StringUtils.strip(dp.Value));
|
|
||||||
|
|
||||||
if (selector != null) {
|
|
||||||
if (!selector.isProperty()) {
|
|
||||||
ChannelUID theChannelUID = new ChannelUID(getThing().getUID(), selector.getChannelID());
|
|
||||||
|
|
||||||
if (dp.Value != null) {
|
|
||||||
logger.trace("Update state of {} with getState '{}'", theChannelUID,
|
|
||||||
selector.getState(dpValue, dmd));
|
|
||||||
updateState(theChannelUID, selector.getState(dpValue, dmd));
|
|
||||||
} else {
|
|
||||||
updateState(theChannelUID, UnDefType.UNDEF);
|
|
||||||
}
|
|
||||||
} else if (dpValue != null) {
|
|
||||||
logger.debug("Updating the property '{}' of '{}' to '{}'", selector.getChannelID(),
|
|
||||||
getThing().getUID(), selector.getState(dpValue, dmd).toString());
|
|
||||||
Map<String, String> properties = editProperties();
|
|
||||||
properties.put(selector.getChannelID(), selector.getState(dpValue, dmd).toString());
|
|
||||||
updateProperties(properties);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
logger.error("An exception occurred while processing a changed device property :'{}'", e.getMessage());
|
|
||||||
}
|
}
|
||||||
|
if (dp.Metadata != null) {
|
||||||
|
String metadata = StringUtils.replace(dp.Metadata.toString(), "enum", "MieleEnum");
|
||||||
|
JsonObject jsonMetaData = (JsonObject) JsonParser.parseString(metadata);
|
||||||
|
dmd = gson.fromJson(jsonMetaData, DeviceMetaData.class);
|
||||||
|
metaDataCache.put(new StringBuilder().append(dp.Name).toString().trim(), metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
ApplianceChannelSelector selector = null;
|
||||||
|
try {
|
||||||
|
selector = getValueSelectorFromMieleID(dp.Name);
|
||||||
|
} catch (Exception h) {
|
||||||
|
logger.trace("{} is not a valid channel for a {}", dp.Name, modelID);
|
||||||
|
}
|
||||||
|
|
||||||
|
String dpValue = StringUtils.trim(StringUtils.strip(dp.Value));
|
||||||
|
|
||||||
|
if (selector != null) {
|
||||||
|
if (!selector.isProperty()) {
|
||||||
|
ChannelUID theChannelUID = new ChannelUID(getThing().getUID(), selector.getChannelID());
|
||||||
|
|
||||||
|
if (dp.Value != null) {
|
||||||
|
logger.trace("Update state of {} with getState '{}'", theChannelUID,
|
||||||
|
selector.getState(dpValue, dmd));
|
||||||
|
updateState(theChannelUID, selector.getState(dpValue, dmd));
|
||||||
|
} else {
|
||||||
|
updateState(theChannelUID, UnDefType.UNDEF);
|
||||||
|
}
|
||||||
|
} else if (dpValue != null) {
|
||||||
|
logger.debug("Updating the property '{}' of '{}' to '{}'", selector.getChannelID(),
|
||||||
|
getThing().getUID(), selector.getState(dpValue, dmd).toString());
|
||||||
|
Map<String, String> properties = editProperties();
|
||||||
|
properties.put(selector.getChannelID(), selector.getState(dpValue, dmd).toString());
|
||||||
|
updateProperties(properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
logger.error("An exception occurred while processing a changed device property :'{}'", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplianceRemoved(HomeDevice appliance) {
|
public void onApplianceRemoved(HomeDevice appliance) {
|
||||||
if (uid != null) {
|
if (applianceId == null) {
|
||||||
if (uid.equals(appliance.getApplianceId())) {
|
return;
|
||||||
updateStatus(ThingStatus.OFFLINE);
|
}
|
||||||
}
|
|
||||||
|
if (applianceId.equals(appliance.getApplianceIdentifier().getApplianceId())) {
|
||||||
|
updateStatus(ThingStatus.OFFLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplianceAdded(HomeDevice appliance) {
|
public void onApplianceAdded(HomeDevice appliance) {
|
||||||
if (uid != null) {
|
if (applianceId == null) {
|
||||||
if (uid.equals(appliance.getApplianceId())) {
|
return;
|
||||||
Map<String, String> properties = editProperties();
|
}
|
||||||
properties.put(PROTOCOL_PROPERTY_NAME, appliance.getProtocol());
|
|
||||||
updateProperties(properties);
|
|
||||||
|
|
||||||
updateStatus(ThingStatus.ONLINE);
|
FullyQualifiedApplianceIdentifier applianceIdentifier = appliance.getApplianceIdentifier();
|
||||||
}
|
|
||||||
|
if (applianceId.equals(applianceIdentifier.getApplianceId())) {
|
||||||
|
Map<String, String> properties = editProperties();
|
||||||
|
properties.put(PROTOCOL_PROPERTY_NAME, applianceIdentifier.getProtocol());
|
||||||
|
properties.put(SERIAL_NUMBER_PROPERTY_NAME, appliance.getSerialNumber());
|
||||||
|
updateProperties(properties);
|
||||||
|
updateStatus(ThingStatus.ONLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ import java.util.regex.Pattern;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier;
|
||||||
import org.openhab.core.common.NamedThreadFactory;
|
import org.openhab.core.common.NamedThreadFactory;
|
||||||
import org.openhab.core.thing.Bridge;
|
import org.openhab.core.thing.Bridge;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
|
@ -71,7 +72,8 @@ import com.google.gson.JsonParser;
|
||||||
* @author Karel Goderis - Initial contribution
|
* @author Karel Goderis - Initial contribution
|
||||||
* @author Kai Kreuzer - Fixed lifecycle issues
|
* @author Kai Kreuzer - Fixed lifecycle issues
|
||||||
* @author Martin Lepsy - Added protocol information to support WiFi devices & some refactoring for HomeDevice
|
* @author Martin Lepsy - Added protocol information to support WiFi devices & some refactoring for HomeDevice
|
||||||
*/
|
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
||||||
|
**/
|
||||||
public class MieleBridgeHandler extends BaseBridgeHandler {
|
public class MieleBridgeHandler extends BaseBridgeHandler {
|
||||||
|
|
||||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_XGW3000);
|
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_XGW3000);
|
||||||
|
@ -103,8 +105,6 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
|
||||||
// Data structures to de-JSONify whatever Miele appliances are sending us
|
// Data structures to de-JSONify whatever Miele appliances are sending us
|
||||||
public class HomeDevice {
|
public class HomeDevice {
|
||||||
|
|
||||||
private static final String PROTOCOL_LAN = "LAN";
|
|
||||||
|
|
||||||
public String Name;
|
public String Name;
|
||||||
public String Status;
|
public String Status;
|
||||||
public String ParentUID;
|
public String ParentUID;
|
||||||
|
@ -121,17 +121,12 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
|
||||||
HomeDevice() {
|
HomeDevice() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public FullyQualifiedApplianceIdentifier getApplianceIdentifier() {
|
||||||
return getApplianceId().replaceAll("[^a-zA-Z0-9_]", "_");
|
return new FullyQualifiedApplianceIdentifier(this.UID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProtocol() {
|
public String getSerialNumber() {
|
||||||
return ProtocolAdapterName.equals(PROTOCOL_LAN) ? HDM_LAN : HDM_ZIGBEE;
|
return Properties.get("serial.number").getAsString();
|
||||||
}
|
|
||||||
|
|
||||||
public String getApplianceId() {
|
|
||||||
return ProtocolAdapterName.equals(PROTOCOL_LAN) ? StringUtils.right(UID, UID.length() - HDM_LAN.length())
|
|
||||||
: StringUtils.right(UID, UID.length() - HDM_ZIGBEE.length());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,14 +264,11 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
|
||||||
String applianceId = (String) appliance.getConfiguration().getProperties()
|
String applianceId = (String) appliance.getConfiguration().getProperties()
|
||||||
.get(APPLIANCE_ID);
|
.get(APPLIANCE_ID);
|
||||||
String protocol = appliance.getProperties().get(PROTOCOL_PROPERTY_NAME);
|
String protocol = appliance.getProperties().get(PROTOCOL_PROPERTY_NAME);
|
||||||
if (protocol == null) {
|
var applianceIdentifier = new FullyQualifiedApplianceIdentifier(applianceId,
|
||||||
logger.error("Protocol property is missing for {}", applianceId);
|
protocol);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
String UID = protocol + applianceId;
|
|
||||||
|
|
||||||
Object[] args = new Object[2];
|
Object[] args = new Object[2];
|
||||||
args[0] = UID;
|
args[0] = applianceIdentifier.getUid();
|
||||||
args[1] = true;
|
args[1] = true;
|
||||||
JsonElement result = invokeRPC("HDAccess/getDeviceClassObjects", args);
|
JsonElement result = invokeRPC("HDAccess/getDeviceClassObjects", args);
|
||||||
|
|
||||||
|
@ -286,7 +278,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(applianceId, dco);
|
listener.onApplianceStateChanged(applianceIdentifier, 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 : '{}'",
|
||||||
|
@ -384,7 +376,7 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
|
||||||
packet.getPort());
|
packet.getPort());
|
||||||
|
|
||||||
DeviceProperty dp = new DeviceProperty();
|
DeviceProperty dp = new DeviceProperty();
|
||||||
String uid = null;
|
String id = null;
|
||||||
|
|
||||||
String[] parts = StringUtils.split(event, "&");
|
String[] parts = StringUtils.split(event, "&");
|
||||||
for (String p : parts) {
|
for (String p : parts) {
|
||||||
|
@ -399,14 +391,27 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "id": {
|
case "id": {
|
||||||
uid = subparts[1];
|
id = subparts[1];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ApplianceStatusListener listener : applianceStatusListeners) {
|
if (id == null) {
|
||||||
listener.onAppliancePropertyChanged(uid, dp);
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In XGW 3000 firmware 2.03 this was changed from UID (hdm:ZigBee:0123456789abcdef#210)
|
||||||
|
// to serial number (001234567890)
|
||||||
|
if (id.startsWith("hdm:")) {
|
||||||
|
for (ApplianceStatusListener listener : applianceStatusListeners) {
|
||||||
|
listener.onAppliancePropertyChanged(new FullyQualifiedApplianceIdentifier(id),
|
||||||
|
dp);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (ApplianceStatusListener listener : applianceStatusListeners) {
|
||||||
|
listener.onAppliancePropertyChanged(id, dp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
try {
|
try {
|
||||||
|
@ -440,14 +445,11 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public JsonElement invokeOperation(String UID, String modelID, String methodName) {
|
public JsonElement invokeOperation(FullyQualifiedApplianceIdentifier applianceIdentifier, String modelID,
|
||||||
return invokeOperation(UID, modelID, methodName, HDM_ZIGBEE);
|
String methodName) {
|
||||||
}
|
|
||||||
|
|
||||||
public JsonElement invokeOperation(String UID, String modelID, String methodName, String protocol) {
|
|
||||||
if (getThing().getStatus() == ThingStatus.ONLINE) {
|
if (getThing().getStatus() == ThingStatus.ONLINE) {
|
||||||
Object[] args = new Object[4];
|
Object[] args = new Object[4];
|
||||||
args[0] = protocol + UID;
|
args[0] = applianceIdentifier.getUid();
|
||||||
args[1] = "com.miele.xgw3000.gateway.hdm.deviceclasses.Miele" + modelID;
|
args[1] = "com.miele.xgw3000.gateway.hdm.deviceclasses.Miele" + modelID;
|
||||||
args[2] = methodName;
|
args[2] = methodName;
|
||||||
args[3] = null;
|
args[3] = null;
|
||||||
|
|
|
@ -15,6 +15,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.APPLIANCE_ID;
|
||||||
import static org.openhab.binding.miele.internal.MieleBindingConstants.PROTOCOL_PROPERTY_NAME;
|
import static org.openhab.binding.miele.internal.MieleBindingConstants.PROTOCOL_PROPERTY_NAME;
|
||||||
|
|
||||||
|
import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier;
|
||||||
import org.openhab.core.library.types.OnOffType;
|
import org.openhab.core.library.types.OnOffType;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
|
@ -32,6 +33,7 @@ import com.google.gson.JsonElement;
|
||||||
* @author Karel Goderis - Initial contribution
|
* @author Karel Goderis - Initial contribution
|
||||||
* @author Kai Kreuzer - fixed handling of REFRESH commands
|
* @author Kai Kreuzer - fixed handling of REFRESH commands
|
||||||
* @author Martin Lepsy - fixed handling of empty JSON results
|
* @author Martin Lepsy - fixed handling of empty JSON results
|
||||||
|
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
||||||
*/
|
*/
|
||||||
public class OvenHandler extends MieleApplianceHandler<OvenChannelSelector> {
|
public class OvenHandler extends MieleApplianceHandler<OvenChannelSelector> {
|
||||||
|
|
||||||
|
@ -46,8 +48,9 @@ public class OvenHandler extends MieleApplianceHandler<OvenChannelSelector> {
|
||||||
super.handleCommand(channelUID, command);
|
super.handleCommand(channelUID, command);
|
||||||
|
|
||||||
String channelID = channelUID.getId();
|
String channelID = channelUID.getId();
|
||||||
String uid = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
String applianceId = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
||||||
String protocol = (String) getThing().getProperties().get(PROTOCOL_PROPERTY_NAME);
|
String protocol = getThing().getProperties().get(PROTOCOL_PROPERTY_NAME);
|
||||||
|
var applianceIdentifier = new FullyQualifiedApplianceIdentifier(applianceId, protocol);
|
||||||
|
|
||||||
OvenChannelSelector selector = (OvenChannelSelector) getValueSelectorFromChannelID(channelID);
|
OvenChannelSelector selector = (OvenChannelSelector) getValueSelectorFromChannelID(channelID);
|
||||||
JsonElement result = null;
|
JsonElement result = null;
|
||||||
|
@ -57,15 +60,15 @@ public class OvenHandler extends MieleApplianceHandler<OvenChannelSelector> {
|
||||||
switch (selector) {
|
switch (selector) {
|
||||||
case SWITCH: {
|
case SWITCH: {
|
||||||
if (command.equals(OnOffType.ON)) {
|
if (command.equals(OnOffType.ON)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "switchOn", protocol);
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "switchOn");
|
||||||
} else if (command.equals(OnOffType.OFF)) {
|
} else if (command.equals(OnOffType.OFF)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "switchOff", protocol);
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "switchOff");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case STOP: {
|
case STOP: {
|
||||||
if (command.equals(OnOffType.ON)) {
|
if (command.equals(OnOffType.ON)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "stop", protocol);
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "stop");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
package org.openhab.binding.miele.internal.handler;
|
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.APPLIANCE_ID;
|
||||||
|
import static org.openhab.binding.miele.internal.MieleBindingConstants.PROTOCOL_PROPERTY_NAME;
|
||||||
|
|
||||||
|
import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier;
|
||||||
import org.openhab.core.library.types.OnOffType;
|
import org.openhab.core.library.types.OnOffType;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
|
@ -31,7 +33,8 @@ import com.google.gson.JsonElement;
|
||||||
* @author Karel Goderis - Initial contribution
|
* @author Karel Goderis - Initial contribution
|
||||||
* @author Kai Kreuzer - fixed handling of REFRESH commands
|
* @author Kai Kreuzer - fixed handling of REFRESH commands
|
||||||
* @author Martin Lepsy - fixed handling of empty JSON results
|
* @author Martin Lepsy - fixed handling of empty JSON results
|
||||||
*/
|
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
||||||
|
**/
|
||||||
public class TumbleDryerHandler extends MieleApplianceHandler<TumbleDryerChannelSelector> {
|
public class TumbleDryerHandler extends MieleApplianceHandler<TumbleDryerChannelSelector> {
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(TumbleDryerHandler.class);
|
private final Logger logger = LoggerFactory.getLogger(TumbleDryerHandler.class);
|
||||||
|
@ -45,7 +48,9 @@ public class TumbleDryerHandler extends MieleApplianceHandler<TumbleDryerChannel
|
||||||
super.handleCommand(channelUID, command);
|
super.handleCommand(channelUID, command);
|
||||||
|
|
||||||
String channelID = channelUID.getId();
|
String channelID = channelUID.getId();
|
||||||
String uid = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
String applianceId = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
||||||
|
String protocol = getThing().getProperties().get(PROTOCOL_PROPERTY_NAME);
|
||||||
|
var applianceIdentifier = new FullyQualifiedApplianceIdentifier(applianceId, protocol);
|
||||||
|
|
||||||
TumbleDryerChannelSelector selector = (TumbleDryerChannelSelector) getValueSelectorFromChannelID(channelID);
|
TumbleDryerChannelSelector selector = (TumbleDryerChannelSelector) getValueSelectorFromChannelID(channelID);
|
||||||
JsonElement result = null;
|
JsonElement result = null;
|
||||||
|
@ -55,9 +60,9 @@ public class TumbleDryerHandler extends MieleApplianceHandler<TumbleDryerChannel
|
||||||
switch (selector) {
|
switch (selector) {
|
||||||
case SWITCH: {
|
case SWITCH: {
|
||||||
if (command.equals(OnOffType.ON)) {
|
if (command.equals(OnOffType.ON)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "start");
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "start");
|
||||||
} else if (command.equals(OnOffType.OFF)) {
|
} else if (command.equals(OnOffType.OFF)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "stop");
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "stop");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
package org.openhab.binding.miele.internal.handler;
|
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.APPLIANCE_ID;
|
||||||
|
import static org.openhab.binding.miele.internal.MieleBindingConstants.PROTOCOL_PROPERTY_NAME;
|
||||||
|
|
||||||
|
import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier;
|
||||||
import org.openhab.core.library.types.OnOffType;
|
import org.openhab.core.library.types.OnOffType;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
|
@ -31,7 +33,8 @@ import com.google.gson.JsonElement;
|
||||||
* @author Karel Goderis - Initial contribution
|
* @author Karel Goderis - Initial contribution
|
||||||
* @author Kai Kreuzer - fixed handling of REFRESH commands
|
* @author Kai Kreuzer - fixed handling of REFRESH commands
|
||||||
* @author Martin Lepsy - fixed handling of empty JSON results
|
* @author Martin Lepsy - fixed handling of empty JSON results
|
||||||
*/
|
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
||||||
|
**/
|
||||||
public class WashingMachineHandler extends MieleApplianceHandler<WashingMachineChannelSelector> {
|
public class WashingMachineHandler extends MieleApplianceHandler<WashingMachineChannelSelector> {
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(WashingMachineHandler.class);
|
private final Logger logger = LoggerFactory.getLogger(WashingMachineHandler.class);
|
||||||
|
@ -45,7 +48,9 @@ public class WashingMachineHandler extends MieleApplianceHandler<WashingMachineC
|
||||||
super.handleCommand(channelUID, command);
|
super.handleCommand(channelUID, command);
|
||||||
|
|
||||||
String channelID = channelUID.getId();
|
String channelID = channelUID.getId();
|
||||||
String uid = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
String applianceId = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
||||||
|
String protocol = getThing().getProperties().get(PROTOCOL_PROPERTY_NAME);
|
||||||
|
var applianceIdentifier = new FullyQualifiedApplianceIdentifier(applianceId, protocol);
|
||||||
|
|
||||||
WashingMachineChannelSelector selector = (WashingMachineChannelSelector) getValueSelectorFromChannelID(
|
WashingMachineChannelSelector selector = (WashingMachineChannelSelector) getValueSelectorFromChannelID(
|
||||||
channelID);
|
channelID);
|
||||||
|
@ -56,9 +61,9 @@ public class WashingMachineHandler extends MieleApplianceHandler<WashingMachineC
|
||||||
switch (selector) {
|
switch (selector) {
|
||||||
case SWITCH: {
|
case SWITCH: {
|
||||||
if (command.equals(OnOffType.ON)) {
|
if (command.equals(OnOffType.ON)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "start");
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "start");
|
||||||
} else if (command.equals(OnOffType.OFF)) {
|
} else if (command.equals(OnOffType.OFF)) {
|
||||||
result = bridgeHandler.invokeOperation(uid, modelID, "stop");
|
result = bridgeHandler.invokeOperation(applianceIdentifier, modelID, "stop");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
<channel-type id="stop" advanced="false">
|
<channel-type id="stop" advanced="false">
|
||||||
<item-type>Switch</item-type>
|
<item-type>Switch</item-type>
|
||||||
<label>Stop</label>
|
<label>Stop</label>
|
||||||
<description>Stop the hood</description>
|
<description>Stop the appliance</description>
|
||||||
</channel-type>
|
</channel-type>
|
||||||
|
|
||||||
<channel-type id="step" advanced="true">
|
<channel-type id="step" advanced="true">
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
<channel id="switch" typeId="switch"/>
|
<channel id="switch" typeId="switch"/>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
||||||
|
<representation-property>uid</representation-property>
|
||||||
|
|
||||||
<config-description>
|
<config-description>
|
||||||
<parameter name="uid" type="text" required="true">
|
<parameter name="uid" type="text" required="true">
|
||||||
<label>ID</label>
|
<label>ID</label>
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
<channel id="switch" typeId="switch"/>
|
<channel id="switch" typeId="switch"/>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
||||||
|
<representation-property>uid</representation-property>
|
||||||
|
|
||||||
<config-description>
|
<config-description>
|
||||||
<parameter name="uid" type="text" required="true">
|
<parameter name="uid" type="text" required="true">
|
||||||
<label>ID</label>
|
<label>ID</label>
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
<channel id="start" typeId="switch"/>
|
<channel id="start" typeId="switch"/>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
||||||
|
<representation-property>uid</representation-property>
|
||||||
|
|
||||||
<config-description>
|
<config-description>
|
||||||
<parameter name="uid" type="text" required="true">
|
<parameter name="uid" type="text" required="true">
|
||||||
<label>ID</label>
|
<label>ID</label>
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
<channel id="start" typeId="switch"/>
|
<channel id="start" typeId="switch"/>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
||||||
|
<representation-property>uid</representation-property>
|
||||||
|
|
||||||
<config-description>
|
<config-description>
|
||||||
<parameter name="uid" type="text" required="true">
|
<parameter name="uid" type="text" required="true">
|
||||||
<label>ID</label>
|
<label>ID</label>
|
||||||
|
|
|
@ -35,6 +35,8 @@
|
||||||
<channel id="plate6time" typeId="time"/>
|
<channel id="plate6time" typeId="time"/>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
||||||
|
<representation-property>uid</representation-property>
|
||||||
|
|
||||||
<config-description>
|
<config-description>
|
||||||
<parameter name="uid" type="text" required="true">
|
<parameter name="uid" type="text" required="true">
|
||||||
<label>ID</label>
|
<label>ID</label>
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
<channel id="stop" typeId="stop"/>
|
<channel id="stop" typeId="stop"/>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
||||||
|
<representation-property>uid</representation-property>
|
||||||
|
|
||||||
<config-description>
|
<config-description>
|
||||||
<parameter name="uid" type="text" required="true">
|
<parameter name="uid" type="text" required="true">
|
||||||
<label>ID</label>
|
<label>ID</label>
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
<channel id="switch" typeId="switch"/>
|
<channel id="switch" typeId="switch"/>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
||||||
|
<representation-property>uid</representation-property>
|
||||||
|
|
||||||
<config-description>
|
<config-description>
|
||||||
<parameter name="uid" type="text" required="true">
|
<parameter name="uid" type="text" required="true">
|
||||||
<label>ID</label>
|
<label>ID</label>
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
<channel id="step" typeId="step"/>
|
<channel id="step" typeId="step"/>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
||||||
|
<representation-property>uid</representation-property>
|
||||||
|
|
||||||
<config-description>
|
<config-description>
|
||||||
<parameter name="uid" type="text" required="true">
|
<parameter name="uid" type="text" required="true">
|
||||||
<label>ID</label>
|
<label>ID</label>
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
<channel id="spinningspeed" typeId="spinningspeed"/>
|
<channel id="spinningspeed" typeId="spinningspeed"/>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
||||||
|
<representation-property>uid</representation-property>
|
||||||
|
|
||||||
<config-description>
|
<config-description>
|
||||||
<parameter name="uid" type="text" required="true">
|
<parameter name="uid" type="text" required="true">
|
||||||
<label>ID</label>
|
<label>ID</label>
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
<property name="vendor">Miele</property>
|
<property name="vendor">Miele</property>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<representation-property>ipAddress</representation-property>
|
||||||
|
|
||||||
<config-description>
|
<config-description>
|
||||||
<parameter name="ipAddress" type="text" required="true">
|
<parameter name="ipAddress" type="text" required="true">
|
||||||
<context>network-address</context>
|
<context>network-address</context>
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2010-2021 Contributors to the openHAB project
|
||||||
|
*
|
||||||
|
* See the NOTICE file(s) distributed with this work for additional
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
|
*/
|
||||||
|
package org.openhab.binding.miele.internal;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.openhab.core.test.java.JavaTest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides test cases for {@link
|
||||||
|
* org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier}
|
||||||
|
*
|
||||||
|
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
||||||
|
*/
|
||||||
|
public class FullyQualifiedApplianceIdentifierTest extends JavaTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getUidWhenConstructedFromUidReturnsUid() {
|
||||||
|
var identifier = new FullyQualifiedApplianceIdentifier("hdm:ZigBee:0123456789abcdef#210");
|
||||||
|
assertEquals("hdm:ZigBee:0123456789abcdef#210", identifier.getUid());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getUidWhenConstructedFromApplianceIdAndProtocolReturnsUid() {
|
||||||
|
var identifier = new FullyQualifiedApplianceIdentifier("0123456789abcdef#210", "hdm:LAN:");
|
||||||
|
assertEquals("hdm:LAN:0123456789abcdef#210", identifier.getUid());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getApplianceIdWhenConstructedFromUidReturnsApplianceId() {
|
||||||
|
var identifier = new FullyQualifiedApplianceIdentifier("hdm:ZigBee:0123456789abcdef#210");
|
||||||
|
assertEquals("0123456789abcdef#210", identifier.getApplianceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getApplianceIdWhenConstructedFromApplianceIdAndProtocolReturnsApplianceId() {
|
||||||
|
var identifier = new FullyQualifiedApplianceIdentifier("0123456789abcdef#210", "hdm:LAN:");
|
||||||
|
assertEquals("0123456789abcdef#210", identifier.getApplianceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getIdWhenConstructedFromUidReturnsProtocol() {
|
||||||
|
var identifier = new FullyQualifiedApplianceIdentifier("hdm:ZigBee:0123456789abcdef#210");
|
||||||
|
assertEquals("0123456789abcdef_210", identifier.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getIdWhenConstructedFromApplianceIdAndProtocolReturnsProtocol() {
|
||||||
|
var identifier = new FullyQualifiedApplianceIdentifier("0123456789abcdef#210", "hdm:LAN:");
|
||||||
|
assertEquals("0123456789abcdef_210", identifier.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getProtocolWhenConstructedFromUidReturnsProtocol() {
|
||||||
|
var identifier = new FullyQualifiedApplianceIdentifier("hdm:ZigBee:0123456789abcdef#210");
|
||||||
|
assertEquals("hdm:ZigBee:", identifier.getProtocol());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getProtocolWhenConstructedFromApplianceIdAndProtocolReturnsProtocol() {
|
||||||
|
var identifier = new FullyQualifiedApplianceIdentifier("0123456789abcdef#210", "hdm:LAN:");
|
||||||
|
assertEquals("hdm:LAN:", identifier.getProtocol());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue