mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Java 17 features (H-M) (#15520)
- 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:
parent
3751fd0646
commit
edaf17b345
@ -82,11 +82,9 @@ public class HaasSohnpelletstoveHandler extends BaseThingHandler {
|
||||
updateOvenData(postData);
|
||||
}
|
||||
} else if (channelUID.getId().equals(CHANNELSPTEMP)) {
|
||||
if (command instanceof QuantityType<?>) {
|
||||
QuantityType<?> value = (QuantityType<?>) command;
|
||||
|
||||
if (command instanceof QuantityType<?> quantityCommand) {
|
||||
Unit<Temperature> unit = SIUnits.CELSIUS;
|
||||
value = value.toUnit(unit);
|
||||
QuantityType<?> value = quantityCommand.toUnit(unit);
|
||||
if (value != null) {
|
||||
double a = value.doubleValue();
|
||||
String postdata = "{\"sp_temp\":" + a + "}";
|
||||
|
@ -38,8 +38,7 @@ public class MD5Utils {
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
byte[] result = md.digest(input);
|
||||
return result;
|
||||
return md.digest(input);
|
||||
}
|
||||
|
||||
private static String bytesToHex(byte[] bytes) {
|
||||
|
@ -15,7 +15,6 @@ package org.openhab.binding.harmonyhub.internal.handler;
|
||||
import static org.openhab.binding.harmonyhub.internal.HarmonyHubBindingConstants.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -65,7 +64,7 @@ public class HarmonyDeviceHandler extends BaseThingHandler {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(HarmonyDeviceHandler.class);
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(HARMONY_DEVICE_THING_TYPE);
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(HARMONY_DEVICE_THING_TYPE);
|
||||
|
||||
private final HarmonyHubDynamicTypeProvider typeProvider;
|
||||
|
||||
|
@ -126,9 +126,9 @@ public class HarmonyHubHandler extends BaseBridgeHandler implements HarmonyClien
|
||||
|
||||
switch (channel.getUID().getId()) {
|
||||
case CHANNEL_CURRENT_ACTIVITY:
|
||||
if (command instanceof DecimalType) {
|
||||
if (command instanceof DecimalType decimalCommand) {
|
||||
try {
|
||||
client.startActivity(((DecimalType) command).intValue());
|
||||
client.startActivity(decimalCommand.intValue());
|
||||
} catch (Exception e) {
|
||||
logger.warn("Could not start activity", e);
|
||||
}
|
||||
|
@ -174,11 +174,13 @@ public class HaywardBindingConstants {
|
||||
// Hayward Command html
|
||||
public static final String COMMAND_PARAMETERS = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Request>";
|
||||
|
||||
public static final String COMMAND_SCHEDULE = "<Parameter name=\"IsCountDownTimer\" dataType=\"bool\">false</Parameter>"
|
||||
+ "<Parameter name=\"StartTimeHours\" dataType=\"int\">0</Parameter>"
|
||||
+ "<Parameter name=\"StartTimeMinutes\" dataType=\"int\">0</Parameter>"
|
||||
+ "<Parameter name=\"EndTimeHours\" dataType=\"int\">0</Parameter>"
|
||||
+ "<Parameter name=\"EndTimeMinutes\" dataType=\"int\">0</Parameter>"
|
||||
+ "<Parameter name=\"DaysActive\" dataType=\"int\">0</Parameter>"
|
||||
+ "<Parameter name=\"Recurring\" dataType=\"bool\">false</Parameter>";
|
||||
public static final String COMMAND_SCHEDULE = """
|
||||
<Parameter name="IsCountDownTimer" dataType="bool">false</Parameter>\
|
||||
<Parameter name="StartTimeHours" dataType="int">0</Parameter>\
|
||||
<Parameter name="StartTimeMinutes" dataType="int">0</Parameter>\
|
||||
<Parameter name="EndTimeHours" dataType="int">0</Parameter>\
|
||||
<Parameter name="EndTimeMinutes" dataType="int">0</Parameter>\
|
||||
<Parameter name="DaysActive" dataType="int">0</Parameter>\
|
||||
<Parameter name="Recurring" dataType="bool">false</Parameter>\
|
||||
""";
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public abstract class HaywardThingHandler extends BaseThingHandler {
|
||||
if (bridge != null) {
|
||||
HaywardBridgeHandler bridgehandler = (HaywardBridgeHandler) bridge.getHandler();
|
||||
if (bridgehandler != null) {
|
||||
if (bridgehandler.account.units.equals("Standard")) {
|
||||
if ("Standard".equals(bridgehandler.account.units)) {
|
||||
return new QuantityType<>(Integer.parseInt(value), ImperialUnits.FAHRENHEIT);
|
||||
} else {
|
||||
return new QuantityType<>(Integer.parseInt(value), SIUnits.CELSIUS);
|
||||
@ -112,10 +112,10 @@ public abstract class HaywardThingHandler extends BaseThingHandler {
|
||||
return "0";
|
||||
} else if (command == OnOffType.ON) {
|
||||
return "1";
|
||||
} else if (command instanceof DecimalType) {
|
||||
return ((DecimalType) command).toString();
|
||||
} else if (command instanceof QuantityType) {
|
||||
return ((QuantityType<?>) command).format("%1.0f");
|
||||
} else if (command instanceof DecimalType decimalCommand) {
|
||||
return decimalCommand.toString();
|
||||
} else if (command instanceof QuantityType quantityCommand) {
|
||||
return quantityCommand.format("%1.0f");
|
||||
} else {
|
||||
return command.toString();
|
||||
}
|
||||
|
@ -349,8 +349,8 @@ public class HaywardDiscoveryService extends AbstractDiscoveryService implements
|
||||
|
||||
@Override
|
||||
public void setThingHandler(@Nullable ThingHandler handler) {
|
||||
if (handler instanceof HaywardBridgeHandler) {
|
||||
this.discoveryBridgehandler = (HaywardBridgeHandler) handler;
|
||||
if (handler instanceof HaywardBridgeHandler bridgeHandler) {
|
||||
this.discoveryBridgehandler = bridgeHandler;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,10 +83,12 @@ public class HaywardBackyardHandler extends HaywardThingHandler {
|
||||
HaywardBridgeHandler bridgehandler = (HaywardBridgeHandler) bridge.getHandler();
|
||||
if (bridgehandler != null) {
|
||||
// *****Request Alarm List from Hayward server
|
||||
String urlParameters = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Request><Name>GetAlarmList</Name><Parameters>"
|
||||
+ "<Parameter name=\"Token\" dataType=\"String\">" + bridgehandler.account.token
|
||||
+ "</Parameter>" + "<Parameter name=\"MspSystemID\" dataType=\"int\">"
|
||||
+ bridgehandler.account.mspSystemID + "</Parameter>"
|
||||
String urlParameters = """
|
||||
<?xml version="1.0" encoding="utf-8"?><Request><Name>GetAlarmList</Name><Parameters>\
|
||||
<Parameter name="Token" dataType="String">\
|
||||
""" + bridgehandler.account.token + "</Parameter>"
|
||||
+ "<Parameter name=\"MspSystemID\" dataType=\"int\">" + bridgehandler.account.mspSystemID
|
||||
+ "</Parameter>"
|
||||
+ "<Parameter name=\"CultureInfoName\" dataType=\"String\">en-us</Parameter></Parameters></Request>";
|
||||
|
||||
try {
|
||||
|
@ -15,9 +15,9 @@ package org.openhab.binding.haywardomnilogic.internal.handler;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -82,7 +82,7 @@ public class HaywardBridgeHandler extends BaseBridgeHandler {
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(HaywardDiscoveryService.class);
|
||||
return Set.of(HaywardDiscoveryService.class);
|
||||
}
|
||||
|
||||
public HaywardBridgeHandler(HaywardDynamicStateDescriptionProvider stateDescriptionProvider, Bridge bridge,
|
||||
@ -191,10 +191,12 @@ public class HaywardBridgeHandler extends BaseBridgeHandler {
|
||||
String status;
|
||||
|
||||
// *****Login to Hayward server
|
||||
String urlParameters = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Request>" + "<Name>Login</Name><Parameters>"
|
||||
+ "<Parameter name=\"UserName\" dataType=\"String\">" + config.username + "</Parameter>"
|
||||
+ "<Parameter name=\"Password\" dataType=\"String\">" + config.password + "</Parameter>"
|
||||
+ "</Parameters></Request>";
|
||||
String urlParameters = """
|
||||
<?xml version="1.0" encoding="utf-8"?><Request>\
|
||||
<Name>Login</Name><Parameters>\
|
||||
<Parameter name="UserName" dataType="String">\
|
||||
""" + config.username + "</Parameter>" + "<Parameter name=\"Password\" dataType=\"String\">"
|
||||
+ config.password + "</Parameter>" + "</Parameters></Request>";
|
||||
|
||||
xmlResponse = httpXmlResponse(urlParameters);
|
||||
|
||||
@ -219,9 +221,11 @@ public class HaywardBridgeHandler extends BaseBridgeHandler {
|
||||
String xmlResponse;
|
||||
|
||||
// *****getApiDef from Hayward server
|
||||
String urlParameters = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Request><Name>GetAPIDef</Name><Parameters>"
|
||||
+ "<Parameter name=\"Token\" dataType=\"String\">" + account.token + "</Parameter>"
|
||||
+ "<Parameter name=\"MspSystemID\" dataType=\"int\">" + account.mspSystemID + "</Parameter>;"
|
||||
String urlParameters = """
|
||||
<?xml version="1.0" encoding="utf-8"?><Request><Name>GetAPIDef</Name><Parameters>\
|
||||
<Parameter name="Token" dataType="String">\
|
||||
""" + account.token + "</Parameter>" + "<Parameter name=\"MspSystemID\" dataType=\"int\">"
|
||||
+ account.mspSystemID + "</Parameter>;"
|
||||
+ "<Parameter name=\"Version\" dataType=\"string\">0.4</Parameter >\r\n"
|
||||
+ "<Parameter name=\"Language\" dataType=\"string\">en</Parameter >\r\n" + "</Parameters></Request>";
|
||||
|
||||
@ -239,9 +243,10 @@ public class HaywardBridgeHandler extends BaseBridgeHandler {
|
||||
String status;
|
||||
|
||||
// *****Get MSP
|
||||
String urlParameters = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Request><Name>GetSiteList</Name><Parameters>"
|
||||
+ "<Parameter name=\"Token\" dataType=\"String\">" + account.token
|
||||
+ "</Parameter><Parameter name=\"UserID\" dataType=\"String\">" + account.userID
|
||||
String urlParameters = """
|
||||
<?xml version="1.0" encoding="utf-8"?><Request><Name>GetSiteList</Name><Parameters>\
|
||||
<Parameter name="Token" dataType="String">\
|
||||
""" + account.token + "</Parameter><Parameter name=\"UserID\" dataType=\"String\">" + account.userID
|
||||
+ "</Parameter></Parameters></Request>";
|
||||
|
||||
xmlResponse = httpXmlResponse(urlParameters);
|
||||
@ -269,10 +274,11 @@ public class HaywardBridgeHandler extends BaseBridgeHandler {
|
||||
|
||||
public synchronized String getMspConfig() throws HaywardException, InterruptedException {
|
||||
// *****getMspConfig from Hayward server
|
||||
String urlParameters = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Request><Name>GetMspConfigFile</Name><Parameters>"
|
||||
+ "<Parameter name=\"Token\" dataType=\"String\">" + account.token + "</Parameter>"
|
||||
+ "<Parameter name=\"MspSystemID\" dataType=\"int\">" + account.mspSystemID
|
||||
+ "</Parameter><Parameter name=\"Version\" dataType=\"string\">0</Parameter>\r\n"
|
||||
String urlParameters = """
|
||||
<?xml version="1.0" encoding="utf-8"?><Request><Name>GetMspConfigFile</Name><Parameters>\
|
||||
<Parameter name="Token" dataType="String">\
|
||||
""" + account.token + "</Parameter>" + "<Parameter name=\"MspSystemID\" dataType=\"int\">"
|
||||
+ account.mspSystemID + "</Parameter><Parameter name=\"Version\" dataType=\"string\">0</Parameter>\r\n"
|
||||
+ "</Parameters></Request>";
|
||||
|
||||
String xmlResponse = httpXmlResponse(urlParameters);
|
||||
@ -312,10 +318,11 @@ public class HaywardBridgeHandler extends BaseBridgeHandler {
|
||||
|
||||
public synchronized boolean getTelemetryData() throws HaywardException, InterruptedException {
|
||||
// *****getTelemetry from Hayward server
|
||||
String urlParameters = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Request><Name>GetTelemetryData</Name><Parameters>"
|
||||
+ "<Parameter name=\"Token\" dataType=\"String\">" + account.token + "</Parameter>"
|
||||
+ "<Parameter name=\"MspSystemID\" dataType=\"int\">" + account.mspSystemID
|
||||
+ "</Parameter></Parameters></Request>";
|
||||
String urlParameters = """
|
||||
<?xml version="1.0" encoding="utf-8"?><Request><Name>GetTelemetryData</Name><Parameters>\
|
||||
<Parameter name="Token" dataType="String">\
|
||||
""" + account.token + "</Parameter>" + "<Parameter name=\"MspSystemID\" dataType=\"int\">"
|
||||
+ account.mspSystemID + "</Parameter></Parameters></Request>";
|
||||
|
||||
String xmlResponse = httpXmlResponse(urlParameters);
|
||||
|
||||
|
@ -90,7 +90,7 @@ public class HaywardChlorinatorHandler extends HaywardThingHandler {
|
||||
data = bridgehandler.evaluateXPath("//Chlorinator/@status", xmlResponse);
|
||||
updateData(HaywardBindingConstants.CHANNEL_CHLORINATOR_STATUS, data.get(i));
|
||||
|
||||
if (data.get(i).equals("0")) {
|
||||
if ("0".equals(data.get(i))) {
|
||||
updateData(HaywardBindingConstants.CHANNEL_CHLORINATOR_ENABLE, "0");
|
||||
// chlorState is used to set the chlorinator cfgState in the timedPercent command
|
||||
this.chlorState = "2";
|
||||
|
@ -60,7 +60,7 @@ public class HaywardColorLogicHandler extends HaywardThingHandler {
|
||||
data = bridgehandler.evaluateXPath("//ColorLogic-Light/@lightState", xmlResponse);
|
||||
updateData(HaywardBindingConstants.CHANNEL_COLORLOGIC_LIGHTSTATE, data.get(i));
|
||||
|
||||
if (data.get(i).equals("0")) {
|
||||
if ("0".equals(data.get(i))) {
|
||||
updateData(HaywardBindingConstants.CHANNEL_COLORLOGIC_ENABLE, "0");
|
||||
} else {
|
||||
updateData(HaywardBindingConstants.CHANNEL_COLORLOGIC_ENABLE, "1");
|
||||
|
@ -154,7 +154,7 @@ public class HaywardFilterHandler extends HaywardThingHandler {
|
||||
updateData(HaywardBindingConstants.CHANNEL_FILTER_SPEEDRPM, rpmSpeed.toString());
|
||||
}
|
||||
|
||||
if (data.get(i).equals("0")) {
|
||||
if ("0".equals(data.get(i))) {
|
||||
updateData(HaywardBindingConstants.CHANNEL_FILTER_ENABLE, "0");
|
||||
} else {
|
||||
updateData(HaywardBindingConstants.CHANNEL_FILTER_ENABLE, "1");
|
||||
|
@ -58,7 +58,7 @@ public class HaywardHeaterHandler extends HaywardThingHandler {
|
||||
|
||||
// Enable
|
||||
data = bridgehandler.evaluateXPath("//Heater/@enable", xmlResponse);
|
||||
if (data.get(i).equals("0")) {
|
||||
if ("0".equals(data.get(i))) {
|
||||
updateData(HaywardBindingConstants.CHANNEL_HEATER_ENABLE, "0");
|
||||
} else {
|
||||
updateData(HaywardBindingConstants.CHANNEL_HEATER_ENABLE, "1");
|
||||
|
@ -150,7 +150,7 @@ public class HaywardPumpHandler extends HaywardThingHandler {
|
||||
updateData(HaywardBindingConstants.CHANNEL_PUMP_SPEEDRPM, rpmSpeed.toString());
|
||||
}
|
||||
|
||||
if (data.get(i).equals("0")) {
|
||||
if ("0".equals(data.get(i))) {
|
||||
updateData(HaywardBindingConstants.CHANNEL_PUMP_ENABLE, "0");
|
||||
} else {
|
||||
updateData(HaywardBindingConstants.CHANNEL_PUMP_ENABLE, "1");
|
||||
|
@ -95,9 +95,9 @@ public class HaywardVirtualHeaterHandler extends HaywardThingHandler {
|
||||
updateData(HaywardBindingConstants.CHANNEL_VIRTUALHEATER_CURRENTSETPOINT, data.get(i));
|
||||
|
||||
data = bridgehandler.evaluateXPath("//VirtualHeater/@enable", xmlResponse);
|
||||
if (data.get(i).equals("yes")) {
|
||||
if ("yes".equals(data.get(i))) {
|
||||
updateData(HaywardBindingConstants.CHANNEL_VIRTUALHEATER_ENABLE, "1");
|
||||
} else if (data.get(i).equals("no")) {
|
||||
} else if ("no".equals(data.get(i))) {
|
||||
updateData(HaywardBindingConstants.CHANNEL_VIRTUALHEATER_ENABLE, "0");
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ package org.openhab.binding.hccrubbishcollection.internal;
|
||||
|
||||
import static org.openhab.binding.hccrubbishcollection.internal.HCCRubbishCollectionBindingConstants.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
@ -41,7 +40,7 @@ import org.osgi.service.component.annotations.Reference;
|
||||
public class HCCRubbishCollectionHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
private final HttpClient httpClient;
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_COLLECTION);
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_COLLECTION);
|
||||
|
||||
@Activate
|
||||
public HCCRubbishCollectionHandlerFactory(final @Reference HttpClientFactory httpClientFactory) {
|
||||
|
@ -143,7 +143,7 @@ public class Mhub4K431Handler extends BaseThingHandler {
|
||||
|
||||
String content = "{CMD=";
|
||||
content = content + command.toString() + "B";
|
||||
content = content + String.valueOf(outputPort) + ".";
|
||||
content = content + outputPort + ".";
|
||||
|
||||
InputStream stream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
|
@ -114,11 +114,11 @@ public class MultiroomPlusHandler extends BaseThingHandler {
|
||||
String httpMethod = "GET";
|
||||
String url = "http://" + host + "/switch.cgi?command=3&data0=";
|
||||
|
||||
url = url + String.valueOf(outputPort) + "&data1=";
|
||||
url = url + outputPort + "&data1=";
|
||||
url = url + command.toString() + "&checksum=";
|
||||
|
||||
int checksum = 3 + outputPort + sourcePort;
|
||||
url = url + String.valueOf(checksum);
|
||||
url = url + checksum;
|
||||
|
||||
try {
|
||||
HttpUtil.executeUrl(httpMethod, url, null, null, null, timeout);
|
||||
|
@ -422,7 +422,7 @@ public class GatewayWebTargets implements Closeable, HostnameVerifier {
|
||||
* @throws HubProcessingException if any error occurs.
|
||||
*/
|
||||
public void stopShade(int shadeId) throws HubProcessingException {
|
||||
invoke(HttpMethod.PUT, shadeStop, Query.of(IDS, Integer.valueOf(shadeId).toString()), null);
|
||||
invoke(HttpMethod.PUT, shadeStop, Query.of(IDS, Integer.toString(shadeId)), null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -147,10 +147,8 @@ public class AutomationChannelBuilder extends BaseChannelBuilder {
|
||||
String label = getScheduledEventName(referencedName, scheduledEvent);
|
||||
String description = translationProvider.getText("dynamic-channel.automation-enabled.description",
|
||||
referencedName);
|
||||
Channel channel = ChannelBuilder.create(channelUid, CoreItemFactory.SWITCH).withType(channelTypeUid)
|
||||
.withLabel(label).withDescription(description).build();
|
||||
|
||||
return channel;
|
||||
return ChannelBuilder.create(channelUid, CoreItemFactory.SWITCH).withType(channelTypeUid).withLabel(label)
|
||||
.withDescription(description).build();
|
||||
}
|
||||
|
||||
private @Nullable String getReferencedSceneOrSceneCollectionName(ScheduledEvent scheduledEvent) {
|
||||
|
@ -67,9 +67,9 @@ public class HDPowerViewCommandExtension extends AbstractConsoleCommandExtension
|
||||
|
||||
for (Thing thing : thingRegistry.getAll()) {
|
||||
ThingHandler thingHandler = thing.getHandler();
|
||||
if (thingHandler instanceof HDPowerViewHubHandler) {
|
||||
if (thingHandler instanceof HDPowerViewHubHandler hubHandler) {
|
||||
console.println("Generation 1/2 API hub: " + thing.getLabel());
|
||||
HDPowerViewWebTargets webTargets = ((HDPowerViewHubHandler) thingHandler).getWebTargets();
|
||||
HDPowerViewWebTargets webTargets = hubHandler.getWebTargets();
|
||||
|
||||
try {
|
||||
List<ShadeData> shades = webTargets.getShades().shadeData;
|
||||
@ -90,9 +90,9 @@ public class HDPowerViewCommandExtension extends AbstractConsoleCommandExtension
|
||||
} catch (HubException e) {
|
||||
console.println("Error retrieving ID's: " + e.getMessage());
|
||||
}
|
||||
} else if (thingHandler instanceof GatewayBridgeHandler) {
|
||||
} else if (thingHandler instanceof GatewayBridgeHandler gatewayHandler) {
|
||||
console.println("Generation 3 API gateway: " + thing.getLabel());
|
||||
GatewayWebTargets webTargets = ((GatewayBridgeHandler) thingHandler).getWebTargets();
|
||||
GatewayWebTargets webTargets = gatewayHandler.getWebTargets();
|
||||
|
||||
try {
|
||||
List<Shade> shades = webTargets.getShades();
|
||||
|
@ -418,9 +418,9 @@ public class ShadeCapabilitiesDatabase {
|
||||
* @param propertyValue
|
||||
*/
|
||||
public void logPropertyMismatch(String propertyKey, int type, int capabilities, boolean propertyValue) {
|
||||
logger.warn(
|
||||
"The '{}:{}' property actually reported by shade 'type:{}' is different "
|
||||
+ "than expected from its 'capabilities:{}' in the database!{}",
|
||||
propertyKey, propertyValue, type, capabilities, REQUEST_DEVELOPERS_TO_UPDATE);
|
||||
logger.warn("""
|
||||
The '{}:{}' property actually reported by shade 'type:{}' is different \
|
||||
than expected from its 'capabilities:{}' in the database!{}\
|
||||
""", propertyKey, propertyValue, type, capabilities, REQUEST_DEVELOPERS_TO_UPDATE);
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
package org.openhab.binding.hdpowerview.internal.discovery;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -55,7 +55,7 @@ public class HDPowerViewDeviceDiscoveryService extends AbstractDiscoveryService
|
||||
private final ShadeCapabilitiesDatabase db = new ShadeCapabilitiesDatabase();
|
||||
|
||||
public HDPowerViewDeviceDiscoveryService(HDPowerViewHubHandler hub) {
|
||||
super(Collections.singleton(HDPowerViewBindingConstants.THING_TYPE_SHADE), 60, true);
|
||||
super(Set.of(HDPowerViewBindingConstants.THING_TYPE_SHADE), 60, true);
|
||||
this.hub = hub;
|
||||
this.scanner = createScanner();
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ package org.openhab.binding.hdpowerview.internal.discovery;
|
||||
|
||||
import static org.openhab.binding.hdpowerview.internal.HDPowerViewBindingConstants.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.jmdns.ServiceInfo;
|
||||
@ -46,7 +45,7 @@ public class HDPowerViewHubDiscoveryParticipant implements MDNSDiscoveryParticip
|
||||
|
||||
@Override
|
||||
public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
|
||||
return Collections.singleton(THING_TYPE_HUB);
|
||||
return Set.of(THING_TYPE_HUB);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,7 +15,7 @@ package org.openhab.binding.hdpowerview.internal.discovery;
|
||||
import static org.openhab.binding.hdpowerview.internal.HDPowerViewBindingConstants.*;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -48,7 +48,7 @@ public class HDPowerViewHubDiscoveryService extends AbstractDiscoveryService {
|
||||
private @Nullable ScheduledFuture<?> backgroundFuture;
|
||||
|
||||
public HDPowerViewHubDiscoveryService() {
|
||||
super(Collections.singleton(THING_TYPE_HUB), 60, true);
|
||||
super(Set.of(THING_TYPE_HUB), 60, true);
|
||||
scanner = createScanner();
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
*/
|
||||
package org.openhab.binding.hdpowerview.internal.discovery;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -44,7 +44,7 @@ public class ShadeDiscoveryService extends AbstractDiscoveryService {
|
||||
private @Nullable ScheduledFuture<?> backgroundFuture;
|
||||
|
||||
public ShadeDiscoveryService(GatewayBridgeHandler hub) {
|
||||
super(Collections.singleton(HDPowerViewBindingConstants.THING_TYPE_SHADE3), 60, true);
|
||||
super(Set.of(HDPowerViewBindingConstants.THING_TYPE_SHADE3), 60, true);
|
||||
this.hub = hub;
|
||||
this.scanner = createScanner();
|
||||
}
|
||||
|
@ -85,8 +85,8 @@ public class ShadePosition {
|
||||
if (shadeCapabilities.supportsPrimary() && shadeCapabilities.supportsSecondary()) {
|
||||
// on dual rail shades constrain percent to not move the lower rail above the upper
|
||||
State secondary = getState(shadeCapabilities, SECONDARY_POSITION);
|
||||
if (secondary instanceof PercentType) {
|
||||
int secPercent = ((PercentType) secondary).intValue();
|
||||
if (secondary instanceof PercentType percentCommand) {
|
||||
int secPercent = percentCommand.intValue();
|
||||
if (percent < secPercent) {
|
||||
percent = secPercent;
|
||||
}
|
||||
@ -221,8 +221,8 @@ public class ShadePosition {
|
||||
if (shadeCapabilities.supportsPrimary() && shadeCapabilities.supportsSecondary()) {
|
||||
// on dual rail shades constrain percent to not move the upper rail below the lower
|
||||
State primary = getState(shadeCapabilities, PRIMARY_POSITION);
|
||||
if (primary instanceof PercentType) {
|
||||
int primaryPercent = ((PercentType) primary).intValue();
|
||||
if (primary instanceof PercentType percentCommand) {
|
||||
int primaryPercent = percentCommand.intValue();
|
||||
if (percent > primaryPercent) {
|
||||
percent = primaryPercent;
|
||||
}
|
||||
|
@ -20,5 +20,5 @@ package org.openhab.binding.hdpowerview.internal.dto.gen3;
|
||||
public enum PowerType {
|
||||
BATTERY,
|
||||
HARDWIRED,
|
||||
RECHARGEABLE;
|
||||
RECHARGEABLE
|
||||
}
|
||||
|
@ -88,8 +88,8 @@ public class GatewayBridgeHandler extends BaseBridgeHandler {
|
||||
|
||||
@Override
|
||||
public void childHandlerInitialized(ThingHandler childHandler, Thing childThing) {
|
||||
if (childHandler instanceof ShadeThingHandler) {
|
||||
refreshShade(((ShadeThingHandler) childHandler).getShadeId());
|
||||
if (childHandler instanceof ShadeThingHandler shadeThingHandler) {
|
||||
refreshShade(shadeThingHandler.getShadeId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -601,8 +601,8 @@ public class HDPowerViewHubHandler extends BaseBridgeHandler {
|
||||
continue;
|
||||
}
|
||||
ThingHandler handler = thing.getHandler();
|
||||
if (handler instanceof HDPowerViewShadeHandler) {
|
||||
((HDPowerViewShadeHandler) handler).requestRefreshShadePosition();
|
||||
if (handler instanceof HDPowerViewShadeHandler shadeHandler) {
|
||||
shadeHandler.requestRefreshShadePosition();
|
||||
} else {
|
||||
int shadeId = item.getValue();
|
||||
logger.debug("Shade '{}' handler not initialized", shadeId);
|
||||
@ -620,8 +620,8 @@ public class HDPowerViewHubHandler extends BaseBridgeHandler {
|
||||
continue;
|
||||
}
|
||||
ThingHandler handler = thing.getHandler();
|
||||
if (handler instanceof HDPowerViewShadeHandler) {
|
||||
((HDPowerViewShadeHandler) handler).requestRefreshShadeBatteryLevel();
|
||||
if (handler instanceof HDPowerViewShadeHandler shadeHandler) {
|
||||
shadeHandler.requestRefreshShadeBatteryLevel();
|
||||
} else {
|
||||
int shadeId = item.getValue();
|
||||
logger.debug("Shade '{}' handler not initialized", shadeId);
|
||||
|
@ -193,8 +193,8 @@ public class HDPowerViewShadeHandler extends AbstractHubbedThingHandler {
|
||||
HubShadeTimeoutException {
|
||||
switch (channelId) {
|
||||
case CHANNEL_SHADE_POSITION:
|
||||
if (command instanceof PercentType) {
|
||||
moveShade(PRIMARY_POSITION, ((PercentType) command).intValue(), webTargets, shadeId);
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
moveShade(PRIMARY_POSITION, percentCommand.intValue(), webTargets, shadeId);
|
||||
} else if (command instanceof UpDownType) {
|
||||
moveShade(PRIMARY_POSITION, UpDownType.UP == command ? 0 : 100, webTargets, shadeId);
|
||||
} else if (command instanceof StopMoveType) {
|
||||
@ -207,16 +207,16 @@ public class HDPowerViewShadeHandler extends AbstractHubbedThingHandler {
|
||||
break;
|
||||
|
||||
case CHANNEL_SHADE_VANE:
|
||||
if (command instanceof PercentType) {
|
||||
moveShade(VANE_TILT_POSITION, ((PercentType) command).intValue(), webTargets, shadeId);
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
moveShade(VANE_TILT_POSITION, percentCommand.intValue(), webTargets, shadeId);
|
||||
} else if (command instanceof OnOffType) {
|
||||
moveShade(VANE_TILT_POSITION, OnOffType.ON == command ? 100 : 0, webTargets, shadeId);
|
||||
}
|
||||
break;
|
||||
|
||||
case CHANNEL_SHADE_SECONDARY_POSITION:
|
||||
if (command instanceof PercentType) {
|
||||
moveShade(SECONDARY_POSITION, ((PercentType) command).intValue(), webTargets, shadeId);
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
moveShade(SECONDARY_POSITION, percentCommand.intValue(), webTargets, shadeId);
|
||||
} else if (command instanceof UpDownType) {
|
||||
moveShade(SECONDARY_POSITION, UpDownType.UP == command ? 0 : 100, webTargets, shadeId);
|
||||
} else if (command instanceof StopMoveType) {
|
||||
@ -229,11 +229,11 @@ public class HDPowerViewShadeHandler extends AbstractHubbedThingHandler {
|
||||
break;
|
||||
|
||||
case CHANNEL_SHADE_COMMAND:
|
||||
if (command instanceof StringType) {
|
||||
if (COMMAND_IDENTIFY.equals(((StringType) command).toString())) {
|
||||
if (command instanceof StringType stringCommand) {
|
||||
if (COMMAND_IDENTIFY.equals(stringCommand.toString())) {
|
||||
logger.debug("Identify shade {}", shadeId);
|
||||
identifyShade(webTargets, shadeId);
|
||||
} else if (COMMAND_CALIBRATE.equals(((StringType) command).toString())) {
|
||||
} else if (COMMAND_CALIBRATE.equals(stringCommand.toString())) {
|
||||
logger.debug("Calibrate shade {}", shadeId);
|
||||
calibrateShade(webTargets, shadeId);
|
||||
}
|
||||
|
@ -116,8 +116,8 @@ public class ShadeThingHandler extends BaseThingHandler {
|
||||
try {
|
||||
switch (channelUID.getId()) {
|
||||
case CHANNEL_SHADE_POSITION:
|
||||
if (command instanceof PercentType) {
|
||||
position.setPosition(PRIMARY_POSITION, ((PercentType) command));
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
position.setPosition(PRIMARY_POSITION, percentCommand);
|
||||
webTargets.moveShade(shadeId, new Shade().setShadePosition(position));
|
||||
break;
|
||||
} else if (command instanceof UpDownType) {
|
||||
@ -134,8 +134,8 @@ public class ShadeThingHandler extends BaseThingHandler {
|
||||
throw new IllegalArgumentException(INVALID_COMMAND);
|
||||
|
||||
case CHANNEL_SHADE_SECONDARY_POSITION:
|
||||
if (command instanceof PercentType) {
|
||||
position.setPosition(SECONDARY_POSITION, ((PercentType) command));
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
position.setPosition(SECONDARY_POSITION, percentCommand);
|
||||
webTargets.moveShade(shadeId, new Shade().setShadePosition(position));
|
||||
break;
|
||||
} else if (command instanceof UpDownType) {
|
||||
@ -153,8 +153,8 @@ public class ShadeThingHandler extends BaseThingHandler {
|
||||
throw new IllegalArgumentException(INVALID_COMMAND);
|
||||
|
||||
case CHANNEL_SHADE_VANE:
|
||||
if (command instanceof PercentType) {
|
||||
position.setPosition(VANE_TILT_POSITION, ((PercentType) command));
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
position.setPosition(VANE_TILT_POSITION, percentCommand);
|
||||
webTargets.moveShade(shadeId, new Shade().setShadePosition(position));
|
||||
break;
|
||||
} else if (command instanceof UpDownType) {
|
||||
@ -166,7 +166,8 @@ public class ShadeThingHandler extends BaseThingHandler {
|
||||
throw new IllegalArgumentException(INVALID_COMMAND);
|
||||
|
||||
case CHANNEL_SHADE_COMMAND:
|
||||
if ((command instanceof StringType) && COMMAND_IDENTIFY.equals(((StringType) command).toString())) {
|
||||
if ((command instanceof StringType stringCommand)
|
||||
&& COMMAND_IDENTIFY.equals(stringCommand.toString())) {
|
||||
webTargets.jogShade(shadeId);
|
||||
break;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import org.openhab.core.i18n.LocaleProvider;
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class MockedLocaleProvider implements LocaleProvider {
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return Locale.ENGLISH;
|
||||
}
|
||||
|
@ -209,15 +209,15 @@ public class HeliosHandler221 extends BaseThingHandler {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("initialize() Request : {}", systemTarget.resolveTemplate("ip", ipAddress)
|
||||
.resolveTemplate("cmd", INFO).getUri().toASCIIString());
|
||||
if (jsonObject.get("success").toString().equals("true")) {
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
logger.trace("initialize() Response: {}", jsonObject.get("result"));
|
||||
}
|
||||
if (jsonObject.get("success").toString().equals("false")) {
|
||||
if ("false".equals(jsonObject.get("success").toString())) {
|
||||
logger.trace("initialize() Response: {}", jsonObject.get("error"));
|
||||
}
|
||||
}
|
||||
|
||||
if (jsonObject.get("success").toString().equals("false")) {
|
||||
if ("false".equals(jsonObject.get("success").toString())) {
|
||||
RESTError error = gson.fromJson(jsonObject.get("error").toString(), RESTError.class);
|
||||
logger.debug(
|
||||
"An error occurred while communicating with the Helios IP Vario '{}': code '{}', param '{}' : '{}'",
|
||||
@ -228,7 +228,7 @@ public class HeliosHandler221 extends BaseThingHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (jsonObject.get("success").toString().equals("true")) {
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
if (logJob == null || logJob.isCancelled()) {
|
||||
logJob = scheduler.scheduleWithFixedDelay(logRunnable, 0, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
@ -316,15 +316,15 @@ public class HeliosHandler221 extends BaseThingHandler {
|
||||
logTarget.resolveTemplate("ip", ipAddress).resolveTemplate("cmd", SUBSCRIBE)
|
||||
.queryParam("include", "new").queryParam("duration", HELIOS_DURATION).getUri()
|
||||
.toASCIIString());
|
||||
if (jsonObject.get("success").toString().equals("true")) {
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
logger.trace("subscribe() Response: {}", jsonObject.get("result"));
|
||||
}
|
||||
if (jsonObject.get("success").toString().equals("false")) {
|
||||
if ("false".equals(jsonObject.get("success").toString())) {
|
||||
logger.trace("subscribe() Response: {}", jsonObject.get("error"));
|
||||
}
|
||||
}
|
||||
|
||||
if (jsonObject.get("success").toString().equals("true")) {
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
RESTSubscribeResponse subscribeResponse = gson.fromJson(jsonObject.get("result").toString(),
|
||||
RESTSubscribeResponse.class);
|
||||
logger.debug("The subscription id to pull logs from the Helios IP Vario '{}' is '{}'",
|
||||
@ -377,15 +377,15 @@ public class HeliosHandler221 extends BaseThingHandler {
|
||||
logger.trace("unsubscribe() Request : {}",
|
||||
logTarget.resolveTemplate("ip", ipAddress).resolveTemplate("cmd", UNSUBSCRIBE)
|
||||
.queryParam("id", logSubscriptionID).getUri().toASCIIString());
|
||||
if (jsonObject.get("success").toString().equals("true")) {
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
logger.trace("unsubscribe() Response: {}", jsonObject.get("result"));
|
||||
}
|
||||
if (jsonObject.get("success").toString().equals("false")) {
|
||||
if ("false".equals(jsonObject.get("success").toString())) {
|
||||
logger.trace("unsubscribe() Response: {}", jsonObject.get("error"));
|
||||
}
|
||||
}
|
||||
|
||||
if (jsonObject.get("success").toString().equals("true")) {
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
logger.debug("Successfully unsubscribed from the log entries of the Helios IP Vario '{}'",
|
||||
getThing().getUID().toString());
|
||||
} else {
|
||||
@ -439,15 +439,15 @@ public class HeliosHandler221 extends BaseThingHandler {
|
||||
logTarget.resolveTemplate("ip", ipAddress).resolveTemplate("cmd", PULL)
|
||||
.queryParam("id", logSubscriptionID).queryParam("timeout", HELIOS_PULL_DURATION)
|
||||
.getUri().toASCIIString());
|
||||
if (jsonObject.get("success").toString().equals("true")) {
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
logger.trace("pullLog() Response: {}", jsonObject.get("result"));
|
||||
}
|
||||
if (jsonObject.get("success").toString().equals("false")) {
|
||||
if ("false".equals(jsonObject.get("success").toString())) {
|
||||
logger.trace("pullLog() Response: {}", jsonObject.get("error"));
|
||||
}
|
||||
}
|
||||
|
||||
if (jsonObject.get("success").toString().equals("true")) {
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
logger.trace("Successfully pulled log entries from the Helios IP Vario '{}'",
|
||||
getThing().getUID().toString());
|
||||
JsonObject js = (JsonObject) jsonObject.get("result");
|
||||
@ -499,15 +499,15 @@ public class HeliosHandler221 extends BaseThingHandler {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("getSwitches() Request : {}", switchTarget.resolveTemplate("ip", ipAddress)
|
||||
.resolveTemplate("cmd", CAPABILITIES).getUri().toASCIIString());
|
||||
if (jsonObject.get("success").toString().equals("true")) {
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
logger.trace("getSwitches() Response: {}", jsonObject.get("result"));
|
||||
}
|
||||
if (jsonObject.get("success").toString().equals("false")) {
|
||||
if ("false".equals(jsonObject.get("success").toString())) {
|
||||
logger.trace("getSwitches() Response: {}", jsonObject.get("error"));
|
||||
}
|
||||
}
|
||||
|
||||
if (jsonObject.get("success").toString().equals("true")) {
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
logger.debug("Successfully requested switch capabilities from the Helios IP Vario '{}'",
|
||||
getThing().getUID().toString());
|
||||
String result = jsonObject.get("result").toString();
|
||||
@ -566,15 +566,15 @@ public class HeliosHandler221 extends BaseThingHandler {
|
||||
logger.trace("triggerSwitch() Request : {}",
|
||||
switchTarget.resolveTemplate("ip", ipAddress).resolveTemplate("cmd", CONTROL)
|
||||
.queryParam("switch", id).queryParam("action", "trigger").getUri().toASCIIString());
|
||||
if (jsonObject.get("success").toString().equals("true")) {
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
logger.trace("triggerSwitch() Response: {}", jsonObject.get("result"));
|
||||
}
|
||||
if (jsonObject.get("success").toString().equals("false")) {
|
||||
if ("false".equals(jsonObject.get("success").toString())) {
|
||||
logger.trace("triggerSwitch() Response: {}", jsonObject.get("error"));
|
||||
}
|
||||
}
|
||||
|
||||
if (jsonObject.get("success").toString().equals("true")) {
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
logger.debug("Successfully triggered a switch on the Helios IP Vario '{}'",
|
||||
getThing().getUID().toString());
|
||||
} else {
|
||||
@ -622,15 +622,15 @@ public class HeliosHandler221 extends BaseThingHandler {
|
||||
switchTarget.resolveTemplate("ip", ipAddress).resolveTemplate("cmd", CONTROL)
|
||||
.queryParam("switch", id).queryParam("action", flag ? "on" : "off").getUri()
|
||||
.toASCIIString());
|
||||
if (jsonObject.get("success").toString().equals("true")) {
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
logger.trace("enableSwitch() Response: {}", jsonObject.get("result"));
|
||||
}
|
||||
if (jsonObject.get("success").toString().equals("false")) {
|
||||
if ("false".equals(jsonObject.get("success").toString())) {
|
||||
logger.trace("enableSwitch() Response: {}", jsonObject.get("error"));
|
||||
}
|
||||
}
|
||||
|
||||
if (jsonObject.get("success").toString().equals("true")) {
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
logger.debug("Successfully dis/enabled a switch on the Helios IP Vario '{}'",
|
||||
getThing().getUID().toString());
|
||||
} else {
|
||||
@ -675,15 +675,15 @@ public class HeliosHandler221 extends BaseThingHandler {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("getPorts() Request : {}", portTarget.resolveTemplate("ip", ipAddress)
|
||||
.resolveTemplate("cmd", CAPABILITIES).getUri().toASCIIString());
|
||||
if (jsonObject.get("success").toString().equals("true")) {
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
logger.trace("getPorts() Response: {}", jsonObject.get("result"));
|
||||
}
|
||||
if (jsonObject.get("success").toString().equals("false")) {
|
||||
if ("false".equals(jsonObject.get("success").toString())) {
|
||||
logger.trace("getPorts() Response: {}", jsonObject.get("error"));
|
||||
}
|
||||
}
|
||||
|
||||
if (jsonObject.get("success").toString().equals("true")) {
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
logger.debug("Successfully requested port capabilities from the Helios IP Vario '{}'",
|
||||
getThing().getUID().toString());
|
||||
JsonObject js = (JsonObject) jsonObject.get("result");
|
||||
@ -743,10 +743,10 @@ public class HeliosHandler221 extends BaseThingHandler {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("configureRunnable Request : {}", systemTarget.resolveTemplate("ip", ipAddress)
|
||||
.resolveTemplate("cmd", INFO).getUri().toASCIIString());
|
||||
if (jsonObject.get("success").toString().equals("true")) {
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
logger.trace("configureRunnable Response: {}", jsonObject.get("result"));
|
||||
}
|
||||
if (jsonObject.get("success").toString().equals("false")) {
|
||||
if ("false".equals(jsonObject.get("success").toString())) {
|
||||
logger.trace("configureRunnable Response: {}", jsonObject.get("error"));
|
||||
}
|
||||
}
|
||||
@ -767,7 +767,7 @@ public class HeliosHandler221 extends BaseThingHandler {
|
||||
|
||||
if (switches != null) {
|
||||
for (RESTSwitch aSwitch : switches) {
|
||||
if (aSwitch.enabled.equals("true")) {
|
||||
if ("true".equals(aSwitch.enabled)) {
|
||||
logger.debug("Adding a channel to the Helios IP Vario '{}' for the switch with id '{}'",
|
||||
getThing().getUID().toString(), aSwitch.id);
|
||||
ThingBuilder thingBuilder = editThing();
|
||||
@ -852,9 +852,9 @@ public class HeliosHandler221 extends BaseThingHandler {
|
||||
break;
|
||||
}
|
||||
case AUDIOLOOPTEST: {
|
||||
if (event.params.get("result").getAsString().equals("passed")) {
|
||||
if ("passed".equals(event.params.get("result").getAsString())) {
|
||||
updateState(AUDIO_LOOP_TEST, OnOffType.ON);
|
||||
} else if (event.params.get("result").getAsString().equals("failed")) {
|
||||
} else if ("failed".equals(event.params.get("result").getAsString())) {
|
||||
updateState(AUDIO_LOOP_TEST, OnOffType.OFF);
|
||||
} else {
|
||||
updateState(AUDIO_LOOP_TEST, UnDefType.UNDEF);
|
||||
@ -864,9 +864,9 @@ public class HeliosHandler221 extends BaseThingHandler {
|
||||
break;
|
||||
}
|
||||
case MOTIONDETECTED: {
|
||||
if (event.params.get("state").getAsString().equals("in")) {
|
||||
if ("in".equals(event.params.get("state").getAsString())) {
|
||||
updateState(MOTION, OnOffType.ON);
|
||||
} else if (event.params.get("state").getAsString().equals("out")) {
|
||||
} else if ("out".equals(event.params.get("state").getAsString())) {
|
||||
updateState(MOTION, OnOffType.OFF);
|
||||
} else {
|
||||
updateState(MOTION, UnDefType.UNDEF);
|
||||
@ -876,9 +876,9 @@ public class HeliosHandler221 extends BaseThingHandler {
|
||||
break;
|
||||
}
|
||||
case NOISEDETECTED: {
|
||||
if (event.params.get("state").getAsString().equals("in")) {
|
||||
if ("in".equals(event.params.get("state").getAsString())) {
|
||||
updateState(NOISE, OnOffType.ON);
|
||||
} else if (event.params.get("state").getAsString().equals("out")) {
|
||||
} else if ("out".equals(event.params.get("state").getAsString())) {
|
||||
updateState(NOISE, OnOffType.OFF);
|
||||
} else {
|
||||
updateState(NOISE, UnDefType.UNDEF);
|
||||
@ -902,9 +902,9 @@ public class HeliosHandler221 extends BaseThingHandler {
|
||||
case CODEENTERED: {
|
||||
triggerChannel(CODE, event.params.get("code").getAsString());
|
||||
|
||||
if (event.params.get("valid").getAsString().equals("true")) {
|
||||
if ("true".equals(event.params.get("valid").getAsString())) {
|
||||
updateState(CODE_VALID, OnOffType.ON);
|
||||
} else if (event.params.get("valid").getAsString().equals("false")) {
|
||||
} else if ("false".equals(event.params.get("valid").getAsString())) {
|
||||
updateState(CODE_VALID, OnOffType.OFF);
|
||||
} else {
|
||||
updateState(CODE_VALID, UnDefType.UNDEF);
|
||||
@ -916,9 +916,9 @@ public class HeliosHandler221 extends BaseThingHandler {
|
||||
case CARDENTERED: {
|
||||
triggerChannel(CARD, event.params.get("uid").getAsString());
|
||||
|
||||
if (event.params.get("valid").getAsString().equals("true")) {
|
||||
if ("true".equals(event.params.get("valid").getAsString())) {
|
||||
updateState(CARD_VALID, OnOffType.ON);
|
||||
} else if (event.params.get("valid").getAsString().equals("false")) {
|
||||
} else if ("false".equals(event.params.get("valid").getAsString())) {
|
||||
updateState(CARD_VALID, OnOffType.OFF);
|
||||
} else {
|
||||
updateState(CARD_VALID, UnDefType.UNDEF);
|
||||
@ -931,9 +931,9 @@ public class HeliosHandler221 extends BaseThingHandler {
|
||||
ChannelUID inputChannel = new ChannelUID(getThing().getUID(),
|
||||
"io" + event.params.get("port").getAsString());
|
||||
|
||||
if (event.params.get("state").getAsString().equals("true")) {
|
||||
if ("true".equals(event.params.get("state").getAsString())) {
|
||||
updateState(inputChannel, OnOffType.ON);
|
||||
} else if (event.params.get("state").getAsString().equals("false")) {
|
||||
} else if ("false".equals(event.params.get("state").getAsString())) {
|
||||
updateState(inputChannel, OnOffType.OFF);
|
||||
} else {
|
||||
updateState(inputChannel, UnDefType.UNDEF);
|
||||
@ -944,9 +944,9 @@ public class HeliosHandler221 extends BaseThingHandler {
|
||||
ChannelUID inputChannel = new ChannelUID(getThing().getUID(),
|
||||
"io" + event.params.get("port").getAsString());
|
||||
|
||||
if (event.params.get("state").getAsString().equals("true")) {
|
||||
if ("true".equals(event.params.get("state").getAsString())) {
|
||||
updateState(inputChannel, OnOffType.ON);
|
||||
} else if (event.params.get("state").getAsString().equals("false")) {
|
||||
} else if ("false".equals(event.params.get("state").getAsString())) {
|
||||
updateState(inputChannel, OnOffType.OFF);
|
||||
} else {
|
||||
updateState(inputChannel, UnDefType.UNDEF);
|
||||
@ -967,9 +967,9 @@ public class HeliosHandler221 extends BaseThingHandler {
|
||||
break;
|
||||
}
|
||||
case SWITCHSTATECHANGED: {
|
||||
if (event.params.get("state").getAsString().equals("true")) {
|
||||
if ("true".equals(event.params.get("state").getAsString())) {
|
||||
updateState(SWITCH_STATE, OnOffType.ON);
|
||||
} else if (event.params.get("state").getAsString().equals("false")) {
|
||||
} else if ("false".equals(event.params.get("state").getAsString())) {
|
||||
updateState(SWITCH_STATE, OnOffType.OFF);
|
||||
} else {
|
||||
updateState(SWITCH_STATE, UnDefType.UNDEF);
|
||||
|
@ -14,7 +14,6 @@ package org.openhab.binding.heliosventilation.internal;
|
||||
|
||||
import static org.openhab.binding.heliosventilation.internal.HeliosVentilationBindingConstants.THING_TYPE_HELIOS_VENTILATION;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
@ -39,8 +38,7 @@ import org.osgi.service.component.annotations.Reference;
|
||||
@Component(configurationPid = "binding.heliosventilation", service = ThingHandlerFactory.class)
|
||||
public class HeliosVentilationHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
|
||||
.singleton(THING_TYPE_HELIOS_VENTILATION);
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_HELIOS_VENTILATION);
|
||||
|
||||
private final SerialPortManager serialPortManager;
|
||||
|
||||
|
@ -43,8 +43,8 @@ public class HeosActions implements ThingActions {
|
||||
|
||||
@Override
|
||||
public void setThingHandler(@Nullable ThingHandler handler) {
|
||||
if (handler instanceof HeosBridgeHandler) {
|
||||
this.handler = (HeosBridgeHandler) handler;
|
||||
if (handler instanceof HeosBridgeHandler bridgeHandler) {
|
||||
this.handler = bridgeHandler;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,6 @@ package org.openhab.binding.heos.internal.discovery;
|
||||
|
||||
import static org.openhab.binding.heos.internal.HeosBindingConstants.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -48,7 +47,7 @@ public class HeosDiscoveryParticipant implements UpnpDiscoveryParticipant {
|
||||
|
||||
@Override
|
||||
public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
|
||||
return Collections.singleton(THING_TYPE_BRIDGE);
|
||||
return Set.of(THING_TYPE_BRIDGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,7 +19,6 @@ import static org.openhab.core.thing.ThingStatus.ONLINE;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -220,9 +219,8 @@ public class HeosBridgeHandler extends BaseBridgeHandler implements HeosEventLis
|
||||
try {
|
||||
@Nullable
|
||||
ThingHandler handler = thing.getHandler();
|
||||
if (handler instanceof HeosThingBaseHandler) {
|
||||
if (handler instanceof HeosThingBaseHandler heosHandler) {
|
||||
Set<String> target = handler instanceof HeosPlayerHandler ? players : groups;
|
||||
HeosThingBaseHandler heosHandler = (HeosThingBaseHandler) handler;
|
||||
String id = heosHandler.getId();
|
||||
|
||||
if (target.contains(id)) {
|
||||
@ -303,12 +301,12 @@ public class HeosBridgeHandler extends BaseBridgeHandler implements HeosEventLis
|
||||
} else if (childHandler instanceof HeosPlayerHandler) {
|
||||
String channelIdentifier = "P" + childThing.getUID().getId();
|
||||
updateThingChannels(channelManager.removeSingleChannel(channelIdentifier));
|
||||
} else if (childHandler instanceof HeosGroupHandler) {
|
||||
} else if (childHandler instanceof HeosGroupHandler groupHandler) {
|
||||
String channelIdentifier = "G" + childThing.getUID().getId();
|
||||
updateThingChannels(channelManager.removeSingleChannel(channelIdentifier));
|
||||
// removes the handler from the groupMemberMap that handler is no longer called
|
||||
// if group is getting online
|
||||
removeGroupHandlerInformation((HeosGroupHandler) childHandler);
|
||||
removeGroupHandlerInformation(groupHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@ -361,13 +359,13 @@ public class HeosBridgeHandler extends BaseBridgeHandler implements HeosEventLis
|
||||
String pid = "";
|
||||
@Nullable
|
||||
ThingHandler handler = childThing.getHandler();
|
||||
if (handler instanceof HeosPlayerHandler) {
|
||||
if (handler instanceof HeosPlayerHandler playerHandler) {
|
||||
channelIdentifier = "P" + childThing.getUID().getId();
|
||||
pid = ((HeosPlayerHandler) handler).getId();
|
||||
} else if (handler instanceof HeosGroupHandler) {
|
||||
pid = playerHandler.getId();
|
||||
} else if (handler instanceof HeosGroupHandler groupHandler) {
|
||||
channelIdentifier = "G" + childThing.getUID().getId();
|
||||
if (groupId == null) {
|
||||
pid = ((HeosGroupHandler) handler).getId();
|
||||
pid = groupHandler.getId();
|
||||
} else {
|
||||
pid = groupId;
|
||||
}
|
||||
@ -520,7 +518,7 @@ public class HeosBridgeHandler extends BaseBridgeHandler implements HeosEventLis
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singletonList(HeosActions.class);
|
||||
return List.of(HeosActions.class);
|
||||
}
|
||||
|
||||
public void registerMediaEventListener(HeosMediaEventListener heosMediaEventListener) {
|
||||
|
@ -387,16 +387,16 @@ public abstract class HeosThingBaseHandler extends BaseThingHandler implements H
|
||||
case GET_NOW_PLAYING_MEDIA:
|
||||
@Nullable
|
||||
T mediaPayload = responseObject.payload;
|
||||
if (mediaPayload instanceof Media) {
|
||||
handleThingMediaUpdate((Media) mediaPayload);
|
||||
if (mediaPayload instanceof Media media) {
|
||||
handleThingMediaUpdate(media);
|
||||
}
|
||||
break;
|
||||
|
||||
case GET_PLAYER_INFO:
|
||||
@Nullable
|
||||
T playerPayload = responseObject.payload;
|
||||
if (playerPayload instanceof Player) {
|
||||
handlePlayerInfo((Player) playerPayload);
|
||||
if (playerPayload instanceof Player player) {
|
||||
handlePlayerInfo(player);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -166,8 +166,8 @@ public class Telnet {
|
||||
throw new ReadException(e);
|
||||
} catch (ExecutionException e) {
|
||||
Throwable cause = e.getCause();
|
||||
if (cause instanceof IOException) {
|
||||
throw (IOException) cause;
|
||||
if (cause instanceof IOException exception) {
|
||||
throw exception;
|
||||
} else {
|
||||
throw new ReadException(cause);
|
||||
}
|
||||
|
@ -138,9 +138,11 @@ public class HeosJsonParserResponseTest {
|
||||
@Test
|
||||
public void get_players() {
|
||||
HeosResponseObject<Player[]> response = subject.parseResponse(
|
||||
"{\"heos\": {\"command\": \"player/get_players\", \"result\": \"success\", \"message\": \"\"}, \"payload\": ["
|
||||
+ "{\"name\": \"Kantoor HEOS 3\", \"pid\": -831584083, \"model\": \"HEOS 3\", \"version\": \"1.520.200\", \"ip\": \"192.168.1.230\", \"network\": \"wired\", \"lineout\": 0, \"serial\": \"ACNG9180110887\"}, "
|
||||
+ "{\"name\": \"HEOS Bar\", \"pid\": 1958912779, \"model\": \"HEOS Bar\", \"version\": \"1.520.200\", \"ip\": \"192.168.1.195\", \"network\": \"wired\", \"lineout\": 0, \"serial\": \"ADAG9180917029\"}]}",
|
||||
"""
|
||||
{"heos": {"command": "player/get_players", "result": "success", "message": ""}, "payload": [\
|
||||
{"name": "Kantoor HEOS 3", "pid": -831584083, "model": "HEOS 3", "version": "1.520.200", "ip": "192.168.1.230", "network": "wired", "lineout": 0, "serial": "ACNG9180110887"}, \
|
||||
{"name": "HEOS Bar", "pid": 1958912779, "model": "HEOS Bar", "version": "1.520.200", "ip": "192.168.1.195", "network": "wired", "lineout": 0, "serial": "ADAG9180917029"}]}\
|
||||
""",
|
||||
Player[].class);
|
||||
|
||||
assertEquals(HeosCommandGroup.PLAYER, response.heosCommand.commandGroup);
|
||||
@ -194,8 +196,10 @@ public class HeosJsonParserResponseTest {
|
||||
@Test
|
||||
public void get_now_playing_media() {
|
||||
HeosResponseObject<Media> response = subject.parseResponse(
|
||||
"{\"heos\": {\"command\": \"player/get_now_playing_media\", \"result\": \"success\", \"message\": \"pid=1958912779\"}, \"payload\": "
|
||||
+ "{\"type\": \"song\", \"song\": \"Solo (feat. Demi Lovato)\", \"album\": \"What Is Love? (Deluxe)\", \"artist\": \"Clean Bandit\", \"image_url\": \"http://192.168.1.230:8015//m-browsableMediaUri/getImageFromTag/mnt/326C72A3E307501E47DE2B0F47D90EB8/Clean%20Bandit/What%20Is%20Love_%20(Deluxe)/03%20Solo%20(feat.%20Demi%20Lovato).m4a\", \"album_id\": \"\", \"mid\": \"http://192.168.1.230:8015/m-1c176905-f6c7-d168-dc35-86b4735c5976/Clean+Bandit/What+Is+Love_+(Deluxe)/03+Solo+(feat.+Demi+Lovato).m4a\", \"qid\": 1, \"sid\": 1024}, \"options\": []}\n",
|
||||
"""
|
||||
{"heos": {"command": "player/get_now_playing_media", "result": "success", "message": "pid=1958912779"}, "payload": \
|
||||
{"type": "song", "song": "Solo (feat. Demi Lovato)", "album": "What Is Love? (Deluxe)", "artist": "Clean Bandit", "image_url": "http://192.168.1.230:8015//m-browsableMediaUri/getImageFromTag/mnt/326C72A3E307501E47DE2B0F47D90EB8/Clean%20Bandit/What%20Is%20Love_%20(Deluxe)/03%20Solo%20(feat.%20Demi%20Lovato).m4a", "album_id": "", "mid": "http://192.168.1.230:8015/m-1c176905-f6c7-d168-dc35-86b4735c5976/Clean+Bandit/What+Is+Love_+(Deluxe)/03+Solo+(feat.+Demi+Lovato).m4a", "qid": 1, "sid": 1024}, "options": []}
|
||||
""",
|
||||
Media.class);
|
||||
|
||||
assertEquals(HeosCommandGroup.PLAYER, response.heosCommand.commandGroup);
|
||||
@ -222,13 +226,15 @@ public class HeosJsonParserResponseTest {
|
||||
@Test
|
||||
public void browse_playlist() {
|
||||
HeosResponseObject<BrowseResult[]> response = subject.parseResponse(
|
||||
"{\"heos\": {\"command\": \"browse/browse\", \"result\": \"success\", \"message\": \"sid=1025&returned=6&count=6\"}, \"payload\": ["
|
||||
+ "{\"container\": \"yes\", \"type\": \"playlist\", \"cid\": \"132562\", \"playable\": \"yes\", \"name\": \"Maaike Ouboter - En hoe het dan ook weer dag wordt\", \"image_url\": \"\"}, "
|
||||
+ "{\"container\": \"yes\", \"type\": \"playlist\", \"cid\": \"132563\", \"playable\": \"yes\", \"name\": \"Maaike Ouboter - Vanaf nu is het van jou\", \"image_url\": \"\"}, "
|
||||
+ "{\"container\": \"yes\", \"type\": \"playlist\", \"cid\": \"162887\", \"playable\": \"yes\", \"name\": \"Easy listening\", \"image_url\": \"\"}, "
|
||||
+ "{\"container\": \"yes\", \"type\": \"playlist\", \"cid\": \"174461\", \"playable\": \"yes\", \"name\": \"Nieuwe muziek 5-2019\", \"image_url\": \"\"}, "
|
||||
+ "{\"container\": \"yes\", \"type\": \"playlist\", \"cid\": \"194000\", \"playable\": \"yes\", \"name\": \"Nieuwe muziek 2019-05\", \"image_url\": \"\"}, "
|
||||
+ "{\"container\": \"yes\", \"type\": \"playlist\", \"cid\": \"194001\", \"playable\": \"yes\", \"name\": \"Clean Bandit\", \"image_url\": \"\"}]}",
|
||||
"""
|
||||
{"heos": {"command": "browse/browse", "result": "success", "message": "sid=1025&returned=6&count=6"}, "payload": [\
|
||||
{"container": "yes", "type": "playlist", "cid": "132562", "playable": "yes", "name": "Maaike Ouboter - En hoe het dan ook weer dag wordt", "image_url": ""}, \
|
||||
{"container": "yes", "type": "playlist", "cid": "132563", "playable": "yes", "name": "Maaike Ouboter - Vanaf nu is het van jou", "image_url": ""}, \
|
||||
{"container": "yes", "type": "playlist", "cid": "162887", "playable": "yes", "name": "Easy listening", "image_url": ""}, \
|
||||
{"container": "yes", "type": "playlist", "cid": "174461", "playable": "yes", "name": "Nieuwe muziek 5-2019", "image_url": ""}, \
|
||||
{"container": "yes", "type": "playlist", "cid": "194000", "playable": "yes", "name": "Nieuwe muziek 2019-05", "image_url": ""}, \
|
||||
{"container": "yes", "type": "playlist", "cid": "194001", "playable": "yes", "name": "Clean Bandit", "image_url": ""}]}\
|
||||
""",
|
||||
BrowseResult[].class);
|
||||
|
||||
assertEquals(HeosCommandGroup.BROWSE, response.heosCommand.commandGroup);
|
||||
@ -252,11 +258,13 @@ public class HeosJsonParserResponseTest {
|
||||
@Test
|
||||
public void browse_favorites() {
|
||||
HeosResponseObject<BrowseResult[]> response = subject.parseResponse(
|
||||
"{\"heos\": {\"command\": \"browse/browse\", \"result\": \"success\", \"message\": \"sid=1028&returned=3&count=3\"}, \"payload\": ["
|
||||
+ "{\"container\": \"no\", \"mid\": \"s6707\", \"type\": \"station\", \"playable\": \"yes\", \"name\": \"NPO 3FM 96.8 (Top 40 %26 Pop Music)\", \"image_url\": \"http://cdn-profiles.tunein.com/s6707/images/logoq.png?t=636268\"}, "
|
||||
+ "{\"container\": \"no\", \"mid\": \"s2967\", \"type\": \"station\", \"playable\": \"yes\", \"name\": \"Classic FM Nederland (Classical Music)\", \"image_url\": \"http://cdn-radiotime-logos.tunein.com/s2967q.png\"}, "
|
||||
+ "{\"container\": \"no\", \"mid\": \"s1993\", \"type\": \"station\", \"playable\": \"yes\", \"name\": \"BNR Nieuwsradio\", \"image_url\": \"http://cdn-radiotime-logos.tunein.com/s1993q.png\"}], "
|
||||
+ "\"options\": [{\"browse\": [{\"id\": 20, \"name\": \"Remove from HEOS Favorites\"}]}]}",
|
||||
"""
|
||||
{"heos": {"command": "browse/browse", "result": "success", "message": "sid=1028&returned=3&count=3"}, "payload": [\
|
||||
{"container": "no", "mid": "s6707", "type": "station", "playable": "yes", "name": "NPO 3FM 96.8 (Top 40 %26 Pop Music)", "image_url": "http://cdn-profiles.tunein.com/s6707/images/logoq.png?t=636268"}, \
|
||||
{"container": "no", "mid": "s2967", "type": "station", "playable": "yes", "name": "Classic FM Nederland (Classical Music)", "image_url": "http://cdn-radiotime-logos.tunein.com/s2967q.png"}, \
|
||||
{"container": "no", "mid": "s1993", "type": "station", "playable": "yes", "name": "BNR Nieuwsradio", "image_url": "http://cdn-radiotime-logos.tunein.com/s1993q.png"}], \
|
||||
"options": [{"browse": [{"id": 20, "name": "Remove from HEOS Favorites"}]}]}\
|
||||
""",
|
||||
BrowseResult[].class);
|
||||
|
||||
assertEquals(HeosCommandGroup.BROWSE, response.heosCommand.commandGroup);
|
||||
@ -282,9 +290,11 @@ public class HeosJsonParserResponseTest {
|
||||
@Test
|
||||
public void get_groups() {
|
||||
HeosResponseObject<Group[]> response = subject.parseResponse(
|
||||
"{\"heos\": {\"command\": \"group/get_groups\", \"result\": \"success\", \"message\": \"\"}, \"payload\": [ "
|
||||
+ "{\"name\": \"Group 1\", \"gid\": \"214243242\", \"players\": [ {\"name\": \"HEOS 1\", \"pid\": \"2142443242\", \"role\": \"leader\"}, {\"name\": \"HEOS 3\", \"pid\": \"32432423432\", \"role\": \"member\"}, {\"name\": \"HEOS 5\", \"pid\": \"342423564\", \"role\": \"member\"}]}, "
|
||||
+ "{\"name\": \"Group 2\", \"gid\": \"2142432342\", \"players\": [ {\"name\": \"HEOS 3\", \"pid\": \"32432423432\", \"role\": \"member\"}, {\"name\": \"HEOS 5\", \"pid\": \"342423564\", \"role\": \"member\"}]}]}",
|
||||
"""
|
||||
{"heos": {"command": "group/get_groups", "result": "success", "message": ""}, "payload": [ \
|
||||
{"name": "Group 1", "gid": "214243242", "players": [ {"name": "HEOS 1", "pid": "2142443242", "role": "leader"}, {"name": "HEOS 3", "pid": "32432423432", "role": "member"}, {"name": "HEOS 5", "pid": "342423564", "role": "member"}]}, \
|
||||
{"name": "Group 2", "gid": "2142432342", "players": [ {"name": "HEOS 3", "pid": "32432423432", "role": "member"}, {"name": "HEOS 5", "pid": "342423564", "role": "member"}]}]}\
|
||||
""",
|
||||
Group[].class);
|
||||
|
||||
assertEquals(HeosCommandGroup.GROUP, response.heosCommand.commandGroup);
|
||||
|
@ -74,8 +74,8 @@ public class CurtainHandler extends BaseThingHandler {
|
||||
(command == UpDownType.UP) ? ControlAddress.OPEN : ControlAddress.CLOSE);
|
||||
} else if (command instanceof StopMoveType) {
|
||||
pkt = buildPacket(Function.CONTROL, ControlAddress.STOP);
|
||||
} else if (command instanceof DecimalType) {
|
||||
pkt = buildPacket(Function.CONTROL, ControlAddress.PERCENT, ((DecimalType) command).byteValue());
|
||||
} else if (command instanceof DecimalType decimalCommand) {
|
||||
pkt = buildPacket(Function.CONTROL, ControlAddress.PERCENT, decimalCommand.byteValue());
|
||||
}
|
||||
break;
|
||||
case CHANNEL_REVERSE:
|
||||
|
@ -12,7 +12,6 @@
|
||||
*/
|
||||
package org.openhab.binding.homeconnect.internal.client;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.openhab.binding.homeconnect.internal.HomeConnectBindingConstants.*;
|
||||
import static org.openhab.binding.homeconnect.internal.client.HttpHelper.*;
|
||||
|
||||
@ -880,7 +879,7 @@ public class HomeConnectApiClient {
|
||||
private void checkResponseCode(int desiredCode, Request request, ContentResponse response, @Nullable String haId,
|
||||
@Nullable String requestPayload)
|
||||
throws CommunicationException, AuthorizationException, ApplianceOfflineException {
|
||||
checkResponseCode(singletonList(desiredCode), request, response, haId, requestPayload);
|
||||
checkResponseCode(List.of(desiredCode), request, response, haId, requestPayload);
|
||||
}
|
||||
|
||||
private void checkResponseCode(List<Integer> desiredCodes, Request request, ContentResponse response,
|
||||
|
@ -60,8 +60,8 @@ public class HomeConnectDiscoveryService extends AbstractDiscoveryService
|
||||
|
||||
@Override
|
||||
public void setThingHandler(ThingHandler handler) {
|
||||
if (handler instanceof HomeConnectBridgeHandler) {
|
||||
this.bridgeHandler = (HomeConnectBridgeHandler) handler;
|
||||
if (handler instanceof HomeConnectBridgeHandler homeConnectBridgeHandler) {
|
||||
this.bridgeHandler = homeConnectBridgeHandler;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -453,8 +453,8 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
|
||||
Bridge bridge = getBridge();
|
||||
if (bridge != null) {
|
||||
BridgeHandler bridgeHandler = bridge.getHandler();
|
||||
if (bridgeHandler instanceof HomeConnectBridgeHandler) {
|
||||
return Optional.of((HomeConnectBridgeHandler) bridgeHandler);
|
||||
if (bridgeHandler instanceof HomeConnectBridgeHandler homeConnectBridgeHandler) {
|
||||
return Optional.of(homeConnectBridgeHandler);
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
@ -537,7 +537,7 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
|
||||
* @param channelUID channel UID
|
||||
*/
|
||||
protected void updateChannel(ChannelUID channelUID) {
|
||||
if (!getApiClient().isPresent()) {
|
||||
if (getApiClient().isEmpty()) {
|
||||
logger.error("Cannot update channel. No instance of api client found! thing={}, haId={}", getThingLabel(),
|
||||
getThingHaId());
|
||||
return;
|
||||
@ -1206,23 +1206,23 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
|
||||
protected void handleTemperatureCommand(final ChannelUID channelUID, final Command command,
|
||||
final HomeConnectApiClient apiClient)
|
||||
throws CommunicationException, AuthorizationException, ApplianceOfflineException {
|
||||
if (command instanceof QuantityType) {
|
||||
QuantityType<?> quantity = (QuantityType<?>) command;
|
||||
|
||||
if (command instanceof QuantityType quantityCommand) {
|
||||
String value;
|
||||
String unit;
|
||||
|
||||
try {
|
||||
if (quantity.getUnit().equals(SIUnits.CELSIUS) || quantity.getUnit().equals(ImperialUnits.FAHRENHEIT)) {
|
||||
unit = quantity.getUnit().toString();
|
||||
value = String.valueOf(quantity.intValue());
|
||||
if (quantityCommand.getUnit().equals(SIUnits.CELSIUS)
|
||||
|| quantityCommand.getUnit().equals(ImperialUnits.FAHRENHEIT)) {
|
||||
unit = quantityCommand.getUnit().toString();
|
||||
value = String.valueOf(quantityCommand.intValue());
|
||||
} else {
|
||||
logger.debug("Converting target temperature from {}{} to °C value. thing={}, haId={}",
|
||||
quantity.intValue(), quantity.getUnit().toString(), getThingLabel(), getThingHaId());
|
||||
quantityCommand.intValue(), quantityCommand.getUnit().toString(), getThingLabel(),
|
||||
getThingHaId());
|
||||
unit = "°C";
|
||||
var celsius = quantity.toUnit(SIUnits.CELSIUS);
|
||||
var celsius = quantityCommand.toUnit(SIUnits.CELSIUS);
|
||||
if (celsius == null) {
|
||||
logger.warn("Converting temperature to celsius failed! quantity={}", quantity);
|
||||
logger.warn("Converting temperature to celsius failed! quantity={}", quantityCommand);
|
||||
value = null;
|
||||
} else {
|
||||
value = String.valueOf(celsius.intValue());
|
||||
@ -1272,10 +1272,10 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
|
||||
} else {
|
||||
newBrightness = currentBrightness - BRIGHTNESS_DIM_STEP;
|
||||
}
|
||||
} else if (command instanceof PercentType) {
|
||||
newBrightness = (int) Math.floor(((PercentType) command).doubleValue());
|
||||
} else if (command instanceof DecimalType) {
|
||||
newBrightness = ((DecimalType) command).intValue();
|
||||
} else if (command instanceof PercentType percentCommand) {
|
||||
newBrightness = (int) Math.floor(percentCommand.doubleValue());
|
||||
} else if (command instanceof DecimalType decimalCommand) {
|
||||
newBrightness = decimalCommand.intValue();
|
||||
}
|
||||
|
||||
// check in in range
|
||||
@ -1308,8 +1308,8 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
|
||||
apiClient.setAmbientLightColorState(getThingHaId(), STATE_AMBIENT_LIGHT_COLOR_CUSTOM_COLOR);
|
||||
}
|
||||
|
||||
if (command instanceof HSBType) {
|
||||
apiClient.setAmbientLightCustomColorState(getThingHaId(), mapColor((HSBType) command));
|
||||
if (command instanceof HSBType hsbCommand) {
|
||||
apiClient.setAmbientLightCustomColorState(getThingHaId(), mapColor(hsbCommand));
|
||||
} else if (command instanceof StringType) {
|
||||
apiClient.setAmbientLightCustomColorState(getThingHaId(), command.toFullString());
|
||||
}
|
||||
@ -1546,9 +1546,9 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
|
||||
.filter(option -> OPTION_DRYER_DRYING_TARGET.equals(option.getKey())).findFirst();
|
||||
|
||||
// Save options in cache only if we got options for all expected channels
|
||||
if (cacheToSet && (!channelSpinSpeed.isPresent() || optionsSpinSpeed.isPresent())
|
||||
&& (!channelTemperature.isPresent() || optionsTemperature.isPresent())
|
||||
&& (!channelDryingTarget.isPresent() || optionsDryingTarget.isPresent())) {
|
||||
if (cacheToSet && (channelSpinSpeed.isEmpty() || optionsSpinSpeed.isPresent())
|
||||
&& (channelTemperature.isEmpty() || optionsTemperature.isPresent())
|
||||
&& (channelDryingTarget.isEmpty() || optionsDryingTarget.isPresent())) {
|
||||
logger.debug("Saving options in cache for program '{}'.", programKey);
|
||||
availableProgramOptionsCache.put(programKey, availableProgramOptions);
|
||||
}
|
||||
@ -1673,7 +1673,7 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
|
||||
private boolean addUnsupportedProgramInCache(String programKey) {
|
||||
Optional<AvailableProgram> prog = programsCache.stream().filter(program -> programKey.equals(program.getKey()))
|
||||
.findFirst();
|
||||
if (!prog.isPresent()) {
|
||||
if (prog.isEmpty()) {
|
||||
programsCache.add(new AvailableProgram(programKey, false));
|
||||
logger.debug("{} added in programs cache as an unsupported program", programKey);
|
||||
return true;
|
||||
|
@ -19,10 +19,10 @@ import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
@ -232,7 +232,7 @@ public class HomeConnectBridgeHandler extends BaseBridgeHandler {
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(HomeConnectDiscoveryService.class);
|
||||
return Set.of(HomeConnectDiscoveryService.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,15 +49,35 @@ import org.slf4j.LoggerFactory;
|
||||
@NonNullByDefault
|
||||
public class HomeConnectHoodHandler extends AbstractHomeConnectThingHandler {
|
||||
|
||||
private static final String START_VENTING_INTENSIVE_STAGE_PAYLOAD_TEMPLATE = "\n" + "{\n" + " \"data\": {\n"
|
||||
+ " \"key\": \"Cooking.Common.Program.Hood.Venting\",\n" + " \"options\": [\n"
|
||||
+ " {\n" + " \"key\": \"Cooking.Common.Option.Hood.IntensiveLevel\",\n"
|
||||
+ " \"value\": \"%s\"\n" + " }\n" + " ]\n" + " }\n" + "}";
|
||||
private static final String START_VENTING_INTENSIVE_STAGE_PAYLOAD_TEMPLATE = """
|
||||
|
||||
private static final String START_VENTING_STAGE_PAYLOAD_TEMPLATE = "\n" + "{\n" + " \"data\": {\n"
|
||||
+ " \"key\": \"Cooking.Common.Program.Hood.Venting\",\n" + " \"options\": [\n"
|
||||
+ " {\n" + " \"key\": \"Cooking.Common.Option.Hood.VentingLevel\",\n"
|
||||
+ " \"value\": \"%s\"\n" + " }\n" + " ]\n" + " }\n" + "}";
|
||||
{
|
||||
"data": {
|
||||
"key": "Cooking.Common.Program.Hood.Venting",
|
||||
"options": [
|
||||
{
|
||||
"key": "Cooking.Common.Option.Hood.IntensiveLevel",
|
||||
"value": "%s"
|
||||
}
|
||||
]
|
||||
}
|
||||
}\
|
||||
""";
|
||||
|
||||
private static final String START_VENTING_STAGE_PAYLOAD_TEMPLATE = """
|
||||
|
||||
{
|
||||
"data": {
|
||||
"key": "Cooking.Common.Program.Hood.Venting",
|
||||
"options": [
|
||||
{
|
||||
"key": "Cooking.Common.Option.Hood.VentingLevel",
|
||||
"value": "%s"
|
||||
}
|
||||
]
|
||||
}
|
||||
}\
|
||||
""";
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(HomeConnectHoodHandler.class);
|
||||
|
||||
|
@ -394,12 +394,12 @@ public class HomematicConfig {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
"%s[gatewayAddress=%s,callbackHost=%s,xmlCallbackPort=%d,binCallbackPort=%d,"
|
||||
+ "gatewayType=%s,rfPort=%d,wiredPort=%d,hmIpPort=%d,cuxdPort=%d,groupPort=%d,timeout=%d,"
|
||||
+ "discoveryTimeToLive=%d,installModeDuration=%d,socketMaxAlive=%d]",
|
||||
getClass().getSimpleName(), gatewayAddress, callbackHost, xmlCallbackPort, binCallbackPort, gatewayType,
|
||||
getRfPort(), getWiredPort(), getHmIpPort(), getCuxdPort(), getGroupPort(), timeout, discoveryTimeToLive,
|
||||
installModeDuration, socketMaxAlive);
|
||||
return String.format("""
|
||||
%s[gatewayAddress=%s,callbackHost=%s,xmlCallbackPort=%d,binCallbackPort=%d,\
|
||||
gatewayType=%s,rfPort=%d,wiredPort=%d,hmIpPort=%d,cuxdPort=%d,groupPort=%d,timeout=%d,\
|
||||
discoveryTimeToLive=%d,installModeDuration=%d,socketMaxAlive=%d]\
|
||||
""", getClass().getSimpleName(), gatewayAddress, callbackHost, xmlCallbackPort, binCallbackPort,
|
||||
gatewayType, getRfPort(), getWiredPort(), getHmIpPort(), getCuxdPort(), getGroupPort(), timeout,
|
||||
discoveryTimeToLive, installModeDuration, socketMaxAlive);
|
||||
}
|
||||
}
|
||||
|
@ -84,8 +84,7 @@ public class XmlRpcClient extends RpcClient<String> {
|
||||
} catch (IOException ex) {
|
||||
reason = ex;
|
||||
// no retries for "init" request or if connection is refused
|
||||
if ("init".equals(request.getMethodName())
|
||||
|| ex.getCause() != null && ex.getCause() instanceof ExecutionException) {
|
||||
if ("init".equals(request.getMethodName()) || ex.getCause() instanceof ExecutionException) {
|
||||
break;
|
||||
}
|
||||
logger.debug("XmlRpcMessage failed({}), sending message again {}/{}", ex.getMessage(), rpcRetryCounter,
|
||||
|
@ -47,7 +47,7 @@ public class BinRpcMessage implements RpcRequest<byte[]>, RpcResponse {
|
||||
}
|
||||
|
||||
private Object[] messageData;
|
||||
private byte binRpcData[];
|
||||
private byte[] binRpcData;
|
||||
private int offset;
|
||||
|
||||
private String methodName;
|
||||
@ -74,7 +74,7 @@ public class BinRpcMessage implements RpcRequest<byte[]>, RpcResponse {
|
||||
*/
|
||||
public BinRpcMessage(InputStream is, boolean methodHeader, Charset encoding) throws IOException {
|
||||
this.encoding = encoding;
|
||||
byte sig[] = new byte[8];
|
||||
byte[] sig = new byte[8];
|
||||
int length = is.read(sig, 0, 4);
|
||||
if (length != 4) {
|
||||
throw new EOFException("Only " + length + " bytes received reading signature");
|
||||
@ -85,7 +85,7 @@ public class BinRpcMessage implements RpcRequest<byte[]>, RpcResponse {
|
||||
throw new EOFException("Only " + length + " bytes received reading message length");
|
||||
}
|
||||
int datasize = (new BigInteger(Arrays.copyOfRange(sig, 4, 8))).intValue();
|
||||
byte payload[] = new byte[datasize];
|
||||
byte[] payload = new byte[datasize];
|
||||
int offset = 0;
|
||||
int currentLength;
|
||||
|
||||
@ -201,14 +201,14 @@ public class BinRpcMessage implements RpcRequest<byte[]>, RpcResponse {
|
||||
|
||||
// read rpc values
|
||||
private int readInt() {
|
||||
byte bi[] = new byte[4];
|
||||
byte[] bi = new byte[4];
|
||||
System.arraycopy(binRpcData, offset, bi, 0, 4);
|
||||
offset += 4;
|
||||
return (new BigInteger(bi)).intValue();
|
||||
}
|
||||
|
||||
private long readInt64() {
|
||||
byte bi[] = new byte[8];
|
||||
byte[] bi = new byte[8];
|
||||
System.arraycopy(binRpcData, offset, bi, 0, 8);
|
||||
offset += 8;
|
||||
return (new BigInteger(bi)).longValue();
|
||||
@ -274,7 +274,7 @@ public class BinRpcMessage implements RpcRequest<byte[]>, RpcResponse {
|
||||
|
||||
private void addByte(byte b) {
|
||||
if (offset == binRpcData.length) {
|
||||
byte newdata[] = new byte[binRpcData.length * 2];
|
||||
byte[] newdata = new byte[binRpcData.length * 2];
|
||||
System.arraycopy(binRpcData, 0, newdata, 0, binRpcData.length);
|
||||
binRpcData = newdata;
|
||||
}
|
||||
@ -311,7 +311,7 @@ public class BinRpcMessage implements RpcRequest<byte[]>, RpcResponse {
|
||||
}
|
||||
|
||||
private void addString(String string) {
|
||||
byte sd[] = string.getBytes(encoding);
|
||||
byte[] sd = string.getBytes(encoding);
|
||||
for (byte ch : sd) {
|
||||
addByte(ch);
|
||||
}
|
||||
@ -351,13 +351,11 @@ public class BinRpcMessage implements RpcRequest<byte[]>, RpcResponse {
|
||||
} else if (object.getClass() == Date.class) {
|
||||
addInt(5);
|
||||
addInt((int) ((Date) object).getTime() / 1000);
|
||||
} else if (object instanceof List<?>) {
|
||||
Collection<?> list = (Collection<?>) object;
|
||||
} else if (object instanceof List<?> list) {
|
||||
addInt(0x100);
|
||||
addInt(list.size());
|
||||
addList(list);
|
||||
} else if (object instanceof Map<?, ?>) {
|
||||
Map<?, ?> map = (Map<?, ?>) object;
|
||||
} else if (object instanceof Map<?, ?> map) {
|
||||
addInt(0x101);
|
||||
addInt(map.size());
|
||||
for (Map.Entry<?, ?> entry : map.entrySet()) {
|
||||
|
@ -42,10 +42,10 @@ public class RpcUtils {
|
||||
sb.append("[\n");
|
||||
}
|
||||
for (Object o : c) {
|
||||
if (o instanceof Map) {
|
||||
dumpMap((Map<?, ?>) o, sb, indent + 1);
|
||||
} else if (o instanceof Object[]) {
|
||||
dumpCollection((Object[]) o, sb, indent + 1);
|
||||
if (o instanceof Map map) {
|
||||
dumpMap(map, sb, indent + 1);
|
||||
} else if (o instanceof Object[] objects) {
|
||||
dumpCollection(objects, sb, indent + 1);
|
||||
} else {
|
||||
for (int in = 0; in < indent; in++) {
|
||||
sb.append('\t');
|
||||
@ -76,12 +76,12 @@ public class RpcUtils {
|
||||
}
|
||||
sb.append(me.getKey());
|
||||
sb.append('=');
|
||||
if (o instanceof Map<?, ?>) {
|
||||
if (o instanceof Map<?, ?> map) {
|
||||
sb.append("\n");
|
||||
dumpMap((Map<?, ?>) o, sb, indent + 1);
|
||||
} else if (o instanceof Object[]) {
|
||||
dumpMap(map, sb, indent + 1);
|
||||
} else if (o instanceof Object[] objects) {
|
||||
sb.append("\n");
|
||||
dumpCollection((Object[]) o, sb, indent + 1);
|
||||
dumpCollection(objects, sb, indent + 1);
|
||||
} else {
|
||||
sb.append(o);
|
||||
sb.append('\n');
|
||||
|
@ -136,16 +136,16 @@ public class XmlRpcRequest implements RpcRequest<String> {
|
||||
tag("boolean", ((Boolean) value).booleanValue() ? "1" : "0");
|
||||
} else if (clazz == Date.class) {
|
||||
tag("dateTime.iso8601", xmlRpcDateFormat.format(((Date) value)));
|
||||
} else if (value instanceof Calendar) {
|
||||
generateValue(((Calendar) value).getTime());
|
||||
} else if (value instanceof byte[]) {
|
||||
tag("base64", Base64.getEncoder().encodeToString((byte[]) value));
|
||||
} else if (value instanceof Calendar calendar) {
|
||||
generateValue(calendar.getTime());
|
||||
} else if (value instanceof byte[] bytes) {
|
||||
tag("base64", Base64.getEncoder().encodeToString(bytes));
|
||||
} else if (clazz.isArray() || value instanceof List) {
|
||||
sb.append("<array><data>");
|
||||
|
||||
Object[] array = null;
|
||||
if (value instanceof List) {
|
||||
array = ((List<?>) value).toArray();
|
||||
if (value instanceof List list) {
|
||||
array = list.toArray();
|
||||
} else {
|
||||
array = (Object[]) value;
|
||||
}
|
||||
|
@ -97,10 +97,10 @@ public class XmlRpcResponse implements RpcResponse {
|
||||
public void startElement(String uri, String localName, String qName, Attributes attributes)
|
||||
throws SAXException {
|
||||
String tag = qName.toLowerCase();
|
||||
if (tag.equals("array") || tag.equals("struct")) {
|
||||
if ("array".equals(tag) || "struct".equals(tag)) {
|
||||
currentDataObject.addLast(new ArrayList<>());
|
||||
}
|
||||
isValueTag = tag.equals("value");
|
||||
isValueTag = "value".equals(tag);
|
||||
tagValue = new StringBuilder();
|
||||
}
|
||||
|
||||
|
@ -105,8 +105,7 @@ public abstract class CommonRpcParser<M, R> implements RpcParser<M, R> {
|
||||
* Converts the object to a string array.
|
||||
*/
|
||||
protected String[] toOptionList(Object optionList) {
|
||||
if (optionList != null && optionList instanceof Object[]) {
|
||||
Object[] vl = (Object[]) optionList;
|
||||
if (optionList != null && optionList instanceof Object[] vl) {
|
||||
String[] stringArray = new String[vl.length];
|
||||
for (int i = 0; i < vl.length; i++) {
|
||||
stringArray[i] = vl[i].toString();
|
||||
@ -232,9 +231,9 @@ public abstract class CommonRpcParser<M, R> implements RpcParser<M, R> {
|
||||
if (value == null || value.isBlank()) {
|
||||
return null;
|
||||
}
|
||||
if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("on")) {
|
||||
if ("true".equalsIgnoreCase(value) || "on".equalsIgnoreCase(value)) {
|
||||
return (Boolean.TRUE);
|
||||
} else if (value.equalsIgnoreCase("false") || value.equalsIgnoreCase("off")) {
|
||||
} else if ("false".equalsIgnoreCase(value) || "off".equalsIgnoreCase(value)) {
|
||||
return (Boolean.FALSE);
|
||||
} else if (value.matches("(-|\\+)?[0-9]+")) {
|
||||
return (Integer.valueOf(value));
|
||||
|
@ -58,7 +58,7 @@ public class GetParamsetParser extends CommonRpcParser<Object[], Void> {
|
||||
|
||||
// suppress warning for this datapoint due wrong CCU metadata
|
||||
String deviceType = channel.getDevice().getType();
|
||||
boolean isHmSenMdirNextTrans = dpInfo.getName().equals("NEXT_TRANSMISSION")
|
||||
boolean isHmSenMdirNextTrans = "NEXT_TRANSMISSION".equals(dpInfo.getName())
|
||||
&& (deviceType.startsWith("HM-Sen-MDIR-O") || deviceType.startsWith("HM-Sen-MDIR-WM55")
|
||||
|| deviceType.startsWith("HM-Sec-MDIR-2"));
|
||||
if (!isHmSenMdirNextTrans) {
|
||||
|
@ -28,9 +28,9 @@ import org.openhab.core.common.ThreadPoolManager;
|
||||
* @author Gerhard Riegler - Initial contribution
|
||||
*/
|
||||
public class BinRpcNetworkService implements Runnable {
|
||||
private static final byte BIN_EMPTY_STRING[] = { 'B', 'i', 'n', 1, 0, 0, 0, 8, 0, 0, 0, 3, 0, 0, 0, 0 };
|
||||
private static final byte BIN_EMPTY_ARRAY[] = { 'B', 'i', 'n', 1, 0, 0, 0, 8, 0, 0, 1, 0, 0, 0, 0, 0 };
|
||||
private static final byte BIN_EMPTY_EVENT_LIST[] = { 'B', 'i', 'n', 1, 0, 0, 0, 21, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0,
|
||||
private static final byte[] BIN_EMPTY_STRING = { 'B', 'i', 'n', 1, 0, 0, 0, 8, 0, 0, 0, 3, 0, 0, 0, 0 };
|
||||
private static final byte[] BIN_EMPTY_ARRAY = { 'B', 'i', 'n', 1, 0, 0, 0, 8, 0, 0, 1, 0, 0, 0, 0, 0 };
|
||||
private static final byte[] BIN_EMPTY_EVENT_LIST = { 'B', 'i', 'n', 1, 0, 0, 0, 21, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0,
|
||||
3, 0, 0, 0, 5, 'e', 'v', 'e', 'n', 't' };
|
||||
|
||||
private static final String RPC_POOL_NAME = "homematicRpc";
|
||||
|
@ -43,7 +43,7 @@ public class DeleteDeviceModeVirtualDatapointHandler extends AbstractVirtualData
|
||||
|
||||
@Override
|
||||
public void initialize(HmDevice device) {
|
||||
if (!device.isGatewayExtras() && !(device.getHmInterface() == HmInterface.CUXD)) {
|
||||
if (!device.isGatewayExtras() && device.getHmInterface() != HmInterface.CUXD) {
|
||||
HmDatapoint dp = addDatapoint(device, 0, getName(), HmValueType.ENUM, 0, false);
|
||||
dp.setOptions(new String[] { MODE_LOCKED, MODE_RESET, MODE_FORCE, MODE_DEFER });
|
||||
dp.setMinValue(0);
|
||||
|
@ -44,7 +44,7 @@ public class DeleteDeviceVirtualDatapointHandler extends AbstractVirtualDatapoin
|
||||
|
||||
@Override
|
||||
public void initialize(HmDevice device) {
|
||||
if (!device.isGatewayExtras() && !(device.getHmInterface() == HmInterface.CUXD)) {
|
||||
if (!device.isGatewayExtras() && device.getHmInterface() != HmInterface.CUXD) {
|
||||
addDatapoint(device, 0, getName(), HmValueType.BOOL, Boolean.FALSE, false);
|
||||
}
|
||||
}
|
||||
|
@ -40,8 +40,7 @@ public class DisplayOptionsVirtualDatapointHandler extends AbstractVirtualDatapo
|
||||
|
||||
@Override
|
||||
public void initialize(HmDevice device) {
|
||||
if (device.getType().startsWith(DEVICE_TYPE_19_REMOTE_CONTROL)
|
||||
&& !(device.getHmInterface() == HmInterface.CUXD)) {
|
||||
if (device.getType().startsWith(DEVICE_TYPE_19_REMOTE_CONTROL) && device.getHmInterface() != HmInterface.CUXD) {
|
||||
addDatapoint(device, 18, getName(), HmValueType.STRING, null, false);
|
||||
}
|
||||
}
|
||||
|
@ -62,8 +62,8 @@ public class OnTimeAutomaticVirtualDatapointHandler extends AbstractVirtualDatap
|
||||
|
||||
@Override
|
||||
public boolean canHandleCommand(HmDatapoint dp, Object value) {
|
||||
boolean isLevel = DATAPOINT_NAME_LEVEL.equals(dp.getName()) && value != null && value instanceof Number
|
||||
&& ((Number) value).doubleValue() > 0.0;
|
||||
boolean isLevel = DATAPOINT_NAME_LEVEL.equals(dp.getName()) && value != null
|
||||
&& value instanceof Number numberCommand && numberCommand.doubleValue() > 0.0;
|
||||
boolean isState = DATAPOINT_NAME_STATE.equals(dp.getName()) && MiscUtils.isTrueValue(value);
|
||||
|
||||
return ((isLevel || isState) && getVirtualDatapointValue(dp.getChannel()) > 0.0)
|
||||
|
@ -19,7 +19,7 @@ import java.net.DatagramPacket;
|
||||
import java.net.InetAddress;
|
||||
import java.net.MulticastSocket;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.openhab.binding.homematic.internal.discovery.eq3udp.Eq3UdpRequest;
|
||||
@ -50,7 +50,7 @@ public class CcuDiscoveryService extends AbstractDiscoveryService {
|
||||
private NetworkAddressService networkAddressService;
|
||||
|
||||
public CcuDiscoveryService() {
|
||||
super(Collections.singleton(THING_TYPE_BRIDGE), 5, true);
|
||||
super(Set.of(THING_TYPE_BRIDGE), 5, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,7 +14,6 @@ package org.openhab.binding.homematic.internal.discovery;
|
||||
|
||||
import static org.openhab.binding.homematic.internal.HomematicBindingConstants.THING_TYPE_BRIDGE;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -41,7 +40,7 @@ public class HomegearDiscoveryParticipant implements UpnpDiscoveryParticipant {
|
||||
|
||||
@Override
|
||||
public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
|
||||
return Collections.singleton(THING_TYPE_BRIDGE);
|
||||
return Set.of(THING_TYPE_BRIDGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,7 +14,7 @@ package org.openhab.binding.homematic.internal.discovery;
|
||||
|
||||
import static org.openhab.binding.homematic.internal.HomematicBindingConstants.BINDING_ID;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
@ -54,13 +54,13 @@ public class HomematicDeviceDiscoveryService extends AbstractDiscoveryService
|
||||
private volatile Object installModeSync = new Object();
|
||||
|
||||
public HomematicDeviceDiscoveryService() {
|
||||
super(Collections.singleton(new ThingTypeUID(BINDING_ID, "-")), DISCOVER_TIMEOUT_SECONDS, false);
|
||||
super(Set.of(new ThingTypeUID(BINDING_ID, "-")), DISCOVER_TIMEOUT_SECONDS, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThingHandler(@Nullable ThingHandler handler) {
|
||||
if (handler instanceof HomematicBridgeHandler) {
|
||||
this.bridgeHandler = (HomematicBridgeHandler) handler;
|
||||
if (handler instanceof HomematicBridgeHandler homematicBridgeHandler) {
|
||||
this.bridgeHandler = homematicBridgeHandler;
|
||||
this.bridgeHandler.setDiscoveryService(this);
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ import static org.openhab.core.thing.Thing.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -229,7 +229,7 @@ public class HomematicBridgeHandler extends BaseBridgeHandler implements Homemat
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(HomematicDeviceDiscoveryService.class);
|
||||
return Set.of(HomematicDeviceDiscoveryService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -594,15 +594,14 @@ public class HomematicThingHandler extends BaseThingHandler {
|
||||
if (dp != null) {
|
||||
try {
|
||||
if (newValue != null) {
|
||||
if (newValue instanceof BigDecimal) {
|
||||
final BigDecimal decimal = (BigDecimal) newValue;
|
||||
if (newValue instanceof BigDecimal decimal) {
|
||||
if (dp.isIntegerType()) {
|
||||
newValue = decimal.intValue();
|
||||
} else if (dp.isFloatType()) {
|
||||
newValue = decimal.doubleValue();
|
||||
}
|
||||
} else if (newValue instanceof String && dp.isEnumType()) {
|
||||
newValue = dp.getOptionIndex((String) newValue);
|
||||
} else if (newValue instanceof String string && dp.isEnumType()) {
|
||||
newValue = dp.getOptionIndex(string);
|
||||
}
|
||||
if (!Objects.equals(dp.getValue(), newValue)) {
|
||||
sendDatapoint(dp, new HmDatapointConfig(), newValue);
|
||||
|
@ -426,9 +426,10 @@ public class HmDatapoint implements Cloneable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s[name=%s,value=%s,defaultValue=%s,type=%s,minValue=%s,maxValue=%s,options=%s,"
|
||||
+ "readOnly=%b,readable=%b,unit=%s,description=%s,info=%s,paramsetType=%s,virtual=%b,trigger=%b]",
|
||||
getClass().getSimpleName(), name, value, defaultValue, type, minValue, maxValue,
|
||||
return String.format("""
|
||||
%s[name=%s,value=%s,defaultValue=%s,type=%s,minValue=%s,maxValue=%s,options=%s,\
|
||||
readOnly=%b,readable=%b,unit=%s,description=%s,info=%s,paramsetType=%s,virtual=%b,trigger=%b]\
|
||||
""", getClass().getSimpleName(), name, value, defaultValue, type, minValue, maxValue,
|
||||
(options == null ? null : String.join(";", options)), readOnly, readable, unit, description, info,
|
||||
paramsetType, virtual, trigger);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ public class HmDatapointInfo {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || !(obj instanceof HmDatapointInfo)) {
|
||||
if (!(obj instanceof HmDatapointInfo)) {
|
||||
return false;
|
||||
}
|
||||
HmDatapointInfo comp = (HmDatapointInfo) obj;
|
||||
|
@ -213,7 +213,7 @@ public class HmDevice {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || !(obj instanceof HmDevice)) {
|
||||
if (!(obj instanceof HmDevice)) {
|
||||
return false;
|
||||
}
|
||||
HmDevice comp = (HmDevice) obj;
|
||||
|
@ -189,11 +189,11 @@ public class HomematicTypeGeneratorImpl implements HomematicTypeGenerator {
|
||||
for (String deviceType : firmwaresByType.keySet()) {
|
||||
Set<String> firmwares = firmwaresByType.get(deviceType);
|
||||
if (firmwares.size() > 1) {
|
||||
logger.info(
|
||||
"Multiple firmware versions for device type '{}' found ({}). "
|
||||
+ "Make sure, all devices of the same type have the same firmware version, "
|
||||
+ "otherwise you MAY have channel and/or datapoint errors in the logfile",
|
||||
deviceType, String.join(", ", firmwares));
|
||||
logger.info("""
|
||||
Multiple firmware versions for device type '{}' found ({}). \
|
||||
Make sure, all devices of the same type have the same firmware version, \
|
||||
otherwise you MAY have channel and/or datapoint errors in the logfile\
|
||||
""", deviceType, String.join(", ", firmwares));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -387,7 +387,7 @@ public class HomematicTypeGeneratorImpl implements HomematicTypeGenerator {
|
||||
*/
|
||||
public static boolean isIgnoredDatapoint(HmDatapoint dp) {
|
||||
for (String testValue : IGNORE_DATAPOINT_NAMES) {
|
||||
if (dp.getName().indexOf(testValue) > -1) {
|
||||
if (dp.getName().contains(testValue)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -299,8 +299,11 @@ public class P1Payload {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("P1 [version: %d model: %s ssid: %s signal: %d"
|
||||
+ " imp1: %f imp2: %f exp1: %f exp2: %f active: %f active1: %f active2: %f active3: %f gas: %f timestamp: %.0f]",
|
||||
return String.format(
|
||||
"""
|
||||
P1 [version: %d model: %s ssid: %s signal: %d\
|
||||
imp1: %f imp2: %f exp1: %f exp2: %f active: %f active1: %f active2: %f active3: %f gas: %f timestamp: %.0f]\
|
||||
""",
|
||||
smrVersion, meterModel, wifiSsid, wifiStrength, totalEnergyImportT1Kwh, totalEnergyImportT2Kwh,
|
||||
totalEnergyExportT1Kwh, totalEnergyExportT2Kwh, activePowerW, activePowerL1W, activePowerL2W,
|
||||
activePowerL3W, totalGasM3, gasTimestamp);
|
||||
|
@ -39,9 +39,7 @@ public class HPFeatures {
|
||||
boolean localScannerStatus = false;
|
||||
|
||||
for (Node n = root.getFirstChild(); n != null; n = n.getNextSibling()) {
|
||||
if (n instanceof Element) {
|
||||
Element feature = (Element) n;
|
||||
|
||||
if (n instanceof Element feature) {
|
||||
NodeList resourceType = feature.getElementsByTagName("dd:ResourceType");
|
||||
|
||||
if (resourceType.getLength() > 0) {
|
||||
|
@ -279,8 +279,7 @@ public class HPUsage {
|
||||
int value = 0;
|
||||
|
||||
for (Node n = parentNode.getFirstChild(); n != null; n = n.getNextSibling()) {
|
||||
if (n instanceof Element) {
|
||||
Element nodeItem = (Element) n;
|
||||
if (n instanceof Element nodeItem) {
|
||||
if (nodeItem.getElementsByTagName(collateTagName).item(0).getTextContent()
|
||||
.equalsIgnoreCase(collateTagNameValue)) {
|
||||
int nodeValue = Integer
|
||||
|
@ -45,11 +45,9 @@ public class Util {
|
||||
String contentString = contentProvider == null ? "null"
|
||||
: StreamSupport.stream(contentProvider.spliterator(), false)
|
||||
.map(b -> StandardCharsets.UTF_8.decode(b).toString()).collect(Collectors.joining(", "));
|
||||
String logString = "Method = {" + request.getMethod() + "}, Headers = {"
|
||||
return "Method = {" + request.getMethod() + "}, Headers = {"
|
||||
+ request.getHeaders().stream().map(HttpField::toString).collect(Collectors.joining(", "))
|
||||
+ "}, Content = {" + contentString + "}";
|
||||
|
||||
return logString;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,13 +60,11 @@ public class ColorItemConverter extends AbstractTransformingItemConverter {
|
||||
return string;
|
||||
}
|
||||
|
||||
if (command instanceof HSBType) {
|
||||
HSBType newState = (HSBType) command;
|
||||
if (command instanceof HSBType newState) {
|
||||
state = newState;
|
||||
return hsbToString(newState);
|
||||
} else if (command instanceof PercentType && state instanceof HSBType) {
|
||||
HSBType newState = new HSBType(((HSBType) state).getBrightness(), ((HSBType) state).getSaturation(),
|
||||
(PercentType) command);
|
||||
} else if (command instanceof PercentType percentCommand && state instanceof HSBType hsb) {
|
||||
HSBType newState = new HSBType(hsb.getBrightness(), hsb.getSaturation(), percentCommand);
|
||||
state = newState;
|
||||
return hsbToString(newState);
|
||||
}
|
||||
@ -78,32 +76,29 @@ public class ColorItemConverter extends AbstractTransformingItemConverter {
|
||||
public State toState(String string) {
|
||||
State newState = UnDefType.UNDEF;
|
||||
if (string.equals(channelConfig.onValue)) {
|
||||
if (state instanceof HSBType) {
|
||||
newState = new HSBType(((HSBType) state).getHue(), ((HSBType) state).getSaturation(),
|
||||
PercentType.HUNDRED);
|
||||
if (state instanceof HSBType hsb) {
|
||||
newState = new HSBType(hsb.getHue(), hsb.getSaturation(), PercentType.HUNDRED);
|
||||
} else {
|
||||
newState = HSBType.WHITE;
|
||||
}
|
||||
} else if (string.equals(channelConfig.offValue)) {
|
||||
if (state instanceof HSBType) {
|
||||
newState = new HSBType(((HSBType) state).getHue(), ((HSBType) state).getSaturation(), PercentType.ZERO);
|
||||
if (state instanceof HSBType hsb) {
|
||||
newState = new HSBType(hsb.getHue(), hsb.getSaturation(), PercentType.ZERO);
|
||||
} else {
|
||||
newState = HSBType.BLACK;
|
||||
}
|
||||
} else if (string.equals(channelConfig.increaseValue) && state instanceof HSBType) {
|
||||
BigDecimal newBrightness = ((HSBType) state).getBrightness().toBigDecimal().add(channelConfig.step);
|
||||
} else if (string.equals(channelConfig.increaseValue) && state instanceof HSBType hsb) {
|
||||
BigDecimal newBrightness = hsb.getBrightness().toBigDecimal().add(channelConfig.step);
|
||||
if (HUNDRED.compareTo(newBrightness) < 0) {
|
||||
newBrightness = HUNDRED;
|
||||
}
|
||||
newState = new HSBType(((HSBType) state).getHue(), ((HSBType) state).getSaturation(),
|
||||
new PercentType(newBrightness));
|
||||
} else if (string.equals(channelConfig.decreaseValue) && state instanceof HSBType) {
|
||||
BigDecimal newBrightness = ((HSBType) state).getBrightness().toBigDecimal().subtract(channelConfig.step);
|
||||
newState = new HSBType(hsb.getHue(), hsb.getSaturation(), new PercentType(newBrightness));
|
||||
} else if (string.equals(channelConfig.decreaseValue) && state instanceof HSBType hsb) {
|
||||
BigDecimal newBrightness = hsb.getBrightness().toBigDecimal().subtract(channelConfig.step);
|
||||
if (BigDecimal.ZERO.compareTo(newBrightness) > 0) {
|
||||
newBrightness = BigDecimal.ZERO;
|
||||
}
|
||||
newState = new HSBType(((HSBType) state).getHue(), ((HSBType) state).getSaturation(),
|
||||
new PercentType(newBrightness));
|
||||
newState = new HSBType(hsb.getHue(), hsb.getSaturation(), new PercentType(newBrightness));
|
||||
} else {
|
||||
Matcher matcher = TRIPLE_MATCHER.matcher(string);
|
||||
if (matcher.matches()) {
|
||||
|
@ -55,8 +55,8 @@ public class DimmerItemConverter extends AbstractTransformingItemConverter {
|
||||
return string;
|
||||
}
|
||||
|
||||
if (command instanceof PercentType) {
|
||||
return ((PercentType) command).toString();
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
return percentCommand.toString();
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Command type '" + command.toString() + "' not supported");
|
||||
@ -70,14 +70,14 @@ public class DimmerItemConverter extends AbstractTransformingItemConverter {
|
||||
newState = PercentType.HUNDRED;
|
||||
} else if (string.equals(channelConfig.offValue)) {
|
||||
newState = PercentType.ZERO;
|
||||
} else if (string.equals(channelConfig.increaseValue) && state instanceof PercentType) {
|
||||
BigDecimal newBrightness = ((PercentType) state).toBigDecimal().add(channelConfig.step);
|
||||
} else if (string.equals(channelConfig.increaseValue) && state instanceof PercentType brightnessState) {
|
||||
BigDecimal newBrightness = brightnessState.toBigDecimal().add(channelConfig.step);
|
||||
if (HUNDRED.compareTo(newBrightness) < 0) {
|
||||
newBrightness = HUNDRED;
|
||||
}
|
||||
newState = new PercentType(newBrightness);
|
||||
} else if (string.equals(channelConfig.decreaseValue) && state instanceof PercentType) {
|
||||
BigDecimal newBrightness = ((PercentType) state).toBigDecimal().subtract(channelConfig.step);
|
||||
} else if (string.equals(channelConfig.decreaseValue) && state instanceof PercentType brightnessState) {
|
||||
BigDecimal newBrightness = brightnessState.toBigDecimal().subtract(channelConfig.step);
|
||||
if (BigDecimal.ZERO.compareTo(newBrightness) > 0) {
|
||||
newBrightness = BigDecimal.ZERO;
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ public class GenericItemConverter extends AbstractTransformingItemConverter {
|
||||
this.toState = toState;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected State toState(String value) {
|
||||
try {
|
||||
return toState.apply(value);
|
||||
@ -53,6 +54,7 @@ public class GenericItemConverter extends AbstractTransformingItemConverter {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String toString(Command command) {
|
||||
return command.toString();
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class RollershutterItemConverter extends AbstractTransformingItemConverte
|
||||
return string;
|
||||
}
|
||||
|
||||
if (command instanceof PercentType) {
|
||||
if (command instanceof PercentType brightnessState) {
|
||||
final String downValue = channelConfig.downValue;
|
||||
final String upValue = channelConfig.upValue;
|
||||
if (command.equals(PercentType.HUNDRED) && downValue != null) {
|
||||
@ -59,7 +59,7 @@ public class RollershutterItemConverter extends AbstractTransformingItemConverte
|
||||
} else if (command.equals(PercentType.ZERO) && upValue != null) {
|
||||
return upValue;
|
||||
} else {
|
||||
return ((PercentType) command).toString();
|
||||
return brightnessState.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,9 +83,8 @@ public class HttpResponseListener extends BufferingResponseListener {
|
||||
}
|
||||
|
||||
private String responseToLogString(Response response) {
|
||||
String logString = "Code = {" + response.getStatus() + "}, Headers = {"
|
||||
return "Code = {" + response.getStatus() + "}, Headers = {"
|
||||
+ response.getHeaders().stream().map(HttpField::toString).collect(Collectors.joining(", "))
|
||||
+ "}, Content = {" + getContentAsString() + "}";
|
||||
return logString;
|
||||
}
|
||||
}
|
||||
|
@ -264,8 +264,8 @@ public class HydrawiseGraphQLClient {
|
||||
private void sendGraphQLMutation(String content)
|
||||
throws HydrawiseConnectionException, HydrawiseAuthenticationException, HydrawiseCommandException {
|
||||
Mutation mutation = new Mutation(content);
|
||||
logger.debug("Sending Mutation {}", gson.toJson(mutation).toString());
|
||||
String response = sendGraphQLRequest(gson.toJson(mutation).toString());
|
||||
logger.debug("Sending Mutation {}", gson.toJson(mutation));
|
||||
String response = sendGraphQLRequest(gson.toJson(mutation));
|
||||
logger.debug("Mutation response {}", response);
|
||||
try {
|
||||
MutationResponse mResponse = gson.fromJson(response, MutationResponse.class);
|
||||
@ -273,7 +273,7 @@ public class HydrawiseGraphQLClient {
|
||||
throw new HydrawiseCommandException("Malformed response: " + response);
|
||||
}
|
||||
Optional<MutationResponseStatus> status = mResponse.data.values().stream().findFirst();
|
||||
if (!status.isPresent()) {
|
||||
if (status.isEmpty()) {
|
||||
throw new HydrawiseCommandException("Unknown response: " + response);
|
||||
}
|
||||
if (status.get().status != StatusCode.OK) {
|
||||
|
@ -27,6 +27,6 @@ public class MutationResponse {
|
||||
public enum StatusCode {
|
||||
OK,
|
||||
WARNING,
|
||||
ERROR;
|
||||
ERROR
|
||||
}
|
||||
}
|
||||
|
@ -99,8 +99,7 @@ public class HydrawiseLocalApiClient {
|
||||
public LocalScheduleResponse getLocalSchedule()
|
||||
throws HydrawiseConnectionException, HydrawiseAuthenticationException {
|
||||
String json = doGet(localGetURL);
|
||||
LocalScheduleResponse response = gson.fromJson(json, LocalScheduleResponse.class);
|
||||
return response;
|
||||
return gson.fromJson(json, LocalScheduleResponse.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -191,7 +190,7 @@ public class HydrawiseLocalApiClient {
|
||||
throws HydrawiseConnectionException, HydrawiseAuthenticationException, HydrawiseCommandException {
|
||||
String json = doGet(url);
|
||||
SetZoneResponse response = gson.fromJson(json, SetZoneResponse.class);
|
||||
if (response.messageType.equals("error")) {
|
||||
if ("error".equals(response.messageType)) {
|
||||
throw new HydrawiseCommandException(response.message);
|
||||
}
|
||||
return response.message;
|
||||
|
@ -12,9 +12,9 @@
|
||||
*/
|
||||
package org.openhab.binding.hydrawise.internal.discovery;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
@ -46,7 +46,7 @@ public class HydrawiseCloudControllerDiscoveryService extends AbstractDiscoveryS
|
||||
HydrawiseAccountHandler handler;
|
||||
|
||||
public HydrawiseCloudControllerDiscoveryService() {
|
||||
super(Collections.singleton(HydrawiseBindingConstants.THING_TYPE_CONTROLLER), TIMEOUT, true);
|
||||
super(Set.of(HydrawiseBindingConstants.THING_TYPE_CONTROLLER), TIMEOUT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -103,8 +103,7 @@ public class HydrawiseCloudControllerDiscoveryService extends AbstractDiscoveryS
|
||||
String.valueOf(id));
|
||||
thingDiscovered(DiscoveryResultBuilder.create(thingUID).withLabel(label).withBridge(bridgeUID)
|
||||
.withProperty(HydrawiseBindingConstants.CONFIG_CONTROLLER_ID, id)
|
||||
.withRepresentationProperty(String.valueOf(HydrawiseBindingConstants.CONFIG_CONTROLLER_ID))
|
||||
.build());
|
||||
.withRepresentationProperty(HydrawiseBindingConstants.CONFIG_CONTROLLER_ID).build());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -122,7 +123,7 @@ public class HydrawiseAccountHandler extends BaseBridgeHandler implements Access
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(HydrawiseCloudControllerDiscoveryService.class);
|
||||
return Set.of(HydrawiseCloudControllerDiscoveryService.class);
|
||||
}
|
||||
|
||||
public void addControllerListeners(HydrawiseControllerListener listener) {
|
||||
@ -209,7 +210,7 @@ public class HydrawiseAccountHandler extends BaseBridgeHandler implements Access
|
||||
if (response == null) {
|
||||
throw new HydrawiseConnectionException("Malformed response");
|
||||
}
|
||||
if (response.errors != null && response.errors.size() > 0) {
|
||||
if (response.errors != null && !response.errors.isEmpty()) {
|
||||
throw new HydrawiseConnectionException(response.errors.stream().map(error -> error.message).reduce("",
|
||||
(messages, message) -> messages + message + ". "));
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ public class HydrawiseLocalHandler extends BaseThingHandler {
|
||||
}
|
||||
|
||||
updateGroupState(CHANNEL_GROUP_ALLZONES, CHANNEL_ZONE_RUN,
|
||||
status.running.size() > 0 ? OnOffType.ON : OnOffType.OFF);
|
||||
!status.running.isEmpty() ? OnOffType.ON : OnOffType.OFF);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
package org.openhab.binding.hyperion.internal;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -39,7 +38,7 @@ public class HyperionDiscoveryParticipant implements MDNSDiscoveryParticipant {
|
||||
|
||||
@Override
|
||||
public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
|
||||
return Collections.singleton(HyperionBindingConstants.THING_TYPE_SERVER_NG);
|
||||
return Set.of(HyperionBindingConstants.THING_TYPE_SERVER_NG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -68,8 +68,6 @@ public class JsonTcpConnection {
|
||||
outToServer.writeBytes(json + System.lineSeparator());
|
||||
outToServer.flush();
|
||||
response = inFromServer.readLine();
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
}
|
||||
logger.debug("Received: {}", response);
|
||||
return response;
|
||||
|
@ -255,10 +255,9 @@ public class HyperionHandler extends BaseThingHandler {
|
||||
}
|
||||
|
||||
private void handleBrightness(Command command) throws IOException, CommandUnsuccessfulException {
|
||||
if (command instanceof PercentType) {
|
||||
PercentType percent = (PercentType) command;
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
Transform transform = new Transform();
|
||||
transform.setLuminanceGain(percent.doubleValue() / 100);
|
||||
transform.setLuminanceGain(percentCommand.doubleValue() / 100);
|
||||
TransformCommand transformCommand = new TransformCommand(transform);
|
||||
sendCommand(transformCommand);
|
||||
} else {
|
||||
@ -267,9 +266,8 @@ public class HyperionHandler extends BaseThingHandler {
|
||||
}
|
||||
|
||||
private void handleColor(Command command) throws IOException, CommandUnsuccessfulException {
|
||||
if (command instanceof HSBType) {
|
||||
HSBType color = (HSBType) command;
|
||||
Color c = new Color(color.getRGB());
|
||||
if (command instanceof HSBType hsbCommand) {
|
||||
Color c = new Color(hsbCommand.getRGB());
|
||||
int r = c.getRed();
|
||||
int g = c.getGreen();
|
||||
int b = c.getBlue();
|
||||
|
@ -176,7 +176,6 @@ public class HyperionNgHandler extends BaseThingHandler {
|
||||
// update Hyperion, older API compatibility
|
||||
Hyperion hyperion = info.getHyperion();
|
||||
if (hyperion != null) {
|
||||
|
||||
updateHyperion(hyperion);
|
||||
}
|
||||
|
||||
@ -422,9 +421,8 @@ public class HyperionNgHandler extends BaseThingHandler {
|
||||
}
|
||||
|
||||
private void handleBrightness(Command command) throws IOException, CommandUnsuccessfulException {
|
||||
if (command instanceof PercentType) {
|
||||
PercentType percent = (PercentType) command;
|
||||
int brightnessValue = percent.intValue();
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
int brightnessValue = percentCommand.intValue();
|
||||
|
||||
Adjustment adjustment = new Adjustment();
|
||||
adjustment.setBrightness(brightnessValue);
|
||||
@ -437,9 +435,8 @@ public class HyperionNgHandler extends BaseThingHandler {
|
||||
}
|
||||
|
||||
private void handleColor(Command command) throws IOException, CommandUnsuccessfulException {
|
||||
if (command instanceof HSBType) {
|
||||
HSBType color = (HSBType) command;
|
||||
Color c = new Color(color.getRGB());
|
||||
if (command instanceof HSBType hsbCommand) {
|
||||
Color c = new Color(hsbCommand.getRGB());
|
||||
int r = c.getRed();
|
||||
int g = c.getGreen();
|
||||
int b = c.getBlue();
|
||||
|
@ -45,7 +45,7 @@ public class Iammeter3080THandler extends IammeterBaseHandler {
|
||||
JsonObject iammeterData = iammeterDataElement.getAsJsonObject();
|
||||
String keyWord = "Datas";
|
||||
if (iammeterData.has("Datas") && iammeterData.has("SN")) {
|
||||
String groups[] = { "powerPhaseA", "powerPhaseB", "powerPhaseC" };
|
||||
String[] groups = { "powerPhaseA", "powerPhaseB", "powerPhaseC" };
|
||||
for (int row = 0; row < groups.length; row++) {
|
||||
String gpName = groups[row];
|
||||
List<Channel> chnList = getThing().getChannelsOfGroup(gpName);
|
||||
|
@ -200,13 +200,12 @@ public class IAqualinkHandler extends BaseThingHandler {
|
||||
: "on".equals(command.toString()) ? "1" : command.toString();
|
||||
client.lightCommand(serialNumber, sessionId, auxId, cmd,
|
||||
AuxiliaryType.fromChannelTypeUID(getChannelTypeUID(channelUID)).getSubType());
|
||||
} else if (command instanceof OnOffType) {
|
||||
} else if (command instanceof OnOffType onOffCommand) {
|
||||
// these are toggle commands and require we have the current state to turn on/off
|
||||
Auxiliary[] auxs = client.getAux(serialNumber, sessionId);
|
||||
Optional<Auxiliary> optional = Arrays.stream(auxs).filter(o -> o.getName().equals(channelName))
|
||||
.findFirst();
|
||||
if (optional.isPresent()) {
|
||||
OnOffType onOffCommand = (OnOffType) command;
|
||||
State currentState = toState(channelName, "Switch", optional.get().getState());
|
||||
if (!currentState.equals(onOffCommand)) {
|
||||
client.auxSetCommand(serialNumber, sessionId, channelName);
|
||||
@ -226,8 +225,7 @@ public class IAqualinkHandler extends BaseThingHandler {
|
||||
client.setPoolTemp(serialNumber, sessionId, value.floatValue());
|
||||
}
|
||||
}
|
||||
} else if (command instanceof OnOffType) {
|
||||
OnOffType onOffCommand = (OnOffType) command;
|
||||
} else if (command instanceof OnOffType onOffCommand) {
|
||||
// these are toggle commands and require we have the current state to turn on/off
|
||||
if (channelName.startsWith("onetouch_")) {
|
||||
OneTouch[] ota = client.getOneTouch(serialNumber, sessionId);
|
||||
|
@ -14,7 +14,6 @@ package org.openhab.binding.icalendar.internal;
|
||||
|
||||
import static org.openhab.binding.icalendar.internal.ICalendarBindingConstants.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@ -52,8 +51,8 @@ import org.slf4j.LoggerFactory;
|
||||
public class ICalendarHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Stream
|
||||
.of(Collections.singleton(THING_TYPE_CALENDAR), Collections.singleton(THING_TYPE_FILTERED_EVENTS))
|
||||
.flatMap(Set::stream).collect(Collectors.toSet());
|
||||
.of(Set.of(THING_TYPE_CALENDAR), Set.of(THING_TYPE_FILTERED_EVENTS)).flatMap(Set::stream)
|
||||
.collect(Collectors.toSet());
|
||||
private final Logger logger = LoggerFactory.getLogger(ICalendarHandlerFactory.class);
|
||||
|
||||
private final HttpClient sharedHttpClient;
|
||||
@ -81,8 +80,8 @@ public class ICalendarHandlerFactory extends BaseThingHandlerFactory {
|
||||
return null;
|
||||
}
|
||||
if (thingTypeUID.equals(THING_TYPE_CALENDAR)) {
|
||||
if (thing instanceof Bridge) {
|
||||
return new ICalendarHandler((Bridge) thing, sharedHttpClient, eventPublisher, tzProvider);
|
||||
if (thing instanceof Bridge bridge) {
|
||||
return new ICalendarHandler(bridge, sharedHttpClient, eventPublisher, tzProvider);
|
||||
} else {
|
||||
logger.warn(
|
||||
"The API of iCalendar has changed. You have to recreate the calendar according to the docs.");
|
||||
|
@ -232,18 +232,19 @@ public class EventFilterHandler extends BaseThingHandler implements CalendarUpda
|
||||
thingBuilder.withoutChannel(toDelete.getUID());
|
||||
});
|
||||
|
||||
resultChannels.stream().filter((ResultChannelSet current) -> {
|
||||
return (getThing().getChannelsOfGroup(current.resultGroup.toString()).size() == 0);
|
||||
}).forEach((ResultChannelSet current) -> {
|
||||
for (ChannelBuilder builder : handlerCallback.createChannelBuilders(current.resultGroup,
|
||||
GROUP_TYPE_UID)) {
|
||||
Channel currentChannel = builder.build();
|
||||
Channel existingChannel = getThing().getChannel(currentChannel.getUID());
|
||||
if (existingChannel == null) {
|
||||
thingBuilder.withChannel(currentChannel);
|
||||
}
|
||||
}
|
||||
});
|
||||
resultChannels
|
||||
.stream().filter((ResultChannelSet current) -> (getThing()
|
||||
.getChannelsOfGroup(current.resultGroup.toString()).isEmpty()))
|
||||
.forEach((ResultChannelSet current) -> {
|
||||
for (ChannelBuilder builder : handlerCallback.createChannelBuilders(current.resultGroup,
|
||||
GROUP_TYPE_UID)) {
|
||||
Channel currentChannel = builder.build();
|
||||
Channel existingChannel = getThing().getChannel(currentChannel.getUID());
|
||||
if (existingChannel == null) {
|
||||
thingBuilder.withChannel(currentChannel);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
updateThing(thingBuilder.build());
|
||||
}
|
||||
|
@ -451,10 +451,10 @@ public class ICalendarHandler extends BaseBridgeHandler implements CalendarUpdat
|
||||
* @param childHandler the handler to be updated
|
||||
*/
|
||||
private void updateChild(@Nullable ThingHandler childHandler) {
|
||||
if (childHandler instanceof CalendarUpdateListener) {
|
||||
if (childHandler instanceof CalendarUpdateListener updateListener) {
|
||||
logger.trace("Notifying {} about fresh calendar.", childHandler.getThing().getUID());
|
||||
try {
|
||||
((CalendarUpdateListener) childHandler).onCalendarUpdated();
|
||||
updateListener.onCalendarUpdated();
|
||||
} catch (Exception e) {
|
||||
logger.trace("The update of a child handler failed. Ignoring.", e);
|
||||
}
|
||||
|
@ -21,12 +21,12 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class EventTextFilter {
|
||||
public static enum Type {
|
||||
public enum Type {
|
||||
TEXT,
|
||||
REGEX
|
||||
}
|
||||
|
||||
public static enum Field {
|
||||
public enum Field {
|
||||
SUMMARY,
|
||||
DESCRIPTION,
|
||||
COMMENT,
|
||||
|
@ -89,8 +89,8 @@ public class ICloudHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
@Override
|
||||
protected void removeHandler(ThingHandler thingHandler) {
|
||||
if (thingHandler instanceof ICloudAccountBridgeHandler) {
|
||||
unregisterDeviceDiscoveryService((ICloudAccountBridgeHandler) thingHandler);
|
||||
if (thingHandler instanceof ICloudAccountBridgeHandler iCloudAccountBridgeHandler) {
|
||||
unregisterDeviceDiscoveryService(iCloudAccountBridgeHandler);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,16 +112,13 @@ public class ICloudAccountBridgeHandler extends BaseBridgeHandler {
|
||||
authState = AuthState.INITIAL;
|
||||
}
|
||||
|
||||
this.iCloudDeviceInformationCache = new ExpiringCache<>(CACHE_EXPIRY, () -> {
|
||||
return callApiWithRetryAndExceptionHandling(() -> {
|
||||
this.iCloudDeviceInformationCache = new ExpiringCache<>(CACHE_EXPIRY,
|
||||
() -> callApiWithRetryAndExceptionHandling(() ->
|
||||
// callApiWithRetryAndExceptionHanlding ensures that iCloudService is not null when the following is
|
||||
// called. Cannot use method local iCloudService instance here, because instance may be replaced with a
|
||||
// new
|
||||
// one during retry.
|
||||
return iCloudService.getDevices().refreshClient();
|
||||
});
|
||||
|
||||
});
|
||||
iCloudService.getDevices().refreshClient()));
|
||||
|
||||
updateStatus(ThingStatus.UNKNOWN);
|
||||
|
||||
|
@ -160,8 +160,8 @@ public class ICloudDeviceHandler extends BaseThingHandler implements ICloudDevic
|
||||
Bridge bridge = getBridge();
|
||||
if (bridge != null) {
|
||||
ThingHandler bridgeHandler = bridge.getHandler();
|
||||
if (bridgeHandler instanceof ICloudAccountBridgeHandler) {
|
||||
((ICloudAccountBridgeHandler) bridgeHandler).unregisterListener(this);
|
||||
if (bridgeHandler instanceof ICloudAccountBridgeHandler iCloudAccountBridgeHandler) {
|
||||
iCloudAccountBridgeHandler.unregisterListener(this);
|
||||
}
|
||||
}
|
||||
super.dispose();
|
||||
|
@ -74,8 +74,8 @@ public class TestICloud {
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
final Logger logger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
|
||||
if (logger instanceof ch.qos.logback.classic.Logger) {
|
||||
((ch.qos.logback.classic.Logger) logger).setLevel(ch.qos.logback.classic.Level.DEBUG);
|
||||
if (logger instanceof ch.qos.logback.classic.Logger qLogger) {
|
||||
qLogger.setLevel(ch.qos.logback.classic.Level.DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,7 +122,6 @@ public class TestICloud {
|
||||
@Test
|
||||
@EnabledIfSystemProperty(named = "icloud.test.email", matches = ".*", disabledReason = "Only for manual execution.")
|
||||
public void testDiscovery() {
|
||||
|
||||
String icloudDeviceRespond = """
|
||||
{
|
||||
"userInfo": {
|
||||
|
@ -411,8 +411,8 @@ public class IhcHandler extends BaseThingHandler implements IhcEventListener {
|
||||
}
|
||||
|
||||
private List<IhcEnumValue> getEnumValues(WSResourceValue value) {
|
||||
if (value instanceof WSEnumValue) {
|
||||
return enumDictionary.getEnumValues(((WSEnumValue) value).definitionTypeID);
|
||||
if (value instanceof WSEnumValue enumValue) {
|
||||
return enumDictionary.getEnumValues(enumValue.definitionTypeID);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -764,8 +764,8 @@ public class IhcHandler extends BaseThingHandler implements IhcEventListener {
|
||||
}
|
||||
|
||||
private void checkPotentialButtonPresses(WSResourceValue value) {
|
||||
if (value instanceof WSBooleanValue) {
|
||||
if (((WSBooleanValue) value).value) {
|
||||
if (value instanceof WSBooleanValue booleanValue) {
|
||||
if (booleanValue.value) {
|
||||
// potential button press
|
||||
lastUpdate.put(value.resourceID, LocalDateTime.now());
|
||||
updateTriggers(value.resourceID, Duration.ZERO);
|
||||
|
@ -96,8 +96,8 @@ public class PushButtonToCommandProfile implements TriggerProfile {
|
||||
long retval;
|
||||
Object paramValue = context.getConfiguration().get(param);
|
||||
logger.debug("Configuring profile with {} parameter '{}'", param, paramValue);
|
||||
if (paramValue instanceof BigDecimal) {
|
||||
retval = ((BigDecimal) paramValue).longValue();
|
||||
if (paramValue instanceof BigDecimal decimalParam) {
|
||||
retval = decimalParam.longValue();
|
||||
} else {
|
||||
logger.debug("Parameter '{}' is not of type BigDecimal, using default value '{}'", param, defValue);
|
||||
retval = defValue;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user