Java 17 features (T-Z) (#15576)
- add missing @override - Java style array syntax - remove redundant modifiers - always move String constants to left side in comparisons - simplify lambda expressions and return statements - use replace instead of replaceAll w/o regex - instanceof matching and multiline strings - remove null check before instanceof Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
@@ -132,25 +132,30 @@ public class WemoUtil {
|
||||
|
||||
public static String createBinaryStateContent(boolean binaryState) {
|
||||
String binary = binaryState ? "1" : "0";
|
||||
String content = "<?xml version=\"1.0\"?>"
|
||||
+ "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
|
||||
+ "<s:Body>" + "<u:SetBinaryState xmlns:u=\"urn:Belkin:service:basicevent:1\">" + "<BinaryState>"
|
||||
return """
|
||||
<?xml version="1.0"?>\
|
||||
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
|
||||
<s:Body>\
|
||||
<u:SetBinaryState xmlns:u="urn:Belkin:service:basicevent:1">\
|
||||
<BinaryState>\
|
||||
"""
|
||||
+ binary + "</BinaryState>" + "</u:SetBinaryState>" + "</s:Body>" + "</s:Envelope>";
|
||||
return content;
|
||||
}
|
||||
|
||||
public static String createStateRequestContent(String action, String actionService) {
|
||||
String content = "<?xml version=\"1.0\"?>"
|
||||
+ "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
|
||||
+ "<s:Body>" + "<u:" + action + " xmlns:u=\"urn:Belkin:service:" + actionService + ":1\">" + "</u:"
|
||||
+ action + ">" + "</s:Body>" + "</s:Envelope>";
|
||||
return content;
|
||||
return """
|
||||
<?xml version="1.0"?>\
|
||||
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
|
||||
<s:Body>\
|
||||
<u:\
|
||||
"""
|
||||
+ action + " xmlns:u=\"urn:Belkin:service:" + actionService + ":1\">" + "</u:" + action + ">"
|
||||
+ "</s:Body>" + "</s:Envelope>";
|
||||
}
|
||||
|
||||
public static String getCharacterDataFromElement(Element e) {
|
||||
Node child = e.getFirstChild();
|
||||
if (child instanceof CharacterData) {
|
||||
CharacterData cd = (CharacterData) child;
|
||||
if (child instanceof CharacterData cd) {
|
||||
return cd.getData();
|
||||
}
|
||||
return "?";
|
||||
|
||||
@@ -17,7 +17,6 @@ import static org.openhab.binding.wemo.internal.WemoUtil.*;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -59,7 +58,7 @@ public class WemoLinkDiscoveryService extends AbstractDiscoveryService implement
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(WemoLinkDiscoveryService.class);
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_MZ100);
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_MZ100);
|
||||
|
||||
public static final String NORMALIZE_ID_REGEX = "[^a-zA-Z0-9_]";
|
||||
|
||||
@@ -119,11 +118,20 @@ public class WemoLinkDiscoveryService extends AbstractDiscoveryService implement
|
||||
logger.trace("devUDN = '{}'", devUDN);
|
||||
|
||||
String soapHeader = "\"urn:Belkin:service:bridge:1#GetEndDevices\"";
|
||||
String content = "<?xml version=\"1.0\"?>"
|
||||
+ "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
|
||||
+ "<s:Body>" + "<u:GetEndDevices xmlns:u=\"urn:Belkin:service:bridge:1\">" + "<DevUDN>" + devUDN
|
||||
+ "</DevUDN><ReqListType>PAIRED_LIST</ReqListType>" + "</u:GetEndDevices>" + "</s:Body>"
|
||||
+ "</s:Envelope>";
|
||||
String content = """
|
||||
<?xml version="1.0"?>\
|
||||
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
|
||||
<s:Body>\
|
||||
<u:GetEndDevices xmlns:u="urn:Belkin:service:bridge:1">\
|
||||
<DevUDN>\
|
||||
"""
|
||||
+ devUDN + """
|
||||
</DevUDN>\
|
||||
<ReqListType>PAIRED_LIST</ReqListType>\
|
||||
</u:GetEndDevices>\
|
||||
</s:Body>\
|
||||
</s:Envelope>\
|
||||
""";
|
||||
|
||||
URL descriptorURL = service.getDescriptorURL(this);
|
||||
|
||||
@@ -274,8 +282,7 @@ public class WemoLinkDiscoveryService extends AbstractDiscoveryService implement
|
||||
|
||||
public static String getCharacterDataFromElement(Element e) {
|
||||
Node child = e.getFirstChild();
|
||||
if (child instanceof CharacterData) {
|
||||
CharacterData cd = (CharacterData) child;
|
||||
if (child instanceof CharacterData cd) {
|
||||
return cd.getData();
|
||||
}
|
||||
return "?";
|
||||
|
||||
@@ -14,7 +14,6 @@ package org.openhab.binding.wemo.internal.handler;
|
||||
|
||||
import static org.openhab.binding.wemo.internal.WemoBindingConstants.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
@@ -38,7 +37,7 @@ import org.slf4j.LoggerFactory;
|
||||
@NonNullByDefault
|
||||
public class WemoBridgeHandler extends BaseBridgeHandler {
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_BRIDGE);
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_BRIDGE);
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(WemoBridgeHandler.class);
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import static org.openhab.binding.wemo.internal.WemoUtil.*;
|
||||
import java.io.StringReader;
|
||||
import java.time.Instant;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
@@ -63,7 +62,7 @@ public class WemoCoffeeHandler extends WemoBaseThingHandler {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(WemoCoffeeHandler.class);
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_COFFEE);
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_COFFEE);
|
||||
|
||||
private final Object jobLock = new Object();
|
||||
|
||||
@@ -145,18 +144,23 @@ public class WemoCoffeeHandler extends WemoBaseThingHandler {
|
||||
try {
|
||||
String soapHeader = "\"urn:Belkin:service:deviceevent:1#SetAttributes\"";
|
||||
|
||||
String content = "<?xml version=\"1.0\"?>"
|
||||
+ "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
|
||||
+ "<s:Body>" + "<u:SetAttributes xmlns:u=\"urn:Belkin:service:deviceevent:1\">"
|
||||
+ "<attributeList><attribute><name>Brewed</name><value>NULL</value></attribute>"
|
||||
+ "<attribute><name>LastCleaned</name><value>NULL</value></attribute><attribute>"
|
||||
+ "<name>ModeTime</name><value>NULL</value></attribute><attribute><name>Brewing</name>"
|
||||
+ "<value>NULL</value></attribute><attribute><name>TimeRemaining</name><value>NULL</value>"
|
||||
+ "</attribute><attribute><name>WaterLevelReached</name><value>NULL</value></attribute><"
|
||||
+ "attribute><name>Mode</name><value>4</value></attribute><attribute><name>CleanAdvise</name>"
|
||||
+ "<value>NULL</value></attribute><attribute><name>FilterAdvise</name><value>NULL</value></attribute>"
|
||||
+ "<attribute><name>Cleaning</name><value>NULL</value></attribute></attributeList>"
|
||||
+ "</u:SetAttributes>" + "</s:Body>" + "</s:Envelope>";
|
||||
String content = """
|
||||
<?xml version="1.0"?>\
|
||||
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
|
||||
<s:Body>\
|
||||
<u:SetAttributes xmlns:u="urn:Belkin:service:deviceevent:1">\
|
||||
<attributeList><attribute><name>Brewed</name><value>NULL</value></attribute>\
|
||||
<attribute><name>LastCleaned</name><value>NULL</value></attribute><attribute>\
|
||||
<name>ModeTime</name><value>NULL</value></attribute><attribute><name>Brewing</name>\
|
||||
<value>NULL</value></attribute><attribute><name>TimeRemaining</name><value>NULL</value>\
|
||||
</attribute><attribute><name>WaterLevelReached</name><value>NULL</value></attribute><\
|
||||
attribute><name>Mode</name><value>4</value></attribute><attribute><name>CleanAdvise</name>\
|
||||
<value>NULL</value></attribute><attribute><name>FilterAdvise</name><value>NULL</value></attribute>\
|
||||
<attribute><name>Cleaning</name><value>NULL</value></attribute></attributeList>\
|
||||
</u:SetAttributes>\
|
||||
</s:Body>\
|
||||
</s:Envelope>\
|
||||
""";
|
||||
|
||||
wemoHttpCaller.executeCall(wemoURL, soapHeader, content);
|
||||
updateState(CHANNEL_STATE, OnOffType.ON);
|
||||
|
||||
@@ -52,7 +52,7 @@ public class WemoCrockpotHandler extends WemoBaseThingHandler {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(WemoCrockpotHandler.class);
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_CROCKPOT);
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_CROCKPOT);
|
||||
|
||||
private final Object jobLock = new Object();
|
||||
|
||||
@@ -147,9 +147,13 @@ public class WemoCrockpotHandler extends WemoBaseThingHandler {
|
||||
}
|
||||
try {
|
||||
String soapHeader = "\"urn:Belkin:service:basicevent:1#SetBinaryState\"";
|
||||
String content = "<?xml version=\"1.0\"?>"
|
||||
+ "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
|
||||
+ "<s:Body>" + "<u:SetCrockpotState xmlns:u=\"urn:Belkin:service:basicevent:1\">" + "<mode>"
|
||||
String content = """
|
||||
<?xml version="1.0"?>\
|
||||
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
|
||||
<s:Body>\
|
||||
<u:SetCrockpotState xmlns:u="urn:Belkin:service:basicevent:1">\
|
||||
<mode>\
|
||||
"""
|
||||
+ mode + "</mode>" + "<time>" + time + "</time>" + "</u:SetCrockpotState>" + "</s:Body>"
|
||||
+ "</s:Envelope>";
|
||||
wemoHttpCaller.executeCall(wemoURL, soapHeader, content);
|
||||
|
||||
@@ -57,7 +57,7 @@ public class WemoDimmerHandler extends WemoBaseThingHandler {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(WemoDimmerHandler.class);
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_DIMMER);
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_DIMMER);
|
||||
|
||||
private final Object jobLock = new Object();
|
||||
|
||||
@@ -157,8 +157,8 @@ public class WemoDimmerHandler extends WemoBaseThingHandler {
|
||||
State brightnessState = new PercentType(currentBrightness);
|
||||
updateState(CHANNEL_BRIGHTNESS, brightnessState);
|
||||
}
|
||||
} else if (command instanceof PercentType) {
|
||||
int newBrightness = ((PercentType) command).intValue();
|
||||
} else if (command instanceof PercentType percentCommand) {
|
||||
int newBrightness = percentCommand.intValue();
|
||||
value = String.valueOf(newBrightness);
|
||||
currentBrightness = newBrightness;
|
||||
argument = "brightness";
|
||||
@@ -217,20 +217,36 @@ public class WemoDimmerHandler extends WemoBaseThingHandler {
|
||||
int commandValue = Integer.valueOf(String.valueOf(command));
|
||||
commandValue = commandValue * 60;
|
||||
String commandString = String.valueOf(commandValue);
|
||||
value = "<BinaryState></BinaryState>" + "<Duration></Duration>" + "<EndAction></EndAction>"
|
||||
+ "<brightness></brightness>" + "<fader>" + commandString + ":-1:1:0:0</fader>"
|
||||
+ "<UDN></UDN>";
|
||||
value = """
|
||||
<BinaryState></BinaryState>\
|
||||
<Duration></Duration>\
|
||||
<EndAction></EndAction>\
|
||||
<brightness></brightness>\
|
||||
<fader>\
|
||||
""" + commandString + ":-1:1:0:0</fader><UDN></UDN>";
|
||||
setBinaryState(action, argument, value);
|
||||
}
|
||||
break;
|
||||
case CHANNEL_FADER_ENABLED:
|
||||
argument = "Fader";
|
||||
if (command.equals(OnOffType.ON)) {
|
||||
value = "<BinaryState></BinaryState>" + "<Duration></Duration>" + "<EndAction></EndAction>"
|
||||
+ "<brightness></brightness>" + "<fader>600:-1:1:0:0</fader>" + "<UDN></UDN>";
|
||||
value = """
|
||||
<BinaryState></BinaryState>\
|
||||
<Duration></Duration>\
|
||||
<EndAction></EndAction>\
|
||||
<brightness></brightness>\
|
||||
<fader>600:-1:1:0:0</fader>\
|
||||
<UDN></UDN>\
|
||||
""";
|
||||
} else if (command.equals(OnOffType.OFF)) {
|
||||
value = "<BinaryState></BinaryState>" + "<Duration></Duration>" + "<EndAction></EndAction>"
|
||||
+ "<brightness></brightness>" + "<fader>600:-1:0:0:0</fader>" + "<UDN></UDN>";
|
||||
value = """
|
||||
<BinaryState></BinaryState>\
|
||||
<Duration></Duration>\
|
||||
<EndAction></EndAction>\
|
||||
<brightness></brightness>\
|
||||
<fader>600:-1:0:0:0</fader>\
|
||||
<UDN></UDN>\
|
||||
""";
|
||||
}
|
||||
setBinaryState(action, argument, value);
|
||||
break;
|
||||
@@ -253,14 +269,23 @@ public class WemoDimmerHandler extends WemoBaseThingHandler {
|
||||
}
|
||||
if (faderSeconds != null && faderEnabled != null) {
|
||||
if (OnOffType.ON.equals(command)) {
|
||||
value = "<BinaryState></BinaryState>" + "<Duration></Duration>" + "<EndAction></EndAction>"
|
||||
+ "<brightness></brightness>" + "<fader>" + faderSeconds + ":" + timeStamp + ":"
|
||||
+ faderEnabled + ":0:0</fader>" + "<UDN></UDN>";
|
||||
value = """
|
||||
<BinaryState></BinaryState>\
|
||||
<Duration></Duration>\
|
||||
<EndAction></EndAction>\
|
||||
<brightness></brightness>\
|
||||
<fader>\
|
||||
""" + faderSeconds + ":" + timeStamp + ":" + faderEnabled + ":0:0</fader>"
|
||||
+ "<UDN></UDN>";
|
||||
updateState(CHANNEL_STATE, OnOffType.ON);
|
||||
} else if (OnOffType.OFF.equals(command)) {
|
||||
value = "<BinaryState></BinaryState>" + "<Duration></Duration>" + "<EndAction></EndAction>"
|
||||
+ "<brightness></brightness>" + "<fader>" + faderSeconds + ":-1:" + faderEnabled
|
||||
+ ":0:0</fader>" + "<UDN></UDN>";
|
||||
value = """
|
||||
<BinaryState></BinaryState>\
|
||||
<Duration></Duration>\
|
||||
<EndAction></EndAction>\
|
||||
<brightness></brightness>\
|
||||
<fader>\
|
||||
""" + faderSeconds + ":-1:" + faderEnabled + ":0:0</fader>" + "<UDN></UDN>";
|
||||
}
|
||||
}
|
||||
setBinaryState(action, argument, value);
|
||||
@@ -281,8 +306,8 @@ public class WemoDimmerHandler extends WemoBaseThingHandler {
|
||||
case CHANNEL_NIGHT_MODE_BRIGHTNESS:
|
||||
action = "ConfigureNightMode";
|
||||
argument = "NightModeConfiguration";
|
||||
if (command instanceof PercentType) {
|
||||
int newBrightness = ((PercentType) command).intValue();
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
int newBrightness = percentCommand.intValue();
|
||||
String newNightModeBrightness = String.valueOf(newBrightness);
|
||||
value = "<startTime>0</startTime> \\n<nightMode>" + currentNightModeState
|
||||
+ "</nightMode> \\n<endTime>23400</endTime> \\n<nightModeBrightness>"
|
||||
@@ -361,7 +386,7 @@ public class WemoDimmerHandler extends WemoBaseThingHandler {
|
||||
updateState(CHANNEL_FADER_COUNT_DOWN_TIME, faderMinutes);
|
||||
}
|
||||
if (splitFader[1] != null) {
|
||||
State isTimerRunning = splitFader[1].equals("-1") ? OnOffType.OFF : OnOffType.ON;
|
||||
State isTimerRunning = "-1".equals(splitFader[1]) ? OnOffType.OFF : OnOffType.ON;
|
||||
logger.debug("isTimerRunning '{}' for device '{}' received", isTimerRunning,
|
||||
getThing().getUID());
|
||||
updateState(CHANNEL_TIMER_START, isTimerRunning);
|
||||
@@ -370,7 +395,7 @@ public class WemoDimmerHandler extends WemoBaseThingHandler {
|
||||
}
|
||||
}
|
||||
if (splitFader[2] != null) {
|
||||
State isFaderEnabled = splitFader[1].equals("0") ? OnOffType.OFF : OnOffType.ON;
|
||||
State isFaderEnabled = "0".equals(splitFader[1]) ? OnOffType.OFF : OnOffType.ON;
|
||||
logger.debug("isFaderEnabled '{}' for device '{}' received", isFaderEnabled,
|
||||
getThing().getUID());
|
||||
updateState(CHANNEL_FADER_ENABLED, isFaderEnabled);
|
||||
@@ -478,8 +503,7 @@ public class WemoDimmerHandler extends WemoBaseThingHandler {
|
||||
return null;
|
||||
}
|
||||
ZonedDateTime zoned = ZonedDateTime.ofInstant(Instant.ofEpochSecond(value), TimeZone.getDefault().toZoneId());
|
||||
State dateTimeState = new DateTimeType(zoned);
|
||||
return dateTimeState;
|
||||
return new DateTimeType(zoned);
|
||||
}
|
||||
|
||||
public void setBinaryState(String action, String argument, String value) {
|
||||
@@ -490,10 +514,14 @@ public class WemoDimmerHandler extends WemoBaseThingHandler {
|
||||
}
|
||||
try {
|
||||
String soapHeader = "\"urn:Belkin:service:basicevent:1#SetBinaryState\"";
|
||||
String content = "<?xml version=\"1.0\"?>"
|
||||
+ "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
|
||||
+ "<s:Body>" + "<u:" + action + " xmlns:u=\"urn:Belkin:service:basicevent:1\">" + "<" + argument
|
||||
+ ">" + value + "</" + argument + ">" + "</u:" + action + ">" + "</s:Body>" + "</s:Envelope>";
|
||||
String content = """
|
||||
<?xml version="1.0"?>\
|
||||
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
|
||||
<s:Body>\
|
||||
<u:\
|
||||
"""
|
||||
+ action + " xmlns:u=\"urn:Belkin:service:basicevent:1\">" + "<" + argument + ">" + value + "</"
|
||||
+ argument + ">" + "</u:" + action + ">" + "</s:Body>" + "</s:Envelope>";
|
||||
|
||||
wemoHttpCaller.executeCall(wemoURL, soapHeader, content);
|
||||
updateStatus(ThingStatus.ONLINE);
|
||||
@@ -512,10 +540,13 @@ public class WemoDimmerHandler extends WemoBaseThingHandler {
|
||||
}
|
||||
try {
|
||||
String soapHeader = "\"urn:Belkin:service:basicevent:1#SetBinaryState\"";
|
||||
String content = "<?xml version=\"1.0\"?>"
|
||||
+ "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
|
||||
+ "<s:Body>" + "<u:SetBinaryState xmlns:u=\"urn:Belkin:service:basicevent:1\">" + value
|
||||
+ "</u:SetBinaryState>" + "</s:Body>" + "</s:Envelope>";
|
||||
String content = """
|
||||
<?xml version="1.0"?>\
|
||||
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
|
||||
<s:Body>\
|
||||
<u:SetBinaryState xmlns:u="urn:Belkin:service:basicevent:1">\
|
||||
"""
|
||||
+ value + "</u:SetBinaryState>" + "</s:Body>" + "</s:Envelope>";
|
||||
wemoHttpCaller.executeCall(wemoURL, soapHeader, content);
|
||||
updateStatus(ThingStatus.ONLINE);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -63,7 +63,7 @@ public class WemoHolmesHandler extends WemoBaseThingHandler {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(WemoHolmesHandler.class);
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_PURIFIER);
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_PURIFIER);
|
||||
|
||||
private static final int FILTER_LIFE_DAYS = 330;
|
||||
private static final int FILTER_LIFE_MINS = FILTER_LIFE_DAYS * 24 * 60;
|
||||
@@ -239,10 +239,14 @@ public class WemoHolmesHandler extends WemoBaseThingHandler {
|
||||
}
|
||||
try {
|
||||
String soapHeader = "\"urn:Belkin:service:deviceevent:1#SetAttributes\"";
|
||||
String content = "<?xml version=\"1.0\"?>"
|
||||
+ "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
|
||||
+ "<s:Body>" + "<u:SetAttributes xmlns:u=\"urn:Belkin:service:deviceevent:1\">"
|
||||
+ "<attributeList><attribute><name>" + attribute + "</name><value>" + value
|
||||
String content = """
|
||||
<?xml version="1.0"?>\
|
||||
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
|
||||
<s:Body>\
|
||||
<u:SetAttributes xmlns:u="urn:Belkin:service:deviceevent:1">\
|
||||
<attributeList><attribute><name>\
|
||||
"""
|
||||
+ attribute + "</name><value>" + value
|
||||
+ "</value></attribute></attributeList>" + "</u:SetAttributes>" + "</s:Body>"
|
||||
+ "</s:Envelope>";
|
||||
wemoHttpCaller.executeCall(wemoURL, soapHeader, content);
|
||||
|
||||
@@ -126,8 +126,8 @@ public class WemoLightHandler extends WemoBaseThingHandler {
|
||||
return null;
|
||||
}
|
||||
ThingHandler handler = bridge.getHandler();
|
||||
if (handler instanceof WemoBridgeHandler) {
|
||||
this.wemoBridgeHandler = (WemoBridgeHandler) handler;
|
||||
if (handler instanceof WemoBridgeHandler wemoBridgeHandler) {
|
||||
this.wemoBridgeHandler = wemoBridgeHandler;
|
||||
} else {
|
||||
logger.debug("No available bridge handler found for {} bridge {} .", wemoLightID, bridge.getUID());
|
||||
return null;
|
||||
@@ -187,8 +187,8 @@ public class WemoLightHandler extends WemoBaseThingHandler {
|
||||
switch (channelUID.getId()) {
|
||||
case CHANNEL_BRIGHTNESS:
|
||||
capability = "10008";
|
||||
if (command instanceof PercentType) {
|
||||
int newBrightness = ((PercentType) command).intValue();
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
int newBrightness = percentCommand.intValue();
|
||||
logger.trace("wemoLight received Value {}", newBrightness);
|
||||
int value1 = Math.round(newBrightness * 255 / 100);
|
||||
value = value1 + ":0";
|
||||
@@ -239,11 +239,14 @@ public class WemoLightHandler extends WemoBaseThingHandler {
|
||||
try {
|
||||
if (capability != null && value != null) {
|
||||
String soapHeader = "\"urn:Belkin:service:bridge:1#SetDeviceStatus\"";
|
||||
String content = "<?xml version=\"1.0\"?>"
|
||||
+ "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
|
||||
+ "<s:Body>" + "<u:SetDeviceStatus xmlns:u=\"urn:Belkin:service:bridge:1\">"
|
||||
+ "<DeviceStatusList>"
|
||||
+ "<?xml version="1.0" encoding="UTF-8"?><DeviceStatus><DeviceID>"
|
||||
String content = """
|
||||
<?xml version="1.0"?>\
|
||||
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
|
||||
<s:Body>\
|
||||
<u:SetDeviceStatus xmlns:u="urn:Belkin:service:bridge:1">\
|
||||
<DeviceStatusList>\
|
||||
<?xml version="1.0" encoding="UTF-8"?><DeviceStatus><DeviceID>\
|
||||
"""
|
||||
+ wemoLightID
|
||||
+ "</DeviceID><IsGroupAction>NO</IsGroupAction><CapabilityID>"
|
||||
+ capability + "</CapabilityID><CapabilityValue>" + value
|
||||
@@ -289,9 +292,13 @@ public class WemoLightHandler extends WemoBaseThingHandler {
|
||||
}
|
||||
try {
|
||||
String soapHeader = "\"urn:Belkin:service:bridge:1#GetDeviceStatus\"";
|
||||
String content = "<?xml version=\"1.0\"?>"
|
||||
+ "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
|
||||
+ "<s:Body>" + "<u:GetDeviceStatus xmlns:u=\"urn:Belkin:service:bridge:1\">" + "<DeviceIDs>"
|
||||
String content = """
|
||||
<?xml version="1.0"?>\
|
||||
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
|
||||
<s:Body>\
|
||||
<u:GetDeviceStatus xmlns:u="urn:Belkin:service:bridge:1">\
|
||||
<DeviceIDs>\
|
||||
"""
|
||||
+ wemoLightID + "</DeviceIDs>" + "</u:GetDeviceStatus>" + "</s:Body>" + "</s:Envelope>";
|
||||
|
||||
String wemoCallResponse = wemoHttpCaller.executeCall(wemoURL, soapHeader, content);
|
||||
@@ -305,7 +312,7 @@ public class WemoLightHandler extends WemoBaseThingHandler {
|
||||
updateState(CHANNEL_STATE, binaryState);
|
||||
}
|
||||
if (splitResponse[1] != null) {
|
||||
String splitBrightness[] = splitResponse[1].split(":");
|
||||
String[] splitBrightness = splitResponse[1].split(":");
|
||||
if (splitBrightness[0] != null) {
|
||||
int newBrightnessValue = Integer.valueOf(splitBrightness[0]);
|
||||
int newBrightness = Math.round(newBrightnessValue * 100 / 255);
|
||||
@@ -335,7 +342,7 @@ public class WemoLightHandler extends WemoBaseThingHandler {
|
||||
updateState(CHANNEL_STATE, binaryState);
|
||||
break;
|
||||
case "10008":
|
||||
String splitValue[] = newValue.split(":");
|
||||
String[] splitValue = newValue.split(":");
|
||||
if (splitValue[0] != null) {
|
||||
int newBrightnessValue = Integer.valueOf(splitValue[0]);
|
||||
int newBrightness = Math.round(newBrightnessValue * 100 / 255);
|
||||
|
||||
@@ -16,7 +16,6 @@ import static org.openhab.binding.wemo.internal.WemoBindingConstants.*;
|
||||
import static org.openhab.binding.wemo.internal.WemoUtil.*;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -56,7 +55,7 @@ public class WemoMakerHandler extends WemoBaseThingHandler {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(WemoMakerHandler.class);
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_MAKER);
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_MAKER);
|
||||
|
||||
private final Object jobLock = new Object();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user