mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 23:22:02 +01:00
[miele] Fix configuration validation and optimize performance (#12510)
* Update bridge status to UNKNOWN before scheduling polling job * Reduced error log levels to warning * Validate configuration and leave initialize() with status UNKNOWN * Extract JSON-RPC handling to separate class * Use already stored applianceId * Keep listeners in Set to eliminate duplicates and improve performance * Reduce access levels for variables exposed to subclasses unneededly * Initialize translation provider with default language in constructor to avoid nullness * Divide listener interface into two: discovery and appliance status * Optimize communication between bridge and handlers * Fix thing status transitions and support gone appliances * Do not check/schedule jobs for each listener registration * Optimize listener registration by using cached appliances * Optimize state/property updates and reduce logging level for properties * Fix concurrency issue during handler initialization * Simplify online/offline transitions * Use cached appliances for discovery listener callback * Avoid unneeded call every 15 seconds receiving response with ~5.5 KB payload * Fix devices being removed after failed RPC calls * Fix method parameter descriptions Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
f1176a062b
commit
2d3f0d68c0
@ -89,7 +89,7 @@ public class DeviceUtil {
|
|||||||
* as well as built-in/translated strings.
|
* as well as built-in/translated strings.
|
||||||
*/
|
*/
|
||||||
public static State getStateTextState(String s, @Nullable DeviceMetaData dmd,
|
public static State getStateTextState(String s, @Nullable DeviceMetaData dmd,
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
MieleTranslationProvider translationProvider) {
|
||||||
return getTextState(s, dmd, translationProvider, STATES, MISSING_STATE_TEXT_PREFIX, "");
|
return getTextState(s, dmd, translationProvider, STATES, MISSING_STATE_TEXT_PREFIX, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ public class DeviceUtil {
|
|||||||
* @return Text string as State
|
* @return Text string as State
|
||||||
*/
|
*/
|
||||||
public static State getTextState(String s, @Nullable DeviceMetaData dmd,
|
public static State getTextState(String s, @Nullable DeviceMetaData dmd,
|
||||||
@Nullable MieleTranslationProvider translationProvider, Map<String, String> valueMap, String propertyPrefix,
|
MieleTranslationProvider translationProvider, Map<String, String> valueMap, String propertyPrefix,
|
||||||
String appliancePrefix) {
|
String appliancePrefix) {
|
||||||
if ("0".equals(s)) {
|
if ("0".equals(s)) {
|
||||||
return UnDefType.UNDEF;
|
return UnDefType.UNDEF;
|
||||||
@ -122,7 +122,7 @@ public class DeviceUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String value = valueMap.get(s);
|
String value = valueMap.get(s);
|
||||||
if (value != null && translationProvider != null) {
|
if (value != null) {
|
||||||
String key = TEXT_PREFIX + propertyPrefix + appliancePrefix + value;
|
String key = TEXT_PREFIX + propertyPrefix + appliancePrefix + value;
|
||||||
return new StringType(
|
return new StringType(
|
||||||
translationProvider.getText(key, gatewayText != null ? gatewayText : propertyPrefix + s));
|
translationProvider.getText(key, gatewayText != null ? gatewayText : propertyPrefix + s));
|
||||||
|
@ -0,0 +1,184 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2010-2022 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 java.io.BufferedInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.openhab.binding.miele.internal.exceptions.MieleRpcException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link MieleGatewayCommunicationController} class is used for communicating with
|
||||||
|
* the XGW 3000 gateway through JSON-RPC.
|
||||||
|
*
|
||||||
|
* @author Jacob Laursen - Initial contribution
|
||||||
|
*/
|
||||||
|
@NonNullByDefault
|
||||||
|
public class MieleGatewayCommunicationController {
|
||||||
|
|
||||||
|
private final URL url;
|
||||||
|
private final Random rand = new Random();
|
||||||
|
private final Gson gson = new Gson();
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(MieleGatewayCommunicationController.class);
|
||||||
|
|
||||||
|
public MieleGatewayCommunicationController(String host) throws MalformedURLException {
|
||||||
|
url = new URL("http://" + host + "/remote/json-rpc");
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonElement invokeOperation(FullyQualifiedApplianceIdentifier applianceIdentifier, String modelID,
|
||||||
|
String methodName) throws MieleRpcException {
|
||||||
|
Object[] args = new Object[4];
|
||||||
|
args[0] = applianceIdentifier.getUid();
|
||||||
|
args[1] = MieleBindingConstants.MIELE_CLASS + modelID;
|
||||||
|
args[2] = methodName;
|
||||||
|
args[3] = null;
|
||||||
|
|
||||||
|
return invokeRPC("HDAccess/invokeDCOOperation", args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonElement invokeRPC(String methodName, Object[] args) throws MieleRpcException {
|
||||||
|
JsonElement result = null;
|
||||||
|
JsonObject req = new JsonObject();
|
||||||
|
int id = rand.nextInt(Integer.MAX_VALUE);
|
||||||
|
req.addProperty("jsonrpc", "2.0");
|
||||||
|
req.addProperty("id", id);
|
||||||
|
req.addProperty("method", methodName);
|
||||||
|
|
||||||
|
JsonArray params = new JsonArray();
|
||||||
|
for (Object o : args) {
|
||||||
|
params.add(gson.toJsonTree(o));
|
||||||
|
}
|
||||||
|
req.add("params", params);
|
||||||
|
|
||||||
|
String requestData = req.toString();
|
||||||
|
String responseData = null;
|
||||||
|
try {
|
||||||
|
responseData = post(url, Collections.emptyMap(), requestData);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new MieleRpcException("Exception occurred while posting data", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.trace("The request '{}' yields '{}'", requestData, responseData);
|
||||||
|
JsonObject parsedResponse = null;
|
||||||
|
try {
|
||||||
|
parsedResponse = (JsonObject) JsonParser.parseReader(new StringReader(responseData));
|
||||||
|
} catch (JsonParseException e) {
|
||||||
|
throw new MieleRpcException("Error parsing JSON response", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonElement error = parsedResponse.get("error");
|
||||||
|
if (error != null && !error.isJsonNull()) {
|
||||||
|
if (error.isJsonPrimitive()) {
|
||||||
|
throw new MieleRpcException("Remote exception occurred: '" + error.getAsString() + "'");
|
||||||
|
} else if (error.isJsonObject()) {
|
||||||
|
JsonObject o = error.getAsJsonObject();
|
||||||
|
Integer code = (o.has("code") ? o.get("code").getAsInt() : null);
|
||||||
|
String message = (o.has("message") ? o.get("message").getAsString() : null);
|
||||||
|
String data = (o.has("data")
|
||||||
|
? (o.get("data") instanceof JsonObject ? o.get("data").toString() : o.get("data").getAsString())
|
||||||
|
: null);
|
||||||
|
throw new MieleRpcException(
|
||||||
|
"Remote exception occurred: '" + code + "':'" + message + "':'" + data + "'");
|
||||||
|
} else {
|
||||||
|
throw new MieleRpcException("Unknown remote exception occurred: '" + error.toString() + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result = parsedResponse.get("result");
|
||||||
|
if (result == null) {
|
||||||
|
throw new MieleRpcException("Result is missing in response");
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String post(URL url, Map<String, String> headers, String data) throws IOException {
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
|
|
||||||
|
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||||
|
connection.addRequestProperty(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
connection.addRequestProperty("Accept-Encoding", "gzip");
|
||||||
|
connection.setRequestMethod("POST");
|
||||||
|
connection.setDoOutput(true);
|
||||||
|
connection.connect();
|
||||||
|
|
||||||
|
OutputStream out = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
out = connection.getOutputStream();
|
||||||
|
|
||||||
|
out.write(data.getBytes());
|
||||||
|
out.flush();
|
||||||
|
|
||||||
|
int statusCode = connection.getResponseCode();
|
||||||
|
if (statusCode != HttpURLConnection.HTTP_OK) {
|
||||||
|
logger.debug("An unexpected status code was returned: '{}'", statusCode);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (out != null) {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String responseEncoding = connection.getHeaderField("Content-Encoding");
|
||||||
|
responseEncoding = (responseEncoding == null ? "" : responseEncoding.trim());
|
||||||
|
|
||||||
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
InputStream in = connection.getInputStream();
|
||||||
|
try {
|
||||||
|
in = connection.getInputStream();
|
||||||
|
if ("gzip".equalsIgnoreCase(responseEncoding)) {
|
||||||
|
in = new GZIPInputStream(in);
|
||||||
|
}
|
||||||
|
in = new BufferedInputStream(in);
|
||||||
|
|
||||||
|
byte[] buff = new byte[1024];
|
||||||
|
int n;
|
||||||
|
while ((n = in.read(buff)) > 0) {
|
||||||
|
bos.write(buff, 0, n);
|
||||||
|
}
|
||||||
|
bos.flush();
|
||||||
|
bos.close();
|
||||||
|
} finally {
|
||||||
|
if (in != null) {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bos.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -23,10 +23,8 @@ import java.util.Set;
|
|||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier;
|
import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier;
|
||||||
import org.openhab.binding.miele.internal.api.dto.DeviceClassObject;
|
|
||||||
import org.openhab.binding.miele.internal.api.dto.DeviceProperty;
|
|
||||||
import org.openhab.binding.miele.internal.api.dto.HomeDevice;
|
import org.openhab.binding.miele.internal.api.dto.HomeDevice;
|
||||||
import org.openhab.binding.miele.internal.handler.ApplianceStatusListener;
|
import org.openhab.binding.miele.internal.handler.DiscoveryListener;
|
||||||
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;
|
||||||
import org.openhab.core.config.discovery.AbstractDiscoveryService;
|
import org.openhab.core.config.discovery.AbstractDiscoveryService;
|
||||||
@ -47,7 +45,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class MieleApplianceDiscoveryService extends AbstractDiscoveryService implements ApplianceStatusListener {
|
public class MieleApplianceDiscoveryService extends AbstractDiscoveryService implements DiscoveryListener {
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(MieleApplianceDiscoveryService.class);
|
private final Logger logger = LoggerFactory.getLogger(MieleApplianceDiscoveryService.class);
|
||||||
|
|
||||||
@ -61,13 +59,13 @@ public class MieleApplianceDiscoveryService extends AbstractDiscoveryService imp
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void activate() {
|
public void activate() {
|
||||||
mieleBridgeHandler.registerApplianceStatusListener(this);
|
mieleBridgeHandler.registerDiscoveryListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deactivate() {
|
public void deactivate() {
|
||||||
removeOlderResults(new Date().getTime());
|
removeOlderResults(new Date().getTime());
|
||||||
mieleBridgeHandler.unregisterApplianceStatusListener(this);
|
mieleBridgeHandler.unregisterDiscoveryListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -77,7 +75,7 @@ public class MieleApplianceDiscoveryService extends AbstractDiscoveryService imp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startScan() {
|
public void startScan() {
|
||||||
List<HomeDevice> appliances = mieleBridgeHandler.getHomeDevices();
|
List<HomeDevice> appliances = mieleBridgeHandler.getHomeDevicesEmptyOnFailure();
|
||||||
for (HomeDevice l : appliances) {
|
for (HomeDevice l : appliances) {
|
||||||
onApplianceAddedInternal(l);
|
onApplianceAddedInternal(l);
|
||||||
}
|
}
|
||||||
@ -146,16 +144,6 @@ public class MieleApplianceDiscoveryService extends AbstractDiscoveryService imp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onApplianceStateChanged(FullyQualifiedApplianceIdentifier applianceIdentifier, DeviceClassObject dco) {
|
|
||||||
// nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAppliancePropertyChanged(FullyQualifiedApplianceIdentifier applianceIdentifier, DeviceProperty dp) {
|
|
||||||
// nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
private @Nullable ThingUID getThingUID(HomeDevice appliance) {
|
private @Nullable ThingUID getThingUID(HomeDevice appliance) {
|
||||||
ThingUID bridgeUID = mieleBridgeHandler.getThing().getUID();
|
ThingUID bridgeUID = mieleBridgeHandler.getThing().getUID();
|
||||||
String modelId = appliance.getDeviceClass();
|
String modelId = appliance.getDeviceClass();
|
||||||
|
@ -64,7 +64,7 @@ public interface ApplianceChannelSelector {
|
|||||||
* @param dmd - the device meta data
|
* @param dmd - the device meta data
|
||||||
* @param translationProvider {@link MieleTranslationProvider} instance
|
* @param translationProvider {@link MieleTranslationProvider} instance
|
||||||
*/
|
*/
|
||||||
State getState(String s, @Nullable DeviceMetaData dmd, @Nullable MieleTranslationProvider translationProvider);
|
State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a State for the given string, taking into
|
* Returns a State for the given string, taking into
|
||||||
|
@ -13,15 +13,13 @@
|
|||||||
package org.openhab.binding.miele.internal.handler;
|
package org.openhab.binding.miele.internal.handler;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier;
|
|
||||||
import org.openhab.binding.miele.internal.api.dto.DeviceClassObject;
|
import org.openhab.binding.miele.internal.api.dto.DeviceClassObject;
|
||||||
import org.openhab.binding.miele.internal.api.dto.DeviceProperty;
|
import org.openhab.binding.miele.internal.api.dto.DeviceProperty;
|
||||||
import org.openhab.binding.miele.internal.api.dto.HomeDevice;
|
import org.openhab.binding.miele.internal.api.dto.HomeDevice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* The {@link ApplianceStatusListener} is notified when the status for the subscribed
|
||||||
* The {@link ApplianceStatusListener} is notified when an appliance status has changed or
|
* appliance has changed or it 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)
|
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
||||||
@ -32,30 +30,26 @@ 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 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(FullyQualifiedApplianceIdentifier applianceIdentifier, DeviceClassObject dco);
|
void onApplianceStateChanged(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 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(FullyQualifiedApplianceIdentifier applianceIdentifier, DeviceProperty dp);
|
void onAppliancePropertyChanged(DeviceProperty dp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called whenever an appliance is removed.
|
* This method is called whenever an appliance is removed.
|
||||||
*
|
|
||||||
* @param appliance The XGW homedevice definition of the appliance that was removed
|
|
||||||
*/
|
*/
|
||||||
void onApplianceRemoved(HomeDevice appliance);
|
void onApplianceRemoved();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called whenever an appliance is added.
|
* This method is called whenever an appliance is added.
|
||||||
*
|
*
|
||||||
* @param appliance The XGW homedevice definition of the appliance that was removed
|
* @param appliance The XGW homedevice definition of the appliance that was added
|
||||||
*/
|
*/
|
||||||
void onApplianceAdded(HomeDevice appliance);
|
void onApplianceAdded(HomeDevice appliance);
|
||||||
}
|
}
|
||||||
|
@ -45,16 +45,14 @@ public enum CoffeeMachineChannelSelector implements ApplianceChannelSelector {
|
|||||||
DEVICE_TYPE("mieleDeviceType", "deviceType", StringType.class, true),
|
DEVICE_TYPE("mieleDeviceType", "deviceType", StringType.class, true),
|
||||||
STATE_TEXT(STATE_PROPERTY_NAME, STATE_TEXT_CHANNEL_ID, StringType.class, false) {
|
STATE_TEXT(STATE_PROPERTY_NAME, STATE_TEXT_CHANNEL_ID, StringType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return DeviceUtil.getStateTextState(s, dmd, translationProvider);
|
return DeviceUtil.getStateTextState(s, dmd, translationProvider);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
STATE("", STATE_CHANNEL_ID, DecimalType.class, false),
|
STATE("", STATE_CHANNEL_ID, DecimalType.class, false),
|
||||||
PROGRAM_TEXT(PROGRAM_ID_PROPERTY_NAME, PROGRAM_TEXT_CHANNEL_ID, StringType.class, false) {
|
PROGRAM_TEXT(PROGRAM_ID_PROPERTY_NAME, PROGRAM_TEXT_CHANNEL_ID, StringType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return DeviceUtil.getTextState(s, dmd, translationProvider, PROGRAMS, MISSING_PROGRAM_TEXT_PREFIX,
|
return DeviceUtil.getTextState(s, dmd, translationProvider, PROGRAMS, MISSING_PROGRAM_TEXT_PREFIX,
|
||||||
MIELE_COFFEE_MACHINE_TEXT_PREFIX);
|
MIELE_COFFEE_MACHINE_TEXT_PREFIX);
|
||||||
}
|
}
|
||||||
@ -63,8 +61,7 @@ public enum CoffeeMachineChannelSelector implements ApplianceChannelSelector {
|
|||||||
PROGRAMTYPE("programType", "type", StringType.class, false),
|
PROGRAMTYPE("programType", "type", StringType.class, false),
|
||||||
PROGRAM_PHASE_TEXT(PHASE_PROPERTY_NAME, PHASE_TEXT_CHANNEL_ID, StringType.class, false) {
|
PROGRAM_PHASE_TEXT(PHASE_PROPERTY_NAME, PHASE_TEXT_CHANNEL_ID, StringType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return DeviceUtil.getTextState(s, dmd, translationProvider, PHASES, MISSING_PHASE_TEXT_PREFIX,
|
return DeviceUtil.getTextState(s, dmd, translationProvider, PHASES, MISSING_PHASE_TEXT_PREFIX,
|
||||||
MIELE_COFFEE_MACHINE_TEXT_PREFIX);
|
MIELE_COFFEE_MACHINE_TEXT_PREFIX);
|
||||||
}
|
}
|
||||||
@ -73,8 +70,7 @@ public enum CoffeeMachineChannelSelector implements ApplianceChannelSelector {
|
|||||||
// lightingStatus signalFailure signalInfo
|
// lightingStatus signalFailure signalInfo
|
||||||
DOOR("signalDoor", "door", OpenClosedType.class, false) {
|
DOOR("signalDoor", "door", OpenClosedType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
if ("true".equals(s)) {
|
if ("true".equals(s)) {
|
||||||
return getState("OPEN");
|
return getState("OPEN");
|
||||||
}
|
}
|
||||||
@ -133,8 +129,7 @@ public enum CoffeeMachineChannelSelector implements ApplianceChannelSelector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return this.getState(s, dmd);
|
return this.getState(s, dmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +158,7 @@ public enum CoffeeMachineChannelSelector implements ApplianceChannelSelector {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("An exception occurred while converting '{}' into a State", s);
|
logger.warn("An exception occurred while converting '{}' into a State", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return UnDefType.UNDEF;
|
return UnDefType.UNDEF;
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
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.MIELE_DEVICE_CLASS_COFFEE_SYSTEM;
|
import static org.openhab.binding.miele.internal.MieleBindingConstants.MIELE_DEVICE_CLASS_COFFEE_SYSTEM;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -52,7 +51,7 @@ public class CoffeeMachineHandler extends MieleApplianceHandler<CoffeeMachineCha
|
|||||||
super.handleCommand(channelUID, command);
|
super.handleCommand(channelUID, command);
|
||||||
|
|
||||||
String channelID = channelUID.getId();
|
String channelID = channelUID.getId();
|
||||||
String applianceId = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
String applianceId = this.applianceId;
|
||||||
if (applianceId == null) {
|
if (applianceId == null) {
|
||||||
logger.warn("Command '{}' failed, appliance id is unknown", command);
|
logger.warn("Command '{}' failed, appliance id is unknown", command);
|
||||||
return;
|
return;
|
||||||
@ -64,7 +63,7 @@ public class CoffeeMachineHandler extends MieleApplianceHandler<CoffeeMachineCha
|
|||||||
try {
|
try {
|
||||||
switch (selector) {
|
switch (selector) {
|
||||||
case SWITCH: {
|
case SWITCH: {
|
||||||
MieleBridgeHandler bridgeHandler = this.bridgeHandler;
|
MieleBridgeHandler bridgeHandler = getMieleBridgeHandler();
|
||||||
if (bridgeHandler == null) {
|
if (bridgeHandler == null) {
|
||||||
logger.warn("Command '{}' failed, missing bridge handler", command);
|
logger.warn("Command '{}' failed, missing bridge handler", command);
|
||||||
return;
|
return;
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2010-2022 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.handler;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.openhab.binding.miele.internal.api.dto.HomeDevice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link DiscoveryListener} is notified when any appliance has been removed or added.
|
||||||
|
*
|
||||||
|
* @author Jacob Laursen - Initial contribution
|
||||||
|
*/
|
||||||
|
@NonNullByDefault
|
||||||
|
public interface DiscoveryListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called whenever any appliance is removed.
|
||||||
|
*
|
||||||
|
* @param appliance The XGW homedevice definition of the appliance that was removed
|
||||||
|
*/
|
||||||
|
void onApplianceRemoved(HomeDevice appliance);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called whenever any appliance is added.
|
||||||
|
*
|
||||||
|
* @param appliance The XGW homedevice definition of the appliance that was added
|
||||||
|
*/
|
||||||
|
void onApplianceAdded(HomeDevice appliance);
|
||||||
|
}
|
@ -12,7 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
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.MIELE_DEVICE_CLASS_DISHWASHER;
|
import static org.openhab.binding.miele.internal.MieleBindingConstants.MIELE_DEVICE_CLASS_DISHWASHER;
|
||||||
import static org.openhab.binding.miele.internal.MieleBindingConstants.POWER_CONSUMPTION_CHANNEL_ID;
|
import static org.openhab.binding.miele.internal.MieleBindingConstants.POWER_CONSUMPTION_CHANNEL_ID;
|
||||||
import static org.openhab.binding.miele.internal.MieleBindingConstants.WATER_CONSUMPTION_CHANNEL_ID;
|
import static org.openhab.binding.miele.internal.MieleBindingConstants.WATER_CONSUMPTION_CHANNEL_ID;
|
||||||
@ -63,7 +62,7 @@ public class DishWasherHandler extends MieleApplianceHandler<DishwasherChannelSe
|
|||||||
super.handleCommand(channelUID, command);
|
super.handleCommand(channelUID, command);
|
||||||
|
|
||||||
String channelID = channelUID.getId();
|
String channelID = channelUID.getId();
|
||||||
String applianceId = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
String applianceId = this.applianceId;
|
||||||
if (applianceId == null) {
|
if (applianceId == null) {
|
||||||
logger.warn("Command '{}' failed, appliance id is unknown", command);
|
logger.warn("Command '{}' failed, appliance id is unknown", command);
|
||||||
return;
|
return;
|
||||||
@ -75,7 +74,7 @@ public class DishWasherHandler extends MieleApplianceHandler<DishwasherChannelSe
|
|||||||
try {
|
try {
|
||||||
switch (selector) {
|
switch (selector) {
|
||||||
case SWITCH: {
|
case SWITCH: {
|
||||||
MieleBridgeHandler bridgeHandler = this.bridgeHandler;
|
MieleBridgeHandler bridgeHandler = getMieleBridgeHandler();
|
||||||
if (bridgeHandler == null) {
|
if (bridgeHandler == null) {
|
||||||
logger.warn("Command '{}' failed, missing bridge handler", command);
|
logger.warn("Command '{}' failed, missing bridge handler", command);
|
||||||
return;
|
return;
|
||||||
|
@ -52,16 +52,14 @@ public enum DishwasherChannelSelector implements ApplianceChannelSelector {
|
|||||||
DEVICE_TYPE("mieleDeviceType", "deviceType", StringType.class, true, false),
|
DEVICE_TYPE("mieleDeviceType", "deviceType", StringType.class, true, false),
|
||||||
STATE_TEXT(STATE_PROPERTY_NAME, STATE_TEXT_CHANNEL_ID, StringType.class, false, false) {
|
STATE_TEXT(STATE_PROPERTY_NAME, STATE_TEXT_CHANNEL_ID, StringType.class, false, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return DeviceUtil.getStateTextState(s, dmd, translationProvider);
|
return DeviceUtil.getStateTextState(s, dmd, translationProvider);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
STATE("", STATE_CHANNEL_ID, DecimalType.class, false, false),
|
STATE("", STATE_CHANNEL_ID, DecimalType.class, false, false),
|
||||||
PROGRAM_TEXT(PROGRAM_ID_PROPERTY_NAME, PROGRAM_TEXT_CHANNEL_ID, StringType.class, false, false) {
|
PROGRAM_TEXT(PROGRAM_ID_PROPERTY_NAME, PROGRAM_TEXT_CHANNEL_ID, StringType.class, false, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return DeviceUtil.getTextState(s, dmd, translationProvider, PROGRAMS, MISSING_PROGRAM_TEXT_PREFIX,
|
return DeviceUtil.getTextState(s, dmd, translationProvider, PROGRAMS, MISSING_PROGRAM_TEXT_PREFIX,
|
||||||
MIELE_DISHWASHER_TEXT_PREFIX);
|
MIELE_DISHWASHER_TEXT_PREFIX);
|
||||||
}
|
}
|
||||||
@ -69,8 +67,7 @@ public enum DishwasherChannelSelector implements ApplianceChannelSelector {
|
|||||||
PROGRAM("", PROGRAM_CHANNEL_ID, DecimalType.class, false, false),
|
PROGRAM("", PROGRAM_CHANNEL_ID, DecimalType.class, false, false),
|
||||||
PROGRAM_PHASE_TEXT(PHASE_PROPERTY_NAME, PHASE_TEXT_CHANNEL_ID, StringType.class, false, false) {
|
PROGRAM_PHASE_TEXT(PHASE_PROPERTY_NAME, PHASE_TEXT_CHANNEL_ID, StringType.class, false, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return DeviceUtil.getTextState(s, dmd, translationProvider, PHASES, MISSING_PHASE_TEXT_PREFIX,
|
return DeviceUtil.getTextState(s, dmd, translationProvider, PHASES, MISSING_PHASE_TEXT_PREFIX,
|
||||||
MIELE_DISHWASHER_TEXT_PREFIX);
|
MIELE_DISHWASHER_TEXT_PREFIX);
|
||||||
}
|
}
|
||||||
@ -78,8 +75,7 @@ public enum DishwasherChannelSelector implements ApplianceChannelSelector {
|
|||||||
PROGRAM_PHASE(RAW_PHASE_PROPERTY_NAME, PHASE_CHANNEL_ID, DecimalType.class, false, false),
|
PROGRAM_PHASE(RAW_PHASE_PROPERTY_NAME, PHASE_CHANNEL_ID, DecimalType.class, false, false),
|
||||||
START_TIME("startTime", "start", DateTimeType.class, false, false) {
|
START_TIME("startTime", "start", DateTimeType.class, false, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
||||||
@ -93,8 +89,7 @@ public enum DishwasherChannelSelector implements ApplianceChannelSelector {
|
|||||||
},
|
},
|
||||||
DURATION("duration", "duration", DateTimeType.class, false, false) {
|
DURATION("duration", "duration", DateTimeType.class, false, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
||||||
@ -108,8 +103,7 @@ public enum DishwasherChannelSelector implements ApplianceChannelSelector {
|
|||||||
},
|
},
|
||||||
ELAPSED_TIME("elapsedTime", "elapsed", DateTimeType.class, false, false) {
|
ELAPSED_TIME("elapsedTime", "elapsed", DateTimeType.class, false, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
||||||
@ -123,8 +117,7 @@ public enum DishwasherChannelSelector implements ApplianceChannelSelector {
|
|||||||
},
|
},
|
||||||
FINISH_TIME("finishTime", "finish", DateTimeType.class, false, false) {
|
FINISH_TIME("finishTime", "finish", DateTimeType.class, false, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
||||||
@ -138,8 +131,7 @@ public enum DishwasherChannelSelector implements ApplianceChannelSelector {
|
|||||||
},
|
},
|
||||||
DOOR("signalDoor", "door", OpenClosedType.class, false, false) {
|
DOOR("signalDoor", "door", OpenClosedType.class, false, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
if ("true".equals(s)) {
|
if ("true".equals(s)) {
|
||||||
return getState("OPEN");
|
return getState("OPEN");
|
||||||
}
|
}
|
||||||
@ -208,8 +200,7 @@ public enum DishwasherChannelSelector implements ApplianceChannelSelector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return this.getState(s, dmd);
|
return this.getState(s, dmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +229,7 @@ public enum DishwasherChannelSelector implements ApplianceChannelSelector {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("An exception occurred while converting '{}' into a State", s);
|
logger.warn("An exception occurred while converting '{}' into a State", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return UnDefType.UNDEF;
|
return UnDefType.UNDEF;
|
||||||
|
@ -45,8 +45,7 @@ public enum FridgeChannelSelector implements ApplianceChannelSelector {
|
|||||||
DEVICE_TYPE("mieleDeviceType", "deviceType", StringType.class, true),
|
DEVICE_TYPE("mieleDeviceType", "deviceType", StringType.class, true),
|
||||||
STATE_TEXT(STATE_PROPERTY_NAME, STATE_TEXT_CHANNEL_ID, StringType.class, false) {
|
STATE_TEXT(STATE_PROPERTY_NAME, STATE_TEXT_CHANNEL_ID, StringType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return DeviceUtil.getStateTextState(s, dmd, translationProvider);
|
return DeviceUtil.getStateTextState(s, dmd, translationProvider);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -54,23 +53,20 @@ public enum FridgeChannelSelector implements ApplianceChannelSelector {
|
|||||||
SUPERCOOL("", SUPERCOOL_CHANNEL_ID, OnOffType.class, false),
|
SUPERCOOL("", SUPERCOOL_CHANNEL_ID, OnOffType.class, false),
|
||||||
FRIDGECURRENTTEMP("currentTemperature", "current", QuantityType.class, false) {
|
FRIDGECURRENTTEMP("currentTemperature", "current", QuantityType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return getTemperatureState(s);
|
return getTemperatureState(s);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
FRIDGETARGETTEMP("targetTemperature", "target", QuantityType.class, false) {
|
FRIDGETARGETTEMP("targetTemperature", "target", QuantityType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return getTemperatureState(s);
|
return getTemperatureState(s);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DOOR("signalDoor", "door", OpenClosedType.class, false) {
|
DOOR("signalDoor", "door", OpenClosedType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
|
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
if ("true".equals(s)) {
|
if ("true".equals(s)) {
|
||||||
return getState("OPEN");
|
return getState("OPEN");
|
||||||
}
|
}
|
||||||
@ -124,8 +120,7 @@ public enum FridgeChannelSelector implements ApplianceChannelSelector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return this.getState(s, dmd);
|
return this.getState(s, dmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +149,7 @@ public enum FridgeChannelSelector implements ApplianceChannelSelector {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("An exception occurred while converting '{}' into a State", s);
|
logger.warn("An exception occurred while converting '{}' into a State", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return UnDefType.UNDEF;
|
return UnDefType.UNDEF;
|
||||||
|
@ -46,8 +46,7 @@ public enum FridgeFreezerChannelSelector implements ApplianceChannelSelector {
|
|||||||
DEVICE_TYPE("mieleDeviceType", "deviceType", StringType.class, true),
|
DEVICE_TYPE("mieleDeviceType", "deviceType", StringType.class, true),
|
||||||
STATE_TEXT(STATE_PROPERTY_NAME, STATE_TEXT_CHANNEL_ID, StringType.class, false) {
|
STATE_TEXT(STATE_PROPERTY_NAME, STATE_TEXT_CHANNEL_ID, StringType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return DeviceUtil.getStateTextState(s, dmd, translationProvider);
|
return DeviceUtil.getStateTextState(s, dmd, translationProvider);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -58,36 +57,31 @@ public enum FridgeFreezerChannelSelector implements ApplianceChannelSelector {
|
|||||||
SUPERFREEZE("", SUPERFREEZE_CHANNEL_ID, OnOffType.class, false),
|
SUPERFREEZE("", SUPERFREEZE_CHANNEL_ID, OnOffType.class, false),
|
||||||
FREEZERCURRENTTEMP("freezerCurrentTemperature", "freezercurrent", QuantityType.class, false) {
|
FREEZERCURRENTTEMP("freezerCurrentTemperature", "freezercurrent", QuantityType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return getTemperatureState(s);
|
return getTemperatureState(s);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
FREEZERTARGETTEMP("freezerTargetTemperature", "freezertarget", QuantityType.class, false) {
|
FREEZERTARGETTEMP("freezerTargetTemperature", "freezertarget", QuantityType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return getTemperatureState(s);
|
return getTemperatureState(s);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
FRIDGECURRENTTEMP("fridgeCurrentTemperature", "fridgecurrent", QuantityType.class, false) {
|
FRIDGECURRENTTEMP("fridgeCurrentTemperature", "fridgecurrent", QuantityType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return getTemperatureState(s);
|
return getTemperatureState(s);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
FRIDGETARGETTEMP("fridgeTargetTemperature", "fridgetarget", QuantityType.class, false) {
|
FRIDGETARGETTEMP("fridgeTargetTemperature", "fridgetarget", QuantityType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return getTemperatureState(s);
|
return getTemperatureState(s);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DOOR("signalDoor", "door", OpenClosedType.class, false) {
|
DOOR("signalDoor", "door", OpenClosedType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
if ("true".equals(s)) {
|
if ("true".equals(s)) {
|
||||||
return getState("OPEN");
|
return getState("OPEN");
|
||||||
}
|
}
|
||||||
@ -142,8 +136,7 @@ public enum FridgeFreezerChannelSelector implements ApplianceChannelSelector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return this.getState(s, dmd);
|
return this.getState(s, dmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +165,7 @@ public enum FridgeFreezerChannelSelector implements ApplianceChannelSelector {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("An exception occurred while converting '{}' into a State", s);
|
logger.warn("An exception occurred while converting '{}' into a State", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return UnDefType.UNDEF;
|
return UnDefType.UNDEF;
|
||||||
|
@ -52,7 +52,7 @@ public class FridgeFreezerHandler extends MieleApplianceHandler<FridgeFreezerCha
|
|||||||
super.handleCommand(channelUID, command);
|
super.handleCommand(channelUID, command);
|
||||||
|
|
||||||
String channelID = channelUID.getId();
|
String channelID = channelUID.getId();
|
||||||
String applianceId = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
String applianceId = this.applianceId;
|
||||||
if (applianceId == null) {
|
if (applianceId == null) {
|
||||||
logger.warn("Command '{}' failed, appliance id is unknown", command);
|
logger.warn("Command '{}' failed, appliance id is unknown", command);
|
||||||
return;
|
return;
|
||||||
@ -62,7 +62,7 @@ public class FridgeFreezerHandler extends MieleApplianceHandler<FridgeFreezerCha
|
|||||||
JsonElement result = null;
|
JsonElement result = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MieleBridgeHandler bridgeHandler = this.bridgeHandler;
|
MieleBridgeHandler bridgeHandler = getMieleBridgeHandler();
|
||||||
if (bridgeHandler == null) {
|
if (bridgeHandler == null) {
|
||||||
logger.warn("Command '{}' failed, missing bridge handler", command);
|
logger.warn("Command '{}' failed, missing bridge handler", command);
|
||||||
return;
|
return;
|
||||||
@ -108,7 +108,7 @@ public class FridgeFreezerHandler extends MieleApplianceHandler<FridgeFreezerCha
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onAppliancePropertyChanged(DeviceProperty dp) {
|
public void onAppliancePropertyChanged(DeviceProperty dp) {
|
||||||
super.onAppliancePropertyChanged(dp);
|
super.onAppliancePropertyChanged(dp);
|
||||||
|
|
||||||
if (!STATE_PROPERTY_NAME.equals(dp.Name)) {
|
if (!STATE_PROPERTY_NAME.equals(dp.Name)) {
|
||||||
|
@ -52,7 +52,7 @@ public class FridgeHandler extends MieleApplianceHandler<FridgeChannelSelector>
|
|||||||
super.handleCommand(channelUID, command);
|
super.handleCommand(channelUID, command);
|
||||||
|
|
||||||
String channelID = channelUID.getId();
|
String channelID = channelUID.getId();
|
||||||
String applianceId = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
String applianceId = this.applianceId;
|
||||||
if (applianceId == null) {
|
if (applianceId == null) {
|
||||||
logger.warn("Command '{}' failed, appliance id is unknown", command);
|
logger.warn("Command '{}' failed, appliance id is unknown", command);
|
||||||
return;
|
return;
|
||||||
@ -62,7 +62,7 @@ public class FridgeHandler extends MieleApplianceHandler<FridgeChannelSelector>
|
|||||||
JsonElement result = null;
|
JsonElement result = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MieleBridgeHandler bridgeHandler = this.bridgeHandler;
|
MieleBridgeHandler bridgeHandler = getMieleBridgeHandler();
|
||||||
if (bridgeHandler == null) {
|
if (bridgeHandler == null) {
|
||||||
logger.warn("Command '{}' failed, missing bridge handler", command);
|
logger.warn("Command '{}' failed, missing bridge handler", command);
|
||||||
return;
|
return;
|
||||||
@ -109,7 +109,7 @@ public class FridgeHandler extends MieleApplianceHandler<FridgeChannelSelector>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onAppliancePropertyChanged(DeviceProperty dp) {
|
public void onAppliancePropertyChanged(DeviceProperty dp) {
|
||||||
super.onAppliancePropertyChanged(dp);
|
super.onAppliancePropertyChanged(dp);
|
||||||
|
|
||||||
if (!STATE_PROPERTY_NAME.equals(dp.Name)) {
|
if (!STATE_PROPERTY_NAME.equals(dp.Name)) {
|
||||||
|
@ -42,8 +42,7 @@ public enum HobChannelSelector implements ApplianceChannelSelector {
|
|||||||
DEVICE_TYPE("mieleDeviceType", "deviceType", StringType.class, true),
|
DEVICE_TYPE("mieleDeviceType", "deviceType", StringType.class, true),
|
||||||
STATE_TEXT(STATE_PROPERTY_NAME, STATE_TEXT_CHANNEL_ID, StringType.class, false) {
|
STATE_TEXT(STATE_PROPERTY_NAME, STATE_TEXT_CHANNEL_ID, StringType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return DeviceUtil.getStateTextState(s, dmd, translationProvider);
|
return DeviceUtil.getStateTextState(s, dmd, translationProvider);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -52,8 +51,7 @@ public enum HobChannelSelector implements ApplianceChannelSelector {
|
|||||||
PLATE1_POWER("plate1PowerStep", "plate1power", DecimalType.class, false),
|
PLATE1_POWER("plate1PowerStep", "plate1power", DecimalType.class, false),
|
||||||
PLATE1_HEAT("plate1RemainingHeat", "plate1heat", DecimalType.class, false) {
|
PLATE1_HEAT("plate1RemainingHeat", "plate1heat", DecimalType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
// If there is remaining heat, the device metadata contains some informative string which can not be
|
// If there is remaining heat, the device metadata contains some informative string which can not be
|
||||||
// converted into a DecimalType. We therefore ignore the metadata and return the device property value as a
|
// converted into a DecimalType. We therefore ignore the metadata and return the device property value as a
|
||||||
// State
|
// State
|
||||||
@ -64,8 +62,7 @@ public enum HobChannelSelector implements ApplianceChannelSelector {
|
|||||||
PLATE2_POWER("plate2PowerStep", "plate2power", DecimalType.class, false),
|
PLATE2_POWER("plate2PowerStep", "plate2power", DecimalType.class, false),
|
||||||
PLATE2_HEAT("plate2RemainingHeat", "plate2heat", DecimalType.class, false) {
|
PLATE2_HEAT("plate2RemainingHeat", "plate2heat", DecimalType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return getState(s);
|
return getState(s);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -73,8 +70,7 @@ public enum HobChannelSelector implements ApplianceChannelSelector {
|
|||||||
PLATE3_POWER("plate3PowerStep", "plate3power", DecimalType.class, false),
|
PLATE3_POWER("plate3PowerStep", "plate3power", DecimalType.class, false),
|
||||||
PLATE3_HEAT("plate3RemainingHeat", "plate3heat", DecimalType.class, false) {
|
PLATE3_HEAT("plate3RemainingHeat", "plate3heat", DecimalType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return getState(s);
|
return getState(s);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -82,8 +78,7 @@ public enum HobChannelSelector implements ApplianceChannelSelector {
|
|||||||
PLATE4_POWER("plate4PowerStep", "plate4power", DecimalType.class, false),
|
PLATE4_POWER("plate4PowerStep", "plate4power", DecimalType.class, false),
|
||||||
PLATE4_HEAT("plate4RemainingHeat", "plate4heat", DecimalType.class, false) {
|
PLATE4_HEAT("plate4RemainingHeat", "plate4heat", DecimalType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return getState(s);
|
return getState(s);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -91,8 +86,7 @@ public enum HobChannelSelector implements ApplianceChannelSelector {
|
|||||||
PLATE5_POWER("plate5PowerStep", "plate5power", DecimalType.class, false),
|
PLATE5_POWER("plate5PowerStep", "plate5power", DecimalType.class, false),
|
||||||
PLATE5_HEAT("plate5RemainingHeat", "plate5heat", DecimalType.class, false) {
|
PLATE5_HEAT("plate5RemainingHeat", "plate5heat", DecimalType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return getState(s);
|
return getState(s);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -100,8 +94,7 @@ public enum HobChannelSelector implements ApplianceChannelSelector {
|
|||||||
PLATE6_POWER("plate6PowerStep", "plate6power", DecimalType.class, false),
|
PLATE6_POWER("plate6PowerStep", "plate6power", DecimalType.class, false),
|
||||||
PLATE6_HEAT("plate6RemainingHeat", "plate6heat", DecimalType.class, false) {
|
PLATE6_HEAT("plate6RemainingHeat", "plate6heat", DecimalType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return getState(s);
|
return getState(s);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -147,8 +140,7 @@ public enum HobChannelSelector implements ApplianceChannelSelector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return this.getState(s, dmd);
|
return this.getState(s, dmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +169,7 @@ public enum HobChannelSelector implements ApplianceChannelSelector {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("An exception occurred while converting '{}' into a State", s);
|
logger.warn("An exception occurred while converting '{}' into a State", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return UnDefType.UNDEF;
|
return UnDefType.UNDEF;
|
||||||
|
@ -43,8 +43,7 @@ public enum HoodChannelSelector implements ApplianceChannelSelector {
|
|||||||
DEVICE_TYPE("mieleDeviceType", "deviceType", StringType.class, true),
|
DEVICE_TYPE("mieleDeviceType", "deviceType", StringType.class, true),
|
||||||
STATE_TEXT(STATE_PROPERTY_NAME, STATE_TEXT_CHANNEL_ID, StringType.class, false) {
|
STATE_TEXT(STATE_PROPERTY_NAME, STATE_TEXT_CHANNEL_ID, StringType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return DeviceUtil.getStateTextState(s, dmd, translationProvider);
|
return DeviceUtil.getStateTextState(s, dmd, translationProvider);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -53,8 +52,7 @@ public enum HoodChannelSelector implements ApplianceChannelSelector {
|
|||||||
LIGHT("lightingStatus", "light", OnOffType.class, false) {
|
LIGHT("lightingStatus", "light", OnOffType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
|
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
if ("true".equals(s)) {
|
if ("true".equals(s)) {
|
||||||
return getState("ON");
|
return getState("ON");
|
||||||
}
|
}
|
||||||
@ -108,8 +106,7 @@ public enum HoodChannelSelector implements ApplianceChannelSelector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return this.getState(s, dmd);
|
return this.getState(s, dmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +135,7 @@ public enum HoodChannelSelector implements ApplianceChannelSelector {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("An exception occurred while converting '{}' into a State", s);
|
logger.warn("An exception occurred while converting '{}' into a State", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return UnDefType.UNDEF;
|
return UnDefType.UNDEF;
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
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.MIELE_DEVICE_CLASS_HOOD;
|
import static org.openhab.binding.miele.internal.MieleBindingConstants.MIELE_DEVICE_CLASS_HOOD;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -51,7 +50,7 @@ public class HoodHandler extends MieleApplianceHandler<HoodChannelSelector> {
|
|||||||
super.handleCommand(channelUID, command);
|
super.handleCommand(channelUID, command);
|
||||||
|
|
||||||
String channelID = channelUID.getId();
|
String channelID = channelUID.getId();
|
||||||
String applianceId = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
String applianceId = this.applianceId;
|
||||||
if (applianceId == null) {
|
if (applianceId == null) {
|
||||||
logger.warn("Command '{}' failed, appliance id is unknown", command);
|
logger.warn("Command '{}' failed, appliance id is unknown", command);
|
||||||
return;
|
return;
|
||||||
@ -61,7 +60,7 @@ public class HoodHandler extends MieleApplianceHandler<HoodChannelSelector> {
|
|||||||
JsonElement result = null;
|
JsonElement result = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MieleBridgeHandler bridgeHandler = this.bridgeHandler;
|
MieleBridgeHandler bridgeHandler = getMieleBridgeHandler();
|
||||||
if (bridgeHandler == null) {
|
if (bridgeHandler == null) {
|
||||||
logger.warn("Command '{}' failed, missing bridge handler", command);
|
logger.warn("Command '{}' failed, missing bridge handler", command);
|
||||||
return;
|
return;
|
||||||
|
@ -23,7 +23,6 @@ import java.util.Set;
|
|||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.miele.internal.DeviceUtil;
|
import org.openhab.binding.miele.internal.DeviceUtil;
|
||||||
import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier;
|
|
||||||
import org.openhab.binding.miele.internal.MieleTranslationProvider;
|
import org.openhab.binding.miele.internal.MieleTranslationProvider;
|
||||||
import org.openhab.binding.miele.internal.api.dto.DeviceClassObject;
|
import org.openhab.binding.miele.internal.api.dto.DeviceClassObject;
|
||||||
import org.openhab.binding.miele.internal.api.dto.DeviceMetaData;
|
import org.openhab.binding.miele.internal.api.dto.DeviceMetaData;
|
||||||
@ -35,8 +34,9 @@ import org.openhab.core.thing.Bridge;
|
|||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
import org.openhab.core.thing.ThingStatus;
|
import org.openhab.core.thing.ThingStatus;
|
||||||
import org.openhab.core.thing.ThingStatusInfo;
|
import org.openhab.core.thing.ThingStatusDetail;
|
||||||
import org.openhab.core.thing.ThingTypeUID;
|
import org.openhab.core.thing.ThingTypeUID;
|
||||||
|
import org.openhab.core.thing.ThingUID;
|
||||||
import org.openhab.core.thing.binding.BaseThingHandler;
|
import org.openhab.core.thing.binding.BaseThingHandler;
|
||||||
import org.openhab.core.thing.binding.ThingHandler;
|
import org.openhab.core.thing.binding.ThingHandler;
|
||||||
import org.openhab.core.types.Command;
|
import org.openhab.core.types.Command;
|
||||||
@ -74,10 +74,10 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
|||||||
protected Gson gson = new Gson();
|
protected Gson gson = new Gson();
|
||||||
|
|
||||||
protected @Nullable String applianceId;
|
protected @Nullable String applianceId;
|
||||||
protected @Nullable MieleBridgeHandler bridgeHandler;
|
private @Nullable MieleBridgeHandler bridgeHandler;
|
||||||
protected TranslationProvider i18nProvider;
|
protected TranslationProvider i18nProvider;
|
||||||
protected LocaleProvider localeProvider;
|
protected LocaleProvider localeProvider;
|
||||||
protected @Nullable MieleTranslationProvider translationProvider;
|
protected MieleTranslationProvider translationProvider;
|
||||||
private Class<E> selectorType;
|
private Class<E> selectorType;
|
||||||
protected String modelID;
|
protected String modelID;
|
||||||
|
|
||||||
@ -90,6 +90,7 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
|||||||
this.localeProvider = localeProvider;
|
this.localeProvider = localeProvider;
|
||||||
this.selectorType = selectorType;
|
this.selectorType = selectorType;
|
||||||
this.modelID = modelID;
|
this.modelID = modelID;
|
||||||
|
this.translationProvider = new MieleTranslationProvider(i18nProvider, localeProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplianceChannelSelector getValueSelectorFromChannelID(String valueSelectorText)
|
public ApplianceChannelSelector getValueSelectorFromChannelID(String valueSelectorText)
|
||||||
@ -128,18 +129,24 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
|||||||
public void initialize() {
|
public void initialize() {
|
||||||
logger.debug("Initializing Miele appliance handler.");
|
logger.debug("Initializing Miele appliance handler.");
|
||||||
final String applianceId = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
final String applianceId = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
||||||
if (applianceId != null) {
|
if (applianceId == null || applianceId.isBlank()) {
|
||||||
this.applianceId = applianceId;
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR,
|
||||||
this.onBridgeConnectionResumed();
|
"@text/offline.configuration-error.uid-not-set");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
this.applianceId = applianceId;
|
||||||
|
|
||||||
public void onBridgeConnectionResumed() {
|
|
||||||
Bridge bridge = getBridge();
|
Bridge bridge = getBridge();
|
||||||
if (bridge != null && getMieleBridgeHandler() != null) {
|
if (bridge == null) {
|
||||||
ThingStatusInfo statusInfo = bridge.getStatusInfo();
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR,
|
||||||
updateStatus(statusInfo.getStatus(), statusInfo.getStatusDetail(), statusInfo.getDescription());
|
"@text/offline.configuration-error.bridge-missing");
|
||||||
initializeTranslationProvider(bridge);
|
return;
|
||||||
|
}
|
||||||
|
initializeTranslationProvider(bridge);
|
||||||
|
updateStatus(ThingStatus.UNKNOWN);
|
||||||
|
|
||||||
|
MieleBridgeHandler bridgeHandler = getMieleBridgeHandler();
|
||||||
|
if (bridgeHandler != null) {
|
||||||
|
bridgeHandler.registerApplianceStatusListener(applianceId, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +157,7 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
|||||||
try {
|
try {
|
||||||
locale = new Locale.Builder().setLanguageTag(language).build();
|
locale = new Locale.Builder().setLanguageTag(language).build();
|
||||||
} catch (IllformedLocaleException e) {
|
} catch (IllformedLocaleException e) {
|
||||||
logger.error("Invalid language configured: {}", e.getMessage());
|
logger.warn("Invalid language configured: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (locale == null) {
|
if (locale == null) {
|
||||||
@ -164,10 +171,11 @@ 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.");
|
||||||
|
String applianceId = this.applianceId;
|
||||||
if (applianceId != null) {
|
if (applianceId != null) {
|
||||||
MieleBridgeHandler bridgeHandler = getMieleBridgeHandler();
|
MieleBridgeHandler bridgeHandler = getMieleBridgeHandler();
|
||||||
if (bridgeHandler != null) {
|
if (bridgeHandler != null) {
|
||||||
bridgeHandler.unregisterApplianceStatusListener(this);
|
bridgeHandler.unregisterApplianceStatusListener(applianceId, this);
|
||||||
}
|
}
|
||||||
applianceId = null;
|
applianceId = null;
|
||||||
}
|
}
|
||||||
@ -183,13 +191,7 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplianceStateChanged(FullyQualifiedApplianceIdentifier applicationIdentifier,
|
public void onApplianceStateChanged(DeviceClassObject dco) {
|
||||||
DeviceClassObject dco) {
|
|
||||||
String applianceId = this.applianceId;
|
|
||||||
if (applianceId == null || !applianceId.equals(applicationIdentifier.getApplianceId())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonArray properties = dco.Properties;
|
JsonArray properties = dco.Properties;
|
||||||
if (properties == null) {
|
if (properties == null) {
|
||||||
return;
|
return;
|
||||||
@ -205,7 +207,7 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
|||||||
dp.Value = dp.Value.trim();
|
dp.Value = dp.Value.trim();
|
||||||
dp.Value = dp.Value.strip();
|
dp.Value = dp.Value.strip();
|
||||||
}
|
}
|
||||||
onAppliancePropertyChanged(applicationIdentifier, dp);
|
onAppliancePropertyChanged(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
|
||||||
}
|
}
|
||||||
@ -213,17 +215,7 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAppliancePropertyChanged(FullyQualifiedApplianceIdentifier applicationIdentifier, DeviceProperty dp) {
|
public void onAppliancePropertyChanged(DeviceProperty dp) {
|
||||||
String applianceId = this.applianceId;
|
|
||||||
|
|
||||||
if (applianceId == null || !applianceId.equals(applicationIdentifier.getApplianceId())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.onAppliancePropertyChanged(dp);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onAppliancePropertyChanged(DeviceProperty dp) {
|
|
||||||
try {
|
try {
|
||||||
DeviceMetaData dmd = null;
|
DeviceMetaData dmd = null;
|
||||||
if (dp.Metadata == null) {
|
if (dp.Metadata == null) {
|
||||||
@ -271,24 +263,22 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
|||||||
String dpValue = dp.Value.strip().trim();
|
String dpValue = dp.Value.strip().trim();
|
||||||
|
|
||||||
if (selector != null) {
|
if (selector != null) {
|
||||||
if (!selector.isProperty()) {
|
String channelId = selector.getChannelID();
|
||||||
ChannelUID theChannelUID = new ChannelUID(getThing().getUID(), selector.getChannelID());
|
ThingUID thingUid = getThing().getUID();
|
||||||
|
State state = selector.getState(dpValue, dmd, this.translationProvider);
|
||||||
State state = selector.getState(dpValue, dmd, this.translationProvider);
|
if (selector.isProperty()) {
|
||||||
|
String value = state.toString();
|
||||||
|
logger.trace("Updating the property '{}' of '{}' to '{}'", channelId, thingUid, value);
|
||||||
|
updateProperty(channelId, value);
|
||||||
|
} else {
|
||||||
|
ChannelUID theChannelUID = new ChannelUID(thingUid, channelId);
|
||||||
logger.trace("Update state of {} with getState '{}'", theChannelUID, state);
|
logger.trace("Update state of {} with getState '{}'", theChannelUID, state);
|
||||||
updateState(theChannelUID, state);
|
updateState(theChannelUID, state);
|
||||||
updateRawChannel(dp.Name, dpValue);
|
updateRawChannel(dp.Name, dpValue);
|
||||||
} else {
|
|
||||||
logger.debug("Updating the property '{}' of '{}' to '{}'", selector.getChannelID(),
|
|
||||||
getThing().getUID(), selector.getState(dpValue, dmd, this.translationProvider).toString());
|
|
||||||
Map<String, String> properties = editProperties();
|
|
||||||
properties.put(selector.getChannelID(),
|
|
||||||
selector.getState(dpValue, dmd, this.translationProvider).toString());
|
|
||||||
updateProperties(properties);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
logger.error("An exception occurred while processing a changed device property :'{}'", e.getMessage());
|
logger.warn("An exception occurred while processing a changed device property: '{}'", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,65 +319,41 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplianceRemoved(HomeDevice appliance) {
|
public void onApplianceRemoved() {
|
||||||
String applianceId = this.applianceId;
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.GONE);
|
||||||
if (applianceId == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FullyQualifiedApplianceIdentifier applianceIdentifier = appliance.getApplianceIdentifier();
|
|
||||||
if (applianceIdentifier == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (applianceId.equals(applianceIdentifier.getApplianceId())) {
|
|
||||||
updateStatus(ThingStatus.OFFLINE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplianceAdded(HomeDevice appliance) {
|
public void onApplianceAdded(HomeDevice appliance) {
|
||||||
String applianceId = this.applianceId;
|
Map<String, String> properties = editProperties();
|
||||||
if (applianceId == null) {
|
String vendor = appliance.Vendor;
|
||||||
return;
|
if (vendor != null) {
|
||||||
|
properties.put(Thing.PROPERTY_VENDOR, vendor);
|
||||||
}
|
}
|
||||||
|
properties.put(Thing.PROPERTY_MODEL_ID, appliance.getApplianceModel());
|
||||||
FullyQualifiedApplianceIdentifier applianceIdentifier = appliance.getApplianceIdentifier();
|
properties.put(Thing.PROPERTY_SERIAL_NUMBER, appliance.getSerialNumber());
|
||||||
if (applianceIdentifier == null) {
|
properties.put(Thing.PROPERTY_FIRMWARE_VERSION, appliance.getFirmwareVersion());
|
||||||
return;
|
String protocolAdapterName = appliance.ProtocolAdapterName;
|
||||||
|
if (protocolAdapterName != null) {
|
||||||
|
properties.put(PROPERTY_PROTOCOL_ADAPTER, protocolAdapterName);
|
||||||
}
|
}
|
||||||
|
String deviceClass = appliance.getDeviceClass();
|
||||||
if (applianceId.equals(applianceIdentifier.getApplianceId())) {
|
if (deviceClass != null) {
|
||||||
Map<String, String> properties = editProperties();
|
properties.put(PROPERTY_DEVICE_CLASS, deviceClass);
|
||||||
String vendor = appliance.Vendor;
|
|
||||||
if (vendor != null) {
|
|
||||||
properties.put(Thing.PROPERTY_VENDOR, vendor);
|
|
||||||
}
|
|
||||||
properties.put(Thing.PROPERTY_MODEL_ID, appliance.getApplianceModel());
|
|
||||||
properties.put(Thing.PROPERTY_SERIAL_NUMBER, appliance.getSerialNumber());
|
|
||||||
properties.put(Thing.PROPERTY_FIRMWARE_VERSION, appliance.getFirmwareVersion());
|
|
||||||
String protocolAdapterName = appliance.ProtocolAdapterName;
|
|
||||||
if (protocolAdapterName != null) {
|
|
||||||
properties.put(PROPERTY_PROTOCOL_ADAPTER, protocolAdapterName);
|
|
||||||
}
|
|
||||||
String deviceClass = appliance.getDeviceClass();
|
|
||||||
if (deviceClass != null) {
|
|
||||||
properties.put(PROPERTY_DEVICE_CLASS, deviceClass);
|
|
||||||
}
|
|
||||||
String connectionType = appliance.getConnectionType();
|
|
||||||
if (connectionType != null) {
|
|
||||||
properties.put(PROPERTY_CONNECTION_TYPE, connectionType);
|
|
||||||
}
|
|
||||||
String connectionBaudRate = appliance.getConnectionBaudRate();
|
|
||||||
if (connectionBaudRate != null) {
|
|
||||||
properties.put(PROPERTY_CONNECTION_BAUD_RATE, connectionBaudRate);
|
|
||||||
}
|
|
||||||
updateProperties(properties);
|
|
||||||
updateStatus(ThingStatus.ONLINE);
|
|
||||||
}
|
}
|
||||||
|
String connectionType = appliance.getConnectionType();
|
||||||
|
if (connectionType != null) {
|
||||||
|
properties.put(PROPERTY_CONNECTION_TYPE, connectionType);
|
||||||
|
}
|
||||||
|
String connectionBaudRate = appliance.getConnectionBaudRate();
|
||||||
|
if (connectionBaudRate != null) {
|
||||||
|
properties.put(PROPERTY_CONNECTION_BAUD_RATE, connectionBaudRate);
|
||||||
|
}
|
||||||
|
updateProperties(properties);
|
||||||
|
updateStatus(ThingStatus.ONLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized @Nullable MieleBridgeHandler getMieleBridgeHandler() {
|
protected synchronized @Nullable MieleBridgeHandler getMieleBridgeHandler() {
|
||||||
if (this.bridgeHandler == null) {
|
if (this.bridgeHandler == null) {
|
||||||
Bridge bridge = getBridge();
|
Bridge bridge = getBridge();
|
||||||
if (bridge == null) {
|
if (bridge == null) {
|
||||||
@ -395,11 +361,7 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
|||||||
}
|
}
|
||||||
ThingHandler handler = bridge.getHandler();
|
ThingHandler handler = bridge.getHandler();
|
||||||
if (handler instanceof MieleBridgeHandler) {
|
if (handler instanceof MieleBridgeHandler) {
|
||||||
var bridgeHandler = (MieleBridgeHandler) handler;
|
this.bridgeHandler = (MieleBridgeHandler) handler;
|
||||||
this.bridgeHandler = bridgeHandler;
|
|
||||||
bridgeHandler.registerApplianceStatusListener(this);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.bridgeHandler;
|
return this.bridgeHandler;
|
||||||
|
@ -14,43 +14,33 @@ package org.openhab.binding.miele.internal.handler;
|
|||||||
|
|
||||||
import static org.openhab.binding.miele.internal.MieleBindingConstants.*;
|
import static org.openhab.binding.miele.internal.MieleBindingConstants.*;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.StringReader;
|
|
||||||
import java.net.DatagramPacket;
|
import java.net.DatagramPacket;
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.MulticastSocket;
|
import java.net.MulticastSocket;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
import java.net.URL;
|
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.IllformedLocaleException;
|
import java.util.IllformedLocaleException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Random;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.zip.GZIPInputStream;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier;
|
import org.openhab.binding.miele.internal.FullyQualifiedApplianceIdentifier;
|
||||||
|
import org.openhab.binding.miele.internal.MieleGatewayCommunicationController;
|
||||||
import org.openhab.binding.miele.internal.api.dto.DeviceClassObject;
|
import org.openhab.binding.miele.internal.api.dto.DeviceClassObject;
|
||||||
import org.openhab.binding.miele.internal.api.dto.DeviceProperty;
|
import org.openhab.binding.miele.internal.api.dto.DeviceProperty;
|
||||||
import org.openhab.binding.miele.internal.api.dto.HomeDevice;
|
import org.openhab.binding.miele.internal.api.dto.HomeDevice;
|
||||||
@ -59,7 +49,6 @@ import org.openhab.core.common.NamedThreadFactory;
|
|||||||
import org.openhab.core.config.core.Configuration;
|
import org.openhab.core.config.core.Configuration;
|
||||||
import org.openhab.core.thing.Bridge;
|
import org.openhab.core.thing.Bridge;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
import org.openhab.core.thing.Thing;
|
|
||||||
import org.openhab.core.thing.ThingStatus;
|
import org.openhab.core.thing.ThingStatus;
|
||||||
import org.openhab.core.thing.ThingStatusDetail;
|
import org.openhab.core.thing.ThingStatusDetail;
|
||||||
import org.openhab.core.thing.ThingTypeUID;
|
import org.openhab.core.thing.ThingTypeUID;
|
||||||
@ -70,11 +59,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link MieleBridgeHandler} is responsible for handling commands, which are
|
* The {@link MieleBridgeHandler} is responsible for handling commands, which are
|
||||||
@ -93,26 +78,26 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
|
|||||||
private static final Pattern IP_PATTERN = Pattern
|
private static final Pattern IP_PATTERN = Pattern
|
||||||
.compile("^(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])$");
|
.compile("^(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])$");
|
||||||
|
|
||||||
protected static final int POLLING_PERIOD = 15; // in seconds
|
private static final int POLLING_PERIOD = 15; // in seconds
|
||||||
protected static final int JSON_RPC_PORT = 2810;
|
private static final int JSON_RPC_PORT = 2810;
|
||||||
protected static final String JSON_RPC_MULTICAST_IP1 = "239.255.68.139";
|
private static final String JSON_RPC_MULTICAST_IP1 = "239.255.68.139";
|
||||||
protected static final String JSON_RPC_MULTICAST_IP2 = "224.255.68.139";
|
private static final String JSON_RPC_MULTICAST_IP2 = "224.255.68.139";
|
||||||
private boolean lastBridgeConnectionState = false;
|
|
||||||
private boolean currentBridgeConnectionState = false;
|
|
||||||
|
|
||||||
protected Random rand = new Random();
|
|
||||||
protected Gson gson = new Gson();
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(MieleBridgeHandler.class);
|
private final Logger logger = LoggerFactory.getLogger(MieleBridgeHandler.class);
|
||||||
|
|
||||||
protected List<ApplianceStatusListener> applianceStatusListeners = new CopyOnWriteArrayList<>();
|
private boolean lastBridgeConnectionState = false;
|
||||||
protected @Nullable ScheduledFuture<?> pollingJob;
|
|
||||||
protected @Nullable ExecutorService executor;
|
|
||||||
protected @Nullable Future<?> eventListenerJob;
|
|
||||||
|
|
||||||
protected Map<String, HomeDevice> cachedHomeDevicesByApplianceId = new ConcurrentHashMap<String, HomeDevice>();
|
private Gson gson = new Gson();
|
||||||
protected Map<String, HomeDevice> cachedHomeDevicesByRemoteUid = new ConcurrentHashMap<String, HomeDevice>();
|
private @NonNullByDefault({}) MieleGatewayCommunicationController gatewayCommunication;
|
||||||
|
|
||||||
protected @Nullable URL url;
|
private Set<DiscoveryListener> discoveryListeners = ConcurrentHashMap.newKeySet();
|
||||||
|
private Map<String, ApplianceStatusListener> applianceStatusListeners = new ConcurrentHashMap<>();
|
||||||
|
private @Nullable ScheduledFuture<?> pollingJob;
|
||||||
|
private @Nullable ExecutorService executor;
|
||||||
|
private @Nullable Future<?> eventListenerJob;
|
||||||
|
|
||||||
|
private Map<String, HomeDevice> cachedHomeDevicesByApplianceId = new ConcurrentHashMap<>();
|
||||||
|
private Map<String, HomeDevice> cachedHomeDevicesByRemoteUid = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public MieleBridgeHandler(Bridge bridge) {
|
public MieleBridgeHandler(Bridge bridge) {
|
||||||
super(bridge);
|
super(bridge);
|
||||||
@ -127,16 +112,15 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
url = new URL("http://" + (String) getConfig().get(HOST) + "/remote/json-rpc");
|
gatewayCommunication = new MieleGatewayCommunicationController((String) getConfig().get(HOST));
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
logger.debug("An exception occurred while defining an URL :'{}'", e.getMessage());
|
|
||||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, e.getMessage());
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, e.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpdate();
|
|
||||||
lastBridgeConnectionState = false;
|
|
||||||
updateStatus(ThingStatus.UNKNOWN);
|
updateStatus(ThingStatus.UNKNOWN);
|
||||||
|
lastBridgeConnectionState = false;
|
||||||
|
schedulePollingAndEventListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validateConfig(Configuration config) {
|
private boolean validateConfig(Configuration config) {
|
||||||
@ -177,94 +161,47 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
|
|||||||
private Runnable pollingRunnable = new Runnable() {
|
private Runnable pollingRunnable = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!IP_PATTERN.matcher((String) getConfig().get(HOST)).matches()) {
|
String host = (String) getConfig().get(HOST);
|
||||||
logger.debug("Invalid IP address for the Miele@Home gateway : '{}'", getConfig().get(HOST));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isReachable((String) getConfig().get(HOST))) {
|
|
||||||
currentBridgeConnectionState = true;
|
|
||||||
} else {
|
|
||||||
currentBridgeConnectionState = false;
|
|
||||||
lastBridgeConnectionState = false;
|
|
||||||
onConnectionLost();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!lastBridgeConnectionState && currentBridgeConnectionState) {
|
|
||||||
logger.debug("Connection to Miele Gateway {} established.", getConfig().get(HOST));
|
|
||||||
lastBridgeConnectionState = true;
|
|
||||||
onConnectionResumed();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!currentBridgeConnectionState || getThing().getStatus() != ThingStatus.ONLINE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<HomeDevice> homeDevices = getHomeDevices();
|
List<HomeDevice> homeDevices = getHomeDevices();
|
||||||
for (HomeDevice hd : homeDevices) {
|
|
||||||
String key = hd.getApplianceIdentifier().getApplianceId();
|
if (!lastBridgeConnectionState) {
|
||||||
if (!cachedHomeDevicesByApplianceId.containsKey(key)) {
|
logger.debug("Connection to Miele Gateway {} established.", host);
|
||||||
logger.debug("A new appliance with ID '{}' has been added", hd.UID);
|
lastBridgeConnectionState = true;
|
||||||
for (ApplianceStatusListener listener : applianceStatusListeners) {
|
|
||||||
listener.onApplianceAdded(hd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cachedHomeDevicesByApplianceId.put(key, hd);
|
|
||||||
cachedHomeDevicesByRemoteUid.put(hd.getRemoteUid(), hd);
|
|
||||||
}
|
}
|
||||||
|
updateStatus(ThingStatus.ONLINE);
|
||||||
|
|
||||||
Set<Entry<String, HomeDevice>> cachedEntries = cachedHomeDevicesByApplianceId.entrySet();
|
refreshHomeDevices(homeDevices);
|
||||||
Iterator<Entry<String, HomeDevice>> iterator = cachedEntries.iterator();
|
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
for (Entry<String, ApplianceStatusListener> entry : applianceStatusListeners.entrySet()) {
|
||||||
Entry<String, HomeDevice> cachedEntry = iterator.next();
|
String applianceId = entry.getKey();
|
||||||
HomeDevice cachedHomeDevice = cachedEntry.getValue();
|
ApplianceStatusListener listener = entry.getValue();
|
||||||
if (!homeDevices.stream().anyMatch(d -> d.UID.equals(cachedHomeDevice.UID))) {
|
FullyQualifiedApplianceIdentifier applianceIdentifier = getApplianceIdentifierFromApplianceId(
|
||||||
logger.debug("The appliance with ID '{}' has been removed", cachedHomeDevice.UID);
|
applianceId);
|
||||||
for (ApplianceStatusListener listener : applianceStatusListeners) {
|
if (applianceIdentifier == null) {
|
||||||
listener.onApplianceRemoved(cachedHomeDevice);
|
logger.debug("The appliance with ID '{}' was not found in appliance list from bridge.",
|
||||||
}
|
applianceId);
|
||||||
cachedHomeDevicesByRemoteUid.remove(cachedHomeDevice.getRemoteUid());
|
listener.onApplianceRemoved();
|
||||||
iterator.remove();
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (Thing appliance : getThing().getThings()) {
|
Object[] args = new Object[2];
|
||||||
if (appliance.getStatus() == ThingStatus.ONLINE) {
|
args[0] = applianceIdentifier.getUid();
|
||||||
String applianceId = (String) appliance.getConfiguration().getProperties().get(APPLIANCE_ID);
|
args[1] = true;
|
||||||
FullyQualifiedApplianceIdentifier applianceIdentifier = null;
|
JsonElement result = gatewayCommunication.invokeRPC("HDAccess/getDeviceClassObjects", args);
|
||||||
if (applianceId != null) {
|
|
||||||
applianceIdentifier = getApplianceIdentifierFromApplianceId(applianceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (applianceIdentifier == null) {
|
for (JsonElement obj : result.getAsJsonArray()) {
|
||||||
logger.warn("The appliance with ID '{}' was not found in appliance list from bridge.",
|
try {
|
||||||
applianceId);
|
DeviceClassObject dco = gson.fromJson(obj, DeviceClassObject.class);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Object[] args = new Object[2];
|
// Skip com.prosyst.mbs.services.zigbee.hdm.deviceclasses.ReportingControl
|
||||||
args[0] = applianceIdentifier.getUid();
|
if (dco == null || !dco.DeviceClass.startsWith(MIELE_CLASS)) {
|
||||||
args[1] = true;
|
continue;
|
||||||
JsonElement result = invokeRPC("HDAccess/getDeviceClassObjects", args);
|
|
||||||
|
|
||||||
for (JsonElement obj : result.getAsJsonArray()) {
|
|
||||||
try {
|
|
||||||
DeviceClassObject dco = gson.fromJson(obj, DeviceClassObject.class);
|
|
||||||
|
|
||||||
// Skip com.prosyst.mbs.services.zigbee.hdm.deviceclasses.ReportingControl
|
|
||||||
if (dco == null || !dco.DeviceClass.startsWith(MIELE_CLASS)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ApplianceStatusListener listener : applianceStatusListeners) {
|
|
||||||
listener.onApplianceStateChanged(applianceIdentifier, dco);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.debug("An exception occurred while querying an appliance : '{}'",
|
|
||||||
e.getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
listener.onApplianceStateChanged(dco);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.debug("An exception occurred while querying an appliance : '{}'", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -276,50 +213,85 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
|
|||||||
logger.debug("An exception occurred while polling an appliance: '{}' -> '{}'", e.getMessage(),
|
logger.debug("An exception occurred while polling an appliance: '{}' -> '{}'", e.getMessage(),
|
||||||
cause.getMessage());
|
cause.getMessage());
|
||||||
}
|
}
|
||||||
|
if (lastBridgeConnectionState) {
|
||||||
|
logger.debug("Connection to Miele Gateway {} lost.", host);
|
||||||
|
lastBridgeConnectionState = false;
|
||||||
|
}
|
||||||
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isReachable(String ipAddress) {
|
|
||||||
try {
|
|
||||||
// note that InetAddress.isReachable is unreliable, see
|
|
||||||
// http://stackoverflow.com/questions/9922543/why-does-inetaddress-isreachable-return-false-when-i-can-ping-the-ip-address
|
|
||||||
// That's why we do an HTTP access instead
|
|
||||||
|
|
||||||
// If there is no connection, this line will fail
|
|
||||||
invokeRPC("system.listMethods", new Object[0]);
|
|
||||||
} catch (MieleRpcException e) {
|
|
||||||
logger.debug("{} is not reachable", ipAddress);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug("{} is reachable", ipAddress);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public List<HomeDevice> getHomeDevices() {
|
private synchronized void refreshHomeDevices(List<HomeDevice> homeDevices) {
|
||||||
|
for (HomeDevice hd : homeDevices) {
|
||||||
|
String key = hd.getApplianceIdentifier().getApplianceId();
|
||||||
|
if (!cachedHomeDevicesByApplianceId.containsKey(key)) {
|
||||||
|
logger.debug("A new appliance with ID '{}' has been added", hd.UID);
|
||||||
|
for (DiscoveryListener listener : discoveryListeners) {
|
||||||
|
listener.onApplianceAdded(hd);
|
||||||
|
}
|
||||||
|
ApplianceStatusListener listener = applianceStatusListeners
|
||||||
|
.get(hd.getApplianceIdentifier().getApplianceId());
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onApplianceAdded(hd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cachedHomeDevicesByApplianceId.put(key, hd);
|
||||||
|
cachedHomeDevicesByRemoteUid.put(hd.getRemoteUid(), hd);
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<Entry<String, HomeDevice>> cachedEntries = cachedHomeDevicesByApplianceId.entrySet();
|
||||||
|
Iterator<Entry<String, HomeDevice>> iterator = cachedEntries.iterator();
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
Entry<String, HomeDevice> cachedEntry = iterator.next();
|
||||||
|
HomeDevice cachedHomeDevice = cachedEntry.getValue();
|
||||||
|
if (!homeDevices.stream().anyMatch(d -> d.UID.equals(cachedHomeDevice.UID))) {
|
||||||
|
logger.debug("The appliance with ID '{}' has been removed", cachedHomeDevice.UID);
|
||||||
|
for (DiscoveryListener listener : discoveryListeners) {
|
||||||
|
listener.onApplianceRemoved(cachedHomeDevice);
|
||||||
|
}
|
||||||
|
ApplianceStatusListener listener = applianceStatusListeners
|
||||||
|
.get(cachedHomeDevice.getApplianceIdentifier().getApplianceId());
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onApplianceRemoved();
|
||||||
|
}
|
||||||
|
cachedHomeDevicesByRemoteUid.remove(cachedHomeDevice.getRemoteUid());
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<HomeDevice> getHomeDevicesEmptyOnFailure() {
|
||||||
|
try {
|
||||||
|
return getHomeDevices();
|
||||||
|
} catch (MieleRpcException e) {
|
||||||
|
Throwable cause = e.getCause();
|
||||||
|
if (cause == null) {
|
||||||
|
logger.debug("An exception occurred while getting the home devices: '{}'", e.getMessage());
|
||||||
|
} else {
|
||||||
|
logger.debug("An exception occurred while getting the home devices: '{}' -> '{}", e.getMessage(),
|
||||||
|
cause.getMessage());
|
||||||
|
}
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<HomeDevice> getHomeDevices() throws MieleRpcException {
|
||||||
List<HomeDevice> devices = new ArrayList<>();
|
List<HomeDevice> devices = new ArrayList<>();
|
||||||
|
|
||||||
if (getThing().getStatus() == ThingStatus.ONLINE) {
|
if (!isInitialized()) {
|
||||||
try {
|
return devices;
|
||||||
String[] args = new String[1];
|
}
|
||||||
args[0] = "(type=SuperVision)";
|
|
||||||
JsonElement result = invokeRPC("HDAccess/getHomeDevices", args);
|
|
||||||
|
|
||||||
for (JsonElement obj : result.getAsJsonArray()) {
|
String[] args = new String[1];
|
||||||
HomeDevice hd = gson.fromJson(obj, HomeDevice.class);
|
args[0] = "(type=SuperVision)";
|
||||||
if (hd != null) {
|
JsonElement result = gatewayCommunication.invokeRPC("HDAccess/getHomeDevices", args);
|
||||||
devices.add(hd);
|
|
||||||
}
|
for (JsonElement obj : result.getAsJsonArray()) {
|
||||||
}
|
HomeDevice hd = gson.fromJson(obj, HomeDevice.class);
|
||||||
} catch (MieleRpcException e) {
|
if (hd != null) {
|
||||||
Throwable cause = e.getCause();
|
devices.add(hd);
|
||||||
if (cause == null) {
|
|
||||||
logger.debug("An exception occurred while getting the home devices: '{}'", e.getMessage());
|
|
||||||
} else {
|
|
||||||
logger.debug("An exception occurred while getting the home devices: '{}' -> '{}", e.getMessage(),
|
|
||||||
cause.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return devices;
|
return devices;
|
||||||
@ -344,8 +316,7 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
|
|||||||
address1 = InetAddress.getByName(JSON_RPC_MULTICAST_IP1);
|
address1 = InetAddress.getByName(JSON_RPC_MULTICAST_IP1);
|
||||||
address2 = InetAddress.getByName(JSON_RPC_MULTICAST_IP2);
|
address2 = InetAddress.getByName(JSON_RPC_MULTICAST_IP2);
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
logger.debug("An exception occurred while setting up the multicast receiver : '{}'",
|
logger.debug("An exception occurred while setting up the multicast receiver: '{}'", e.getMessage());
|
||||||
e.getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] buf = new byte[256];
|
byte[] buf = new byte[256];
|
||||||
@ -410,20 +381,22 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
|
|||||||
var deviceProperty = new DeviceProperty();
|
var deviceProperty = new DeviceProperty();
|
||||||
deviceProperty.Name = name;
|
deviceProperty.Name = name;
|
||||||
deviceProperty.Value = value;
|
deviceProperty.Value = value;
|
||||||
for (ApplianceStatusListener listener : applianceStatusListeners) {
|
ApplianceStatusListener listener = applianceStatusListeners
|
||||||
listener.onAppliancePropertyChanged(applianceIdentifier, deviceProperty);
|
.get(applianceIdentifier.getApplianceId());
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onAppliancePropertyChanged(deviceProperty);
|
||||||
}
|
}
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
logger.debug("Eventlistener has been interrupted.");
|
logger.debug("Event listener has been interrupted.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.debug("An exception occurred while receiving multicast packets : '{}'", ex.getMessage());
|
logger.debug("An exception occurred while receiving multicast packets: '{}'", ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// restart the cycle with a clean slate
|
// restart the cycle with a clean slate
|
||||||
@ -433,7 +406,7 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
|
|||||||
clientSocket.leaveGroup(address2);
|
clientSocket.leaveGroup(address2);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.debug("An exception occurred while leaving multicast group : '{}'", e.getMessage());
|
logger.debug("An exception occurred while leaving multicast group: '{}'", e.getMessage());
|
||||||
}
|
}
|
||||||
if (clientSocket != null) {
|
if (clientSocket != null) {
|
||||||
clientSocket.close();
|
clientSocket.close();
|
||||||
@ -441,7 +414,7 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.debug("Invalid IP address for the multicast interface : '{}'", getConfig().get(INTERFACE));
|
logger.debug("Invalid IP address for the multicast interface: '{}'", getConfig().get(INTERFACE));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -456,137 +429,10 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
|
|||||||
+ " was not found in appliance list from gateway - operations can not be invoked");
|
+ " was not found in appliance list from gateway - operations can not be invoked");
|
||||||
}
|
}
|
||||||
|
|
||||||
Object[] args = new Object[4];
|
return gatewayCommunication.invokeOperation(applianceIdentifier, modelID, methodName);
|
||||||
args[0] = applianceIdentifier.getUid();
|
|
||||||
args[1] = MIELE_CLASS + modelID;
|
|
||||||
args[2] = methodName;
|
|
||||||
args[3] = null;
|
|
||||||
|
|
||||||
return invokeRPC("HDAccess/invokeDCOOperation", args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JsonElement invokeRPC(String methodName, Object[] args) throws MieleRpcException {
|
private synchronized void schedulePollingAndEventListener() {
|
||||||
JsonElement result = null;
|
|
||||||
URL url = this.url;
|
|
||||||
if (url == null) {
|
|
||||||
throw new MieleRpcException("URL is not set");
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonObject req = new JsonObject();
|
|
||||||
int id = rand.nextInt(Integer.MAX_VALUE);
|
|
||||||
req.addProperty("jsonrpc", "2.0");
|
|
||||||
req.addProperty("id", id);
|
|
||||||
req.addProperty("method", methodName);
|
|
||||||
|
|
||||||
JsonArray params = new JsonArray();
|
|
||||||
for (Object o : args) {
|
|
||||||
params.add(gson.toJsonTree(o));
|
|
||||||
}
|
|
||||||
req.add("params", params);
|
|
||||||
|
|
||||||
String requestData = req.toString();
|
|
||||||
String responseData = null;
|
|
||||||
try {
|
|
||||||
responseData = post(url, Collections.emptyMap(), requestData);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new MieleRpcException("Exception occurred while posting data", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace("The request '{}' yields '{}'", requestData, responseData);
|
|
||||||
JsonObject parsedResponse = null;
|
|
||||||
try {
|
|
||||||
parsedResponse = (JsonObject) JsonParser.parseReader(new StringReader(responseData));
|
|
||||||
} catch (JsonParseException e) {
|
|
||||||
throw new MieleRpcException("Error parsing JSON response", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonElement error = parsedResponse.get("error");
|
|
||||||
if (error != null && !error.isJsonNull()) {
|
|
||||||
if (error.isJsonPrimitive()) {
|
|
||||||
throw new MieleRpcException("Remote exception occurred: '" + error.getAsString() + "'");
|
|
||||||
} else if (error.isJsonObject()) {
|
|
||||||
JsonObject o = error.getAsJsonObject();
|
|
||||||
Integer code = (o.has("code") ? o.get("code").getAsInt() : null);
|
|
||||||
String message = (o.has("message") ? o.get("message").getAsString() : null);
|
|
||||||
String data = (o.has("data")
|
|
||||||
? (o.get("data") instanceof JsonObject ? o.get("data").toString() : o.get("data").getAsString())
|
|
||||||
: null);
|
|
||||||
throw new MieleRpcException(
|
|
||||||
"Remote exception occurred: '" + code + "':'" + message + "':'" + data + "'");
|
|
||||||
} else {
|
|
||||||
throw new MieleRpcException("Unknown remote exception occurred: '" + error.toString() + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result = parsedResponse.get("result");
|
|
||||||
if (result == null) {
|
|
||||||
throw new MieleRpcException("Result is missing in response");
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String post(URL url, Map<String, String> headers, String data) throws IOException {
|
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
||||||
|
|
||||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
|
||||||
connection.addRequestProperty(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
connection.addRequestProperty("Accept-Encoding", "gzip");
|
|
||||||
|
|
||||||
connection.setRequestMethod("POST");
|
|
||||||
connection.setDoOutput(true);
|
|
||||||
connection.connect();
|
|
||||||
|
|
||||||
OutputStream out = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
out = connection.getOutputStream();
|
|
||||||
|
|
||||||
out.write(data.getBytes());
|
|
||||||
out.flush();
|
|
||||||
|
|
||||||
int statusCode = connection.getResponseCode();
|
|
||||||
if (statusCode != HttpURLConnection.HTTP_OK) {
|
|
||||||
logger.debug("An unexpected status code was returned: '{}'", statusCode);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (out != null) {
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String responseEncoding = connection.getHeaderField("Content-Encoding");
|
|
||||||
responseEncoding = (responseEncoding == null ? "" : responseEncoding.trim());
|
|
||||||
|
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
||||||
|
|
||||||
InputStream in = connection.getInputStream();
|
|
||||||
try {
|
|
||||||
in = connection.getInputStream();
|
|
||||||
if ("gzip".equalsIgnoreCase(responseEncoding)) {
|
|
||||||
in = new GZIPInputStream(in);
|
|
||||||
}
|
|
||||||
in = new BufferedInputStream(in);
|
|
||||||
|
|
||||||
byte[] buff = new byte[1024];
|
|
||||||
int n;
|
|
||||||
while ((n = in.read(buff)) > 0) {
|
|
||||||
bos.write(buff, 0, n);
|
|
||||||
}
|
|
||||||
bos.flush();
|
|
||||||
bos.close();
|
|
||||||
} finally {
|
|
||||||
if (in != null) {
|
|
||||||
in.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return bos.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private synchronized void onUpdate() {
|
|
||||||
logger.debug("Scheduling the Miele polling job");
|
logger.debug("Scheduling the Miele polling job");
|
||||||
ScheduledFuture<?> pollingJob = this.pollingJob;
|
ScheduledFuture<?> pollingJob = this.pollingJob;
|
||||||
if (pollingJob == null || pollingJob.isCancelled()) {
|
if (pollingJob == null || pollingJob.isCancelled()) {
|
||||||
@ -595,8 +441,8 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
|
|||||||
this.pollingJob = pollingJob;
|
this.pollingJob = pollingJob;
|
||||||
logger.trace("Scheduling the Miele polling job Job is done ?{}", pollingJob.isDone());
|
logger.trace("Scheduling the Miele polling job Job is done ?{}", pollingJob.isDone());
|
||||||
}
|
}
|
||||||
logger.debug("Scheduling the Miele event listener job");
|
|
||||||
|
|
||||||
|
logger.debug("Scheduling the Miele event listener job");
|
||||||
Future<?> eventListenerJob = this.eventListenerJob;
|
Future<?> eventListenerJob = this.eventListenerJob;
|
||||||
if (eventListenerJob == null || eventListenerJob.isCancelled()) {
|
if (eventListenerJob == null || eventListenerJob.isCancelled()) {
|
||||||
ExecutorService executor = Executors
|
ExecutorService executor = Executors
|
||||||
@ -606,47 +452,71 @@ public class MieleBridgeHandler extends BaseBridgeHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public boolean registerApplianceStatusListener(String applianceId,
|
||||||
* This method is called whenever the connection to the given {@link MieleBridge} is lost.
|
ApplianceStatusListener applianceStatusListener) {
|
||||||
*
|
ApplianceStatusListener existingListener = applianceStatusListeners.get(applianceId);
|
||||||
*/
|
if (existingListener != null) {
|
||||||
public void onConnectionLost() {
|
if (!existingListener.equals(applianceStatusListener)) {
|
||||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR);
|
logger.warn("Unsupported configuration: appliance with ID '{}' referenced by multiple things",
|
||||||
}
|
applianceId);
|
||||||
|
} else {
|
||||||
|
logger.debug("Duplicate listener registration attempted for '{}'", applianceId);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
applianceStatusListeners.put(applianceId, applianceStatusListener);
|
||||||
|
|
||||||
/**
|
HomeDevice cachedHomeDevice = cachedHomeDevicesByApplianceId.get(applianceId);
|
||||||
* This method is called whenever the connection to the given {@link MieleBridge} is resumed.
|
if (cachedHomeDevice != null) {
|
||||||
*
|
applianceStatusListener.onApplianceAdded(cachedHomeDevice);
|
||||||
* @param bridge the Miele bridge the connection is resumed to
|
} else {
|
||||||
*/
|
try {
|
||||||
public void onConnectionResumed() {
|
refreshHomeDevices(getHomeDevices());
|
||||||
updateStatus(ThingStatus.ONLINE);
|
} catch (MieleRpcException e) {
|
||||||
for (Thing thing : getThing().getThings()) {
|
Throwable cause = e.getCause();
|
||||||
MieleApplianceHandler<?> handler = (MieleApplianceHandler<?>) thing.getHandler();
|
if (cause == null) {
|
||||||
if (handler != null) {
|
logger.debug("An exception occurred while getting the home devices: '{}'", e.getMessage());
|
||||||
handler.onBridgeConnectionResumed();
|
} else {
|
||||||
|
logger.debug("An exception occurred while getting the home devices: '{}' -> '{}", e.getMessage(),
|
||||||
|
cause.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean registerApplianceStatusListener(ApplianceStatusListener applianceStatusListener) {
|
public boolean unregisterApplianceStatusListener(String applianceId,
|
||||||
boolean result = applianceStatusListeners.add(applianceStatusListener);
|
ApplianceStatusListener applianceStatusListener) {
|
||||||
if (result && isInitialized()) {
|
return applianceStatusListeners.remove(applianceId) != null;
|
||||||
onUpdate();
|
}
|
||||||
|
|
||||||
for (HomeDevice hd : getHomeDevices()) {
|
public boolean registerDiscoveryListener(DiscoveryListener discoveryListener) {
|
||||||
applianceStatusListener.onApplianceAdded(hd);
|
if (!discoveryListeners.add(discoveryListener)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (cachedHomeDevicesByApplianceId.isEmpty()) {
|
||||||
|
try {
|
||||||
|
refreshHomeDevices(getHomeDevices());
|
||||||
|
} catch (MieleRpcException e) {
|
||||||
|
Throwable cause = e.getCause();
|
||||||
|
if (cause == null) {
|
||||||
|
logger.debug("An exception occurred while getting the home devices: '{}'", e.getMessage());
|
||||||
|
} else {
|
||||||
|
logger.debug("An exception occurred while getting the home devices: '{}' -> '{}", e.getMessage(),
|
||||||
|
cause.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (Entry<String, HomeDevice> entry : cachedHomeDevicesByApplianceId.entrySet()) {
|
||||||
|
discoveryListener.onApplianceAdded(entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean unregisterApplianceStatusListener(ApplianceStatusListener applianceStatusListener) {
|
public boolean unregisterDiscoveryListener(DiscoveryListener discoveryListener) {
|
||||||
boolean result = applianceStatusListeners.remove(applianceStatusListener);
|
return discoveryListeners.remove(discoveryListener);
|
||||||
if (result && isInitialized()) {
|
|
||||||
onUpdate();
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -52,8 +52,7 @@ public enum OvenChannelSelector implements ApplianceChannelSelector {
|
|||||||
DEVICE_TYPE("mieleDeviceType", "deviceType", StringType.class, true),
|
DEVICE_TYPE("mieleDeviceType", "deviceType", StringType.class, true),
|
||||||
STATE_TEXT(STATE_PROPERTY_NAME, STATE_TEXT_CHANNEL_ID, StringType.class, false) {
|
STATE_TEXT(STATE_PROPERTY_NAME, STATE_TEXT_CHANNEL_ID, StringType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return DeviceUtil.getStateTextState(s, dmd, translationProvider);
|
return DeviceUtil.getStateTextState(s, dmd, translationProvider);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -63,8 +62,7 @@ public enum OvenChannelSelector implements ApplianceChannelSelector {
|
|||||||
PROGRAMTYPE("programType", "type", StringType.class, false),
|
PROGRAMTYPE("programType", "type", StringType.class, false),
|
||||||
PROGRAM_PHASE_TEXT(PHASE_PROPERTY_NAME, PHASE_TEXT_CHANNEL_ID, StringType.class, false) {
|
PROGRAM_PHASE_TEXT(PHASE_PROPERTY_NAME, PHASE_TEXT_CHANNEL_ID, StringType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return DeviceUtil.getTextState(s, dmd, translationProvider, PHASES, MISSING_PHASE_TEXT_PREFIX,
|
return DeviceUtil.getTextState(s, dmd, translationProvider, PHASES, MISSING_PHASE_TEXT_PREFIX,
|
||||||
MIELE_OVEN_TEXT_PREFIX);
|
MIELE_OVEN_TEXT_PREFIX);
|
||||||
}
|
}
|
||||||
@ -72,8 +70,7 @@ public enum OvenChannelSelector implements ApplianceChannelSelector {
|
|||||||
PROGRAM_PHASE(RAW_PHASE_PROPERTY_NAME, PHASE_CHANNEL_ID, DecimalType.class, false),
|
PROGRAM_PHASE(RAW_PHASE_PROPERTY_NAME, PHASE_CHANNEL_ID, DecimalType.class, false),
|
||||||
START_TIME("startTime", "start", DateTimeType.class, false) {
|
START_TIME("startTime", "start", DateTimeType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
||||||
@ -87,8 +84,7 @@ public enum OvenChannelSelector implements ApplianceChannelSelector {
|
|||||||
},
|
},
|
||||||
DURATION("duration", "duration", DateTimeType.class, false) {
|
DURATION("duration", "duration", DateTimeType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
||||||
@ -102,8 +98,7 @@ public enum OvenChannelSelector implements ApplianceChannelSelector {
|
|||||||
},
|
},
|
||||||
ELAPSED_TIME("elapsedTime", "elapsed", DateTimeType.class, false) {
|
ELAPSED_TIME("elapsedTime", "elapsed", DateTimeType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
||||||
@ -117,8 +112,7 @@ public enum OvenChannelSelector implements ApplianceChannelSelector {
|
|||||||
},
|
},
|
||||||
FINISH_TIME("finishTime", "finish", DateTimeType.class, false) {
|
FINISH_TIME("finishTime", "finish", DateTimeType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
||||||
@ -132,37 +126,32 @@ public enum OvenChannelSelector implements ApplianceChannelSelector {
|
|||||||
},
|
},
|
||||||
TARGET_TEMP("targetTemperature", "target", QuantityType.class, false) {
|
TARGET_TEMP("targetTemperature", "target", QuantityType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return getTemperatureState(s);
|
return getTemperatureState(s);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
MEASURED_TEMP("measuredTemperature", "measured", QuantityType.class, false) {
|
MEASURED_TEMP("measuredTemperature", "measured", QuantityType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return getTemperatureState(s);
|
return getTemperatureState(s);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DEVICE_TEMP_ONE("deviceTemperature1", "temp1", QuantityType.class, false) {
|
DEVICE_TEMP_ONE("deviceTemperature1", "temp1", QuantityType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return getTemperatureState(s);
|
return getTemperatureState(s);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DEVICE_TEMP_TWO("deviceTemperature2", "temp2", QuantityType.class, false) {
|
DEVICE_TEMP_TWO("deviceTemperature2", "temp2", QuantityType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return getTemperatureState(s);
|
return getTemperatureState(s);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DOOR("signalDoor", "door", OpenClosedType.class, false) {
|
DOOR("signalDoor", "door", OpenClosedType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
|
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
if ("true".equals(s)) {
|
if ("true".equals(s)) {
|
||||||
return getState("OPEN");
|
return getState("OPEN");
|
||||||
}
|
}
|
||||||
@ -221,8 +210,7 @@ public enum OvenChannelSelector implements ApplianceChannelSelector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return this.getState(s, dmd);
|
return this.getState(s, dmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +239,7 @@ public enum OvenChannelSelector implements ApplianceChannelSelector {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("An exception occurred while converting '{}' into a State", s);
|
logger.warn("An exception occurred while converting '{}' into a State", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return UnDefType.UNDEF;
|
return UnDefType.UNDEF;
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
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.MIELE_DEVICE_CLASS_OVEN;
|
import static org.openhab.binding.miele.internal.MieleBindingConstants.MIELE_DEVICE_CLASS_OVEN;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -52,7 +51,7 @@ public class OvenHandler extends MieleApplianceHandler<OvenChannelSelector> {
|
|||||||
super.handleCommand(channelUID, command);
|
super.handleCommand(channelUID, command);
|
||||||
|
|
||||||
String channelID = channelUID.getId();
|
String channelID = channelUID.getId();
|
||||||
String applianceId = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
String applianceId = this.applianceId;
|
||||||
if (applianceId == null) {
|
if (applianceId == null) {
|
||||||
logger.warn("Command '{}' failed, appliance id is unknown", command);
|
logger.warn("Command '{}' failed, appliance id is unknown", command);
|
||||||
return;
|
return;
|
||||||
@ -62,7 +61,7 @@ public class OvenHandler extends MieleApplianceHandler<OvenChannelSelector> {
|
|||||||
JsonElement result = null;
|
JsonElement result = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MieleBridgeHandler bridgeHandler = this.bridgeHandler;
|
MieleBridgeHandler bridgeHandler = getMieleBridgeHandler();
|
||||||
if (bridgeHandler == null) {
|
if (bridgeHandler == null) {
|
||||||
logger.warn("Command '{}' failed, missing bridge handler", command);
|
logger.warn("Command '{}' failed, missing bridge handler", command);
|
||||||
return;
|
return;
|
||||||
|
@ -51,16 +51,14 @@ public enum TumbleDryerChannelSelector implements ApplianceChannelSelector {
|
|||||||
DEVICE_TYPE("mieleDeviceType", "deviceType", StringType.class, true),
|
DEVICE_TYPE("mieleDeviceType", "deviceType", StringType.class, true),
|
||||||
STATE_TEXT(STATE_PROPERTY_NAME, STATE_TEXT_CHANNEL_ID, StringType.class, false) {
|
STATE_TEXT(STATE_PROPERTY_NAME, STATE_TEXT_CHANNEL_ID, StringType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return DeviceUtil.getStateTextState(s, dmd, translationProvider);
|
return DeviceUtil.getStateTextState(s, dmd, translationProvider);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
STATE("", STATE_CHANNEL_ID, DecimalType.class, false),
|
STATE("", STATE_CHANNEL_ID, DecimalType.class, false),
|
||||||
PROGRAM_TEXT(PROGRAM_ID_PROPERTY_NAME, PROGRAM_TEXT_CHANNEL_ID, StringType.class, false) {
|
PROGRAM_TEXT(PROGRAM_ID_PROPERTY_NAME, PROGRAM_TEXT_CHANNEL_ID, StringType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return DeviceUtil.getTextState(s, dmd, translationProvider, PROGRAMS, MISSING_PROGRAM_TEXT_PREFIX,
|
return DeviceUtil.getTextState(s, dmd, translationProvider, PROGRAMS, MISSING_PROGRAM_TEXT_PREFIX,
|
||||||
MIELE_TUMBLE_DRYER_TEXT_PREFIX);
|
MIELE_TUMBLE_DRYER_TEXT_PREFIX);
|
||||||
}
|
}
|
||||||
@ -69,8 +67,7 @@ public enum TumbleDryerChannelSelector implements ApplianceChannelSelector {
|
|||||||
PROGRAMTYPE("programType", "type", StringType.class, false),
|
PROGRAMTYPE("programType", "type", StringType.class, false),
|
||||||
PROGRAM_PHASE_TEXT(PHASE_PROPERTY_NAME, PHASE_TEXT_CHANNEL_ID, StringType.class, false) {
|
PROGRAM_PHASE_TEXT(PHASE_PROPERTY_NAME, PHASE_TEXT_CHANNEL_ID, StringType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return DeviceUtil.getTextState(s, dmd, translationProvider, PHASES, MISSING_PHASE_TEXT_PREFIX,
|
return DeviceUtil.getTextState(s, dmd, translationProvider, PHASES, MISSING_PHASE_TEXT_PREFIX,
|
||||||
MIELE_TUMBLE_DRYER_TEXT_PREFIX);
|
MIELE_TUMBLE_DRYER_TEXT_PREFIX);
|
||||||
}
|
}
|
||||||
@ -78,8 +75,7 @@ public enum TumbleDryerChannelSelector implements ApplianceChannelSelector {
|
|||||||
PROGRAM_PHASE(RAW_PHASE_PROPERTY_NAME, PHASE_CHANNEL_ID, DecimalType.class, false),
|
PROGRAM_PHASE(RAW_PHASE_PROPERTY_NAME, PHASE_CHANNEL_ID, DecimalType.class, false),
|
||||||
START_TIME("startTime", "start", DateTimeType.class, false) {
|
START_TIME("startTime", "start", DateTimeType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
||||||
@ -93,8 +89,7 @@ public enum TumbleDryerChannelSelector implements ApplianceChannelSelector {
|
|||||||
},
|
},
|
||||||
DURATION("duration", "duration", DateTimeType.class, false) {
|
DURATION("duration", "duration", DateTimeType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
||||||
@ -108,8 +103,7 @@ public enum TumbleDryerChannelSelector implements ApplianceChannelSelector {
|
|||||||
},
|
},
|
||||||
ELAPSED_TIME("elapsedTime", "elapsed", DateTimeType.class, false) {
|
ELAPSED_TIME("elapsedTime", "elapsed", DateTimeType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
||||||
@ -123,8 +117,7 @@ public enum TumbleDryerChannelSelector implements ApplianceChannelSelector {
|
|||||||
},
|
},
|
||||||
FINISH_TIME("finishTime", "finish", DateTimeType.class, false) {
|
FINISH_TIME("finishTime", "finish", DateTimeType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
||||||
@ -138,16 +131,14 @@ public enum TumbleDryerChannelSelector implements ApplianceChannelSelector {
|
|||||||
},
|
},
|
||||||
DRYING_STEP("dryingStep", "step", DecimalType.class, false) {
|
DRYING_STEP("dryingStep", "step", DecimalType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return getState(s);
|
return getState(s);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DOOR("signalDoor", "door", OpenClosedType.class, false) {
|
DOOR("signalDoor", "door", OpenClosedType.class, false) {
|
||||||
@Override
|
@Override
|
||||||
|
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
if ("true".equals(s)) {
|
if ("true".equals(s)) {
|
||||||
return getState("OPEN");
|
return getState("OPEN");
|
||||||
}
|
}
|
||||||
@ -217,8 +208,7 @@ public enum TumbleDryerChannelSelector implements ApplianceChannelSelector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return this.getState(s, dmd);
|
return this.getState(s, dmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,7 +237,7 @@ public enum TumbleDryerChannelSelector implements ApplianceChannelSelector {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("An exception occurred while converting '{}' into a State", s);
|
logger.warn("An exception occurred while converting '{}' into a State", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return UnDefType.UNDEF;
|
return UnDefType.UNDEF;
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
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.MIELE_DEVICE_CLASS_TUMBLE_DRYER;
|
import static org.openhab.binding.miele.internal.MieleBindingConstants.MIELE_DEVICE_CLASS_TUMBLE_DRYER;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -52,7 +51,7 @@ public class TumbleDryerHandler extends MieleApplianceHandler<TumbleDryerChannel
|
|||||||
super.handleCommand(channelUID, command);
|
super.handleCommand(channelUID, command);
|
||||||
|
|
||||||
String channelID = channelUID.getId();
|
String channelID = channelUID.getId();
|
||||||
String applianceId = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
String applianceId = this.applianceId;
|
||||||
if (applianceId == null) {
|
if (applianceId == null) {
|
||||||
logger.warn("Command '{}' failed, appliance id is unknown", command);
|
logger.warn("Command '{}' failed, appliance id is unknown", command);
|
||||||
return;
|
return;
|
||||||
@ -64,7 +63,7 @@ public class TumbleDryerHandler extends MieleApplianceHandler<TumbleDryerChannel
|
|||||||
try {
|
try {
|
||||||
switch (selector) {
|
switch (selector) {
|
||||||
case SWITCH: {
|
case SWITCH: {
|
||||||
MieleBridgeHandler bridgeHandler = this.bridgeHandler;
|
MieleBridgeHandler bridgeHandler = getMieleBridgeHandler();
|
||||||
if (bridgeHandler == null) {
|
if (bridgeHandler == null) {
|
||||||
logger.warn("Command '{}' failed, missing bridge handler", command);
|
logger.warn("Command '{}' failed, missing bridge handler", command);
|
||||||
return;
|
return;
|
||||||
|
@ -52,16 +52,14 @@ public enum WashingMachineChannelSelector implements ApplianceChannelSelector {
|
|||||||
DEVICE_TYPE("mieleDeviceType", "deviceType", StringType.class, true, false),
|
DEVICE_TYPE("mieleDeviceType", "deviceType", StringType.class, true, false),
|
||||||
STATE_TEXT(STATE_PROPERTY_NAME, STATE_TEXT_CHANNEL_ID, StringType.class, false, false) {
|
STATE_TEXT(STATE_PROPERTY_NAME, STATE_TEXT_CHANNEL_ID, StringType.class, false, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return DeviceUtil.getStateTextState(s, dmd, translationProvider);
|
return DeviceUtil.getStateTextState(s, dmd, translationProvider);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
STATE("", STATE_CHANNEL_ID, DecimalType.class, false, false),
|
STATE("", STATE_CHANNEL_ID, DecimalType.class, false, false),
|
||||||
PROGRAM_TEXT(PROGRAM_ID_PROPERTY_NAME, PROGRAM_TEXT_CHANNEL_ID, StringType.class, false, false) {
|
PROGRAM_TEXT(PROGRAM_ID_PROPERTY_NAME, PROGRAM_TEXT_CHANNEL_ID, StringType.class, false, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return DeviceUtil.getTextState(s, dmd, translationProvider, PROGRAMS, MISSING_PROGRAM_TEXT_PREFIX,
|
return DeviceUtil.getTextState(s, dmd, translationProvider, PROGRAMS, MISSING_PROGRAM_TEXT_PREFIX,
|
||||||
MIELE_WASHING_MACHINE_TEXT_PREFIX);
|
MIELE_WASHING_MACHINE_TEXT_PREFIX);
|
||||||
}
|
}
|
||||||
@ -70,8 +68,7 @@ public enum WashingMachineChannelSelector implements ApplianceChannelSelector {
|
|||||||
PROGRAMTYPE("programType", "type", StringType.class, false, false),
|
PROGRAMTYPE("programType", "type", StringType.class, false, false),
|
||||||
PROGRAM_PHASE_TEXT(PHASE_PROPERTY_NAME, PHASE_TEXT_CHANNEL_ID, StringType.class, false, false) {
|
PROGRAM_PHASE_TEXT(PHASE_PROPERTY_NAME, PHASE_TEXT_CHANNEL_ID, StringType.class, false, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return DeviceUtil.getTextState(s, dmd, translationProvider, PHASES, MISSING_PHASE_TEXT_PREFIX,
|
return DeviceUtil.getTextState(s, dmd, translationProvider, PHASES, MISSING_PHASE_TEXT_PREFIX,
|
||||||
MIELE_WASHING_MACHINE_TEXT_PREFIX);
|
MIELE_WASHING_MACHINE_TEXT_PREFIX);
|
||||||
}
|
}
|
||||||
@ -79,8 +76,7 @@ public enum WashingMachineChannelSelector implements ApplianceChannelSelector {
|
|||||||
PROGRAM_PHASE(RAW_PHASE_PROPERTY_NAME, PHASE_CHANNEL_ID, DecimalType.class, false, false),
|
PROGRAM_PHASE(RAW_PHASE_PROPERTY_NAME, PHASE_CHANNEL_ID, DecimalType.class, false, false),
|
||||||
START_TIME("startTime", "start", DateTimeType.class, false, false) {
|
START_TIME("startTime", "start", DateTimeType.class, false, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
||||||
@ -94,8 +90,7 @@ public enum WashingMachineChannelSelector implements ApplianceChannelSelector {
|
|||||||
},
|
},
|
||||||
DURATION("duration", "duration", DateTimeType.class, false, false) {
|
DURATION("duration", "duration", DateTimeType.class, false, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
||||||
@ -109,8 +104,7 @@ public enum WashingMachineChannelSelector implements ApplianceChannelSelector {
|
|||||||
},
|
},
|
||||||
ELAPSED_TIME("elapsedTime", "elapsed", DateTimeType.class, false, false) {
|
ELAPSED_TIME("elapsedTime", "elapsed", DateTimeType.class, false, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
||||||
@ -124,8 +118,7 @@ public enum WashingMachineChannelSelector implements ApplianceChannelSelector {
|
|||||||
},
|
},
|
||||||
FINISH_TIME("finishTime", "finish", DateTimeType.class, false, false) {
|
FINISH_TIME("finishTime", "finish", DateTimeType.class, false, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
||||||
@ -139,15 +132,13 @@ public enum WashingMachineChannelSelector implements ApplianceChannelSelector {
|
|||||||
},
|
},
|
||||||
TARGET_TEMP("targetTemperature", "target", QuantityType.class, false, false) {
|
TARGET_TEMP("targetTemperature", "target", QuantityType.class, false, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return getTemperatureState(s);
|
return getTemperatureState(s);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SPINNING_SPEED("spinningSpeed", "spinningspeed", StringType.class, false, false) {
|
SPINNING_SPEED("spinningSpeed", "spinningspeed", StringType.class, false, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
if ("0".equals(s)) {
|
if ("0".equals(s)) {
|
||||||
return getState("Without spinning");
|
return getState("Without spinning");
|
||||||
}
|
}
|
||||||
@ -159,8 +150,7 @@ public enum WashingMachineChannelSelector implements ApplianceChannelSelector {
|
|||||||
},
|
},
|
||||||
DOOR("signalDoor", "door", OpenClosedType.class, false, false) {
|
DOOR("signalDoor", "door", OpenClosedType.class, false, false) {
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
if ("true".equals(s)) {
|
if ("true".equals(s)) {
|
||||||
return getState("OPEN");
|
return getState("OPEN");
|
||||||
}
|
}
|
||||||
@ -234,8 +224,7 @@ public enum WashingMachineChannelSelector implements ApplianceChannelSelector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public State getState(String s, @Nullable DeviceMetaData dmd,
|
public State getState(String s, @Nullable DeviceMetaData dmd, MieleTranslationProvider translationProvider) {
|
||||||
@Nullable MieleTranslationProvider translationProvider) {
|
|
||||||
return this.getState(s, dmd);
|
return this.getState(s, dmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +253,7 @@ public enum WashingMachineChannelSelector implements ApplianceChannelSelector {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("An exception occurred while converting '{}' into a State", s);
|
logger.warn("An exception occurred while converting '{}' into a State", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return UnDefType.UNDEF;
|
return UnDefType.UNDEF;
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
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.MIELE_DEVICE_CLASS_WASHING_MACHINE;
|
import static org.openhab.binding.miele.internal.MieleBindingConstants.MIELE_DEVICE_CLASS_WASHING_MACHINE;
|
||||||
import static org.openhab.binding.miele.internal.MieleBindingConstants.POWER_CONSUMPTION_CHANNEL_ID;
|
import static org.openhab.binding.miele.internal.MieleBindingConstants.POWER_CONSUMPTION_CHANNEL_ID;
|
||||||
import static org.openhab.binding.miele.internal.MieleBindingConstants.WATER_CONSUMPTION_CHANNEL_ID;
|
import static org.openhab.binding.miele.internal.MieleBindingConstants.WATER_CONSUMPTION_CHANNEL_ID;
|
||||||
@ -64,7 +63,7 @@ public class WashingMachineHandler extends MieleApplianceHandler<WashingMachineC
|
|||||||
super.handleCommand(channelUID, command);
|
super.handleCommand(channelUID, command);
|
||||||
|
|
||||||
String channelID = channelUID.getId();
|
String channelID = channelUID.getId();
|
||||||
String applianceId = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
|
String applianceId = this.applianceId;
|
||||||
if (applianceId == null) {
|
if (applianceId == null) {
|
||||||
logger.warn("Command '{}' failed, appliance id is unknown", command);
|
logger.warn("Command '{}' failed, appliance id is unknown", command);
|
||||||
return;
|
return;
|
||||||
@ -77,7 +76,7 @@ public class WashingMachineHandler extends MieleApplianceHandler<WashingMachineC
|
|||||||
try {
|
try {
|
||||||
switch (selector) {
|
switch (selector) {
|
||||||
case SWITCH: {
|
case SWITCH: {
|
||||||
MieleBridgeHandler bridgeHandler = this.bridgeHandler;
|
MieleBridgeHandler bridgeHandler = getMieleBridgeHandler();
|
||||||
if (bridgeHandler == null) {
|
if (bridgeHandler == null) {
|
||||||
logger.warn("Command '{}' failed, missing bridge handler", command);
|
logger.warn("Command '{}' failed, missing bridge handler", command);
|
||||||
return;
|
return;
|
||||||
|
@ -125,11 +125,13 @@ channel-type.miele.waterConsumption.description = Water consumption by the curre
|
|||||||
|
|
||||||
# thing status descriptions
|
# thing status descriptions
|
||||||
|
|
||||||
|
offline.configuration-error.bridge-missing = Bridge is missing
|
||||||
offline.configuration-error.ip-address-not-set = Cannot connect to the Miele gateway: host IP address is not set.
|
offline.configuration-error.ip-address-not-set = Cannot connect to the Miele gateway: host IP address is not set.
|
||||||
offline.configuration-error.ip-multicast-interface-not-set = Cannot connect to the Miele gateway: multicast interface is not set.
|
offline.configuration-error.ip-multicast-interface-not-set = Cannot connect to the Miele gateway: multicast interface is not set.
|
||||||
offline.configuration-error.invalid-ip-gateway = Invalid IP address for the Miele@Home gateway: {0}
|
offline.configuration-error.invalid-ip-gateway = Invalid IP address for the Miele@Home gateway: {0}
|
||||||
offline.configuration-error.invalid-ip-multicast-interface = Invalid IP address for the multicast interface: {0}
|
offline.configuration-error.invalid-ip-multicast-interface = Invalid IP address for the multicast interface: {0}
|
||||||
offline.configuration-error.invalid-language = Invalid language: {0}
|
offline.configuration-error.invalid-language = Invalid language: {0}
|
||||||
|
offline.configuration-error.uid-not-set = Appliance ID is not set
|
||||||
|
|
||||||
# Discovery result
|
# Discovery result
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user