Java 17 features (T-Z) (#15576)
- add missing @override - Java style array syntax - remove redundant modifiers - always move String constants to left side in comparisons - simplify lambda expressions and return statements - use replace instead of replaceAll w/o regex - instanceof matching and multiline strings - remove null check before instanceof Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>pull/15640/head
parent
bf1aa3deb2
commit
1b122a53b9
|
@ -93,8 +93,7 @@ public final class AnalogMessage extends Message {
|
|||
public AnalogValue getAnalogValue(int portNumber) {
|
||||
// Get the internal index for portNumber within the message
|
||||
int idx = (portNumber - 1) % 4;
|
||||
AnalogValue value = new AnalogValue(this.getValue(idx), getMeasureType(idx));
|
||||
return value;
|
||||
return new AnalogValue(this.getValue(idx), getMeasureType(idx));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.openhab.core.types.State;
|
|||
@NonNullByDefault
|
||||
public class ApiPageEntry {
|
||||
|
||||
static enum Type {
|
||||
enum Type {
|
||||
READ_ONLY_SWITCH(true),
|
||||
READ_ONLY_NUMERIC(true),
|
||||
NUMERIC_FORM(false),
|
||||
|
|
|
@ -30,7 +30,7 @@ public class ChangerX2Entry {
|
|||
public static final String NUMBER_MAX = "max";
|
||||
public static final String NUMBER_STEP = "step";
|
||||
|
||||
static enum OptionType {
|
||||
enum OptionType {
|
||||
NUMBER,
|
||||
SELECT,
|
||||
}
|
||||
|
|
|
@ -73,12 +73,12 @@ public class CapabilitiesSupport {
|
|||
// iterate over all mode capability elements and build the superset of their inner capabilities
|
||||
allCapabilities.forEach(e -> {
|
||||
if (e != null) {
|
||||
light |= e.getLight() != null ? e.getLight().size() > 0 : false;
|
||||
swing |= e.getSwings() != null ? e.getSwings().size() > 0 : false;
|
||||
fanLevel |= e.getFanLevel() != null ? e.getFanLevel().size() > 0 : false;
|
||||
fanSpeed |= e.getFanSpeeds() != null ? e.getFanSpeeds().size() > 0 : false;
|
||||
verticalSwing |= e.getVerticalSwing() != null ? e.getVerticalSwing().size() > 0 : false;
|
||||
horizontalSwing |= e.getHorizontalSwing() != null ? e.getHorizontalSwing().size() > 0 : false;
|
||||
light |= e.getLight() != null ? !e.getLight().isEmpty() : false;
|
||||
swing |= e.getSwings() != null ? !e.getSwings().isEmpty() : false;
|
||||
fanLevel |= e.getFanLevel() != null ? !e.getFanLevel().isEmpty() : false;
|
||||
fanSpeed |= e.getFanSpeeds() != null ? !e.getFanSpeeds().isEmpty() : false;
|
||||
verticalSwing |= e.getVerticalSwing() != null ? !e.getVerticalSwing().isEmpty() : false;
|
||||
horizontalSwing |= e.getHorizontalSwing() != null ? !e.getHorizontalSwing().isEmpty() : false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class TadoBindingConstants {
|
|||
// List of all Channel IDs
|
||||
public static final String PROPERTY_HOME_TEMPERATURE_UNIT = "temperatureUnit";
|
||||
|
||||
public static enum TemperatureUnit {
|
||||
public enum TemperatureUnit {
|
||||
CELSIUS,
|
||||
FAHRENHEIT
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class TadoBindingConstants {
|
|||
|
||||
public static final String CHANNEL_ZONE_HVAC_MODE = "hvacMode";
|
||||
|
||||
public static enum HvacMode {
|
||||
public enum HvacMode {
|
||||
OFF,
|
||||
HEAT,
|
||||
COOL,
|
||||
|
@ -69,7 +69,7 @@ public class TadoBindingConstants {
|
|||
|
||||
public static final String CHANNEL_ZONE_FAN_SPEED = "fanspeed";
|
||||
|
||||
public static enum FanSpeed {
|
||||
public enum FanSpeed {
|
||||
LOW,
|
||||
MIDDLE,
|
||||
HIGH,
|
||||
|
@ -78,7 +78,7 @@ public class TadoBindingConstants {
|
|||
|
||||
public static final String CHANNEL_ZONE_FAN_LEVEL = "fanLevel";
|
||||
|
||||
public static enum FanLevel {
|
||||
public enum FanLevel {
|
||||
SILENT,
|
||||
LEVEL1,
|
||||
LEVEL2,
|
||||
|
@ -90,7 +90,7 @@ public class TadoBindingConstants {
|
|||
|
||||
public static final String CHANNEL_ZONE_HORIZONTAL_SWING = "horizontalSwing";
|
||||
|
||||
public static enum HorizontalSwing {
|
||||
public enum HorizontalSwing {
|
||||
OFF,
|
||||
ON,
|
||||
LEFT,
|
||||
|
@ -103,7 +103,7 @@ public class TadoBindingConstants {
|
|||
|
||||
public static final String CHANNEL_ZONE_VERTICAL_SWING = "verticalSwing";
|
||||
|
||||
public static enum VerticalSwing {
|
||||
public enum VerticalSwing {
|
||||
OFF,
|
||||
ON,
|
||||
UP,
|
||||
|
@ -116,7 +116,7 @@ public class TadoBindingConstants {
|
|||
|
||||
public static final String CHANNEL_ZONE_OPERATION_MODE = "operationMode";
|
||||
|
||||
public static enum OperationMode {
|
||||
public enum OperationMode {
|
||||
SCHEDULE,
|
||||
TIMER,
|
||||
MANUAL,
|
||||
|
@ -141,7 +141,7 @@ public class TadoBindingConstants {
|
|||
public static final String PROPERTY_ZONE_NAME = "name";
|
||||
public static final String PROPERTY_ZONE_TYPE = "type";
|
||||
|
||||
public static enum ZoneType {
|
||||
public enum ZoneType {
|
||||
HEATING,
|
||||
AIR_CONDITIONING,
|
||||
HOT_WATER
|
||||
|
|
|
@ -221,7 +221,7 @@ public class TadoZoneStateAdapter {
|
|||
break;
|
||||
}
|
||||
|
||||
return power.getValue().equals("ON");
|
||||
return "ON".equals(power.getValue());
|
||||
}
|
||||
|
||||
private static DecimalType toDecimalType(double value) {
|
||||
|
|
|
@ -226,8 +226,8 @@ public class TadoApiTypeUtils {
|
|||
@Nullable GenericZoneCapabilities capabilities) {
|
||||
AirConditioningCapabilities acCapabilities;
|
||||
|
||||
if (capabilities instanceof AirConditioningCapabilities) {
|
||||
acCapabilities = (AirConditioningCapabilities) capabilities;
|
||||
if (capabilities instanceof AirConditioningCapabilities conditioningCapabilities) {
|
||||
acCapabilities = conditioningCapabilities;
|
||||
} else {
|
||||
acCapabilities = new AirConditioningCapabilities();
|
||||
}
|
||||
|
|
|
@ -84,8 +84,7 @@ public class TerminationConditionBuilder {
|
|||
}
|
||||
|
||||
private OverlayTerminationCondition getDefaultTerminationCondition() throws IOException, ApiException {
|
||||
OverlayTerminationCondition defaultTerminationCondition = zoneHandler.getDefaultTerminationCondition();
|
||||
return defaultTerminationCondition;
|
||||
return zoneHandler.getDefaultTerminationCondition();
|
||||
}
|
||||
|
||||
private TimerTerminationCondition getCurrentOrDefaultTimerTermination(ZoneStateProvider zoneStateProvider)
|
||||
|
|
|
@ -14,10 +14,7 @@ package org.openhab.binding.tado.internal.handler;
|
|||
|
||||
import static org.openhab.binding.tado.internal.TadoBindingConstants.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -48,8 +45,8 @@ import org.osgi.service.component.annotations.Reference;
|
|||
@Component(configurationPid = "binding.tado", service = ThingHandlerFactory.class)
|
||||
public class TadoHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
|
||||
.unmodifiableSet(new HashSet<>(Arrays.asList(THING_TYPE_HOME, THING_TYPE_ZONE, THING_TYPE_MOBILE_DEVICE)));
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_HOME, THING_TYPE_ZONE,
|
||||
THING_TYPE_MOBILE_DEVICE);
|
||||
|
||||
private final Map<ThingUID, ServiceRegistration<?>> discoveryServiceRegs = new HashMap<>();
|
||||
|
||||
|
|
|
@ -179,8 +179,8 @@ public class TadoHomeHandler extends BaseBridgeHandler {
|
|||
switch (id) {
|
||||
case TadoBindingConstants.CHANNEL_HOME_PRESENCE_MODE:
|
||||
HomePresence presence = new HomePresence();
|
||||
presence.setHomePresence(command.toFullString().toUpperCase().equals("ON")
|
||||
|| command.toFullString().toUpperCase().equals("HOME") ? PresenceState.HOME
|
||||
presence.setHomePresence("ON".equals(command.toFullString().toUpperCase())
|
||||
|| "HOME".equals(command.toFullString().toUpperCase()) ? PresenceState.HOME
|
||||
: PresenceState.AWAY);
|
||||
try {
|
||||
api.updatePresenceLock(homeId, presence);
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
*/
|
||||
package org.openhab.binding.tankerkoenig.internal;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
|
@ -33,8 +32,8 @@ public class TankerkoenigBindingConstants {
|
|||
public static final ThingTypeUID THING_TYPE_TANKSTELLE = new ThingTypeUID(BINDING_ID, "station");
|
||||
public static final ThingTypeUID BRIDGE_THING_TYPE = new ThingTypeUID(BINDING_ID, "webservice");
|
||||
|
||||
public static final Set<ThingTypeUID> BRIDGE_THING_TYPES_UIDS = Collections.singleton(BRIDGE_THING_TYPE);
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_TANKSTELLE);
|
||||
public static final Set<ThingTypeUID> BRIDGE_THING_TYPES_UIDS = Set.of(BRIDGE_THING_TYPE);
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_TANKSTELLE);
|
||||
|
||||
// List of all Channel ids
|
||||
public static final String CHANNEL_DIESEL = "diesel";
|
||||
|
|
|
@ -53,8 +53,7 @@ public class TankerkoenigHandlerFactory extends BaseThingHandlerFactory {
|
|||
protected @Nullable ThingHandler createHandler(Thing thing) {
|
||||
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
|
||||
if (thingTypeUID.equals(BRIDGE_THING_TYPE)) {
|
||||
WebserviceHandler handler = new WebserviceHandler((Bridge) thing);
|
||||
return handler;
|
||||
return new WebserviceHandler((Bridge) thing);
|
||||
} else if (thingTypeUID.equals(THING_TYPE_TANKSTELLE)) {
|
||||
return new StationHandler(thing);
|
||||
}
|
||||
|
|
|
@ -84,8 +84,7 @@ public class TapoDiscoveryService extends AbstractDiscoveryService implements Th
|
|||
|
||||
@Override
|
||||
public void setThingHandler(@Nullable ThingHandler handler) {
|
||||
if (handler instanceof TapoBridgeHandler) {
|
||||
TapoBridgeHandler tapoBridge = (TapoBridgeHandler) handler;
|
||||
if (handler instanceof TapoBridgeHandler tapoBridge) {
|
||||
tapoBridge.setDiscoveryService(this);
|
||||
this.bridge = tapoBridge;
|
||||
}
|
||||
|
|
|
@ -222,8 +222,7 @@ public class TapoCloudConnector {
|
|||
httpRequest.content(new StringContentProvider(payload, CONTENT_CHARSET), CONTENT_TYPE_JSON);
|
||||
|
||||
try {
|
||||
ContentResponse httpResponse = httpRequest.send();
|
||||
return httpResponse;
|
||||
return httpRequest.send();
|
||||
} catch (InterruptedException e) {
|
||||
logger.debug("({}) sending request interrupted: {}", uid, e.toString());
|
||||
handleError(new TapoErrorHandler(e));
|
||||
|
|
|
@ -158,7 +158,7 @@ public class TapoDeviceHttpApi {
|
|||
String payload = plBuilder.getPayload();
|
||||
|
||||
/* send request (create ) */
|
||||
logger.trace("({}) create handhsake with payload: {}", uid, payload.toString());
|
||||
logger.trace("({}) create handhsake with payload: {}", uid, payload);
|
||||
ContentResponse response = sendRequest(this.deviceURL, payload);
|
||||
if (response != null && getErrorCode(response) == 0) {
|
||||
String encryptedKey = getKeyFromResponse(response);
|
||||
|
@ -308,8 +308,7 @@ public class TapoDeviceHttpApi {
|
|||
httpRequest.content(new StringContentProvider(payload, CONTENT_CHARSET), CONTENT_TYPE_JSON);
|
||||
|
||||
try {
|
||||
ContentResponse httpResponse = httpRequest.send();
|
||||
return httpResponse;
|
||||
return httpRequest.send();
|
||||
} catch (InterruptedException e) {
|
||||
logger.debug("({}) sending request interrupted: {}", uid, e.toString());
|
||||
handleError(new TapoErrorHandler(e));
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
package org.openhab.binding.tapocontrol.internal.device;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -114,7 +114,7 @@ public class TapoBridgeHandler extends BaseBridgeHandler {
|
|||
*/
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(TapoDiscoveryService.class);
|
||||
return Set.of(TapoDiscoveryService.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -140,7 +140,7 @@ public abstract class TapoDevice extends BaseThingHandler {
|
|||
TapoErrorHandler configErr = new TapoErrorHandler();
|
||||
|
||||
/* check bridge */
|
||||
if (bridge == null || !(bridge instanceof TapoBridgeHandler)) {
|
||||
if (!(bridge instanceof TapoBridgeHandler)) {
|
||||
configErr.raiseError(ERR_CONFIG_NO_BRIDGE);
|
||||
return configErr;
|
||||
}
|
||||
|
|
|
@ -76,24 +76,24 @@ public class TapoLightStrip extends TapoDevice {
|
|||
refreshInfo = true;
|
||||
break;
|
||||
case CHANNEL_BRIGHTNESS:
|
||||
if (command instanceof PercentType) {
|
||||
Float percent = ((PercentType) command).floatValue();
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
Float percent = percentCommand.floatValue();
|
||||
setBrightness(percent.intValue()); // 0..100% = 0..100
|
||||
refreshInfo = true;
|
||||
} else if (command instanceof DecimalType) {
|
||||
setBrightness(((DecimalType) command).intValue());
|
||||
} else if (command instanceof DecimalType decimalCommand) {
|
||||
setBrightness(decimalCommand.intValue());
|
||||
refreshInfo = true;
|
||||
}
|
||||
break;
|
||||
case CHANNEL_COLOR_TEMP:
|
||||
if (command instanceof DecimalType) {
|
||||
setColorTemp(((DecimalType) command).intValue());
|
||||
if (command instanceof DecimalType decimalCommand) {
|
||||
setColorTemp(decimalCommand.intValue());
|
||||
refreshInfo = true;
|
||||
}
|
||||
break;
|
||||
case CHANNEL_COLOR:
|
||||
if (command instanceof HSBType) {
|
||||
setColor((HSBType) command);
|
||||
if (command instanceof HSBType hsbCommand) {
|
||||
setColor(hsbCommand);
|
||||
refreshInfo = true;
|
||||
}
|
||||
break;
|
||||
|
@ -163,11 +163,11 @@ public class TapoLightStrip extends TapoDevice {
|
|||
TapoLightEffect lightEffect = deviceInfo.getLightEffect();
|
||||
switch (channel) {
|
||||
case CHANNEL_FX_BRIGHTNESS:
|
||||
if (command instanceof PercentType) {
|
||||
Float percent = ((PercentType) command).floatValue();
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
Float percent = percentCommand.floatValue();
|
||||
lightEffect.setBrightness(percent.intValue()); // 0..100% = 0..100
|
||||
} else if (command instanceof DecimalType) {
|
||||
lightEffect.setBrightness(((DecimalType) command).intValue());
|
||||
} else if (command instanceof DecimalType decimalCommand) {
|
||||
lightEffect.setBrightness(decimalCommand.intValue());
|
||||
}
|
||||
break;
|
||||
case CHANNEL_FX_COLORS:
|
||||
|
|
|
@ -71,24 +71,24 @@ public class TapoSmartBulb extends TapoDevice {
|
|||
refreshInfo = true;
|
||||
break;
|
||||
case CHANNEL_BRIGHTNESS:
|
||||
if (command instanceof PercentType) {
|
||||
Float percent = ((PercentType) command).floatValue();
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
Float percent = percentCommand.floatValue();
|
||||
setBrightness(percent.intValue()); // 0..100% = 0..100
|
||||
refreshInfo = true;
|
||||
} else if (command instanceof DecimalType) {
|
||||
setBrightness(((DecimalType) command).intValue());
|
||||
} else if (command instanceof DecimalType decimalCommand) {
|
||||
setBrightness(decimalCommand.intValue());
|
||||
refreshInfo = true;
|
||||
}
|
||||
break;
|
||||
case CHANNEL_COLOR_TEMP:
|
||||
if (command instanceof DecimalType) {
|
||||
setColorTemp(((DecimalType) command).intValue());
|
||||
if (command instanceof DecimalType decimalCommand) {
|
||||
setColorTemp(decimalCommand.intValue());
|
||||
refreshInfo = true;
|
||||
}
|
||||
break;
|
||||
case CHANNEL_COLOR:
|
||||
if (command instanceof HSBType) {
|
||||
setColor((HSBType) command);
|
||||
if (command instanceof HSBType hsbCommand) {
|
||||
setColor(hsbCommand);
|
||||
refreshInfo = true;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -70,24 +70,24 @@ public class TapoUniversalDevice extends TapoDevice {
|
|||
refreshInfo = true;
|
||||
break;
|
||||
case CHANNEL_BRIGHTNESS:
|
||||
if (command instanceof PercentType) {
|
||||
Float percent = ((PercentType) command).floatValue();
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
Float percent = percentCommand.floatValue();
|
||||
setBrightness(percent.intValue()); // 0..100% = 0..100
|
||||
refreshInfo = true;
|
||||
} else if (command instanceof DecimalType) {
|
||||
setBrightness(((DecimalType) command).intValue());
|
||||
} else if (command instanceof DecimalType decimalCommand) {
|
||||
setBrightness(decimalCommand.intValue());
|
||||
refreshInfo = true;
|
||||
}
|
||||
break;
|
||||
case CHANNEL_COLOR_TEMP:
|
||||
if (command instanceof DecimalType) {
|
||||
setColorTemp(((DecimalType) command).intValue());
|
||||
if (command instanceof DecimalType decimalCommand) {
|
||||
setColorTemp(decimalCommand.intValue());
|
||||
refreshInfo = true;
|
||||
}
|
||||
break;
|
||||
case CHANNEL_COLOR:
|
||||
if (command instanceof HSBType) {
|
||||
setColor((HSBType) command);
|
||||
if (command instanceof HSBType hsbCommand) {
|
||||
setColor(hsbCommand);
|
||||
refreshInfo = true;
|
||||
}
|
||||
break;
|
||||
|
@ -173,6 +173,7 @@ public class TapoUniversalDevice extends TapoDevice {
|
|||
*
|
||||
* @param responseBody
|
||||
*/
|
||||
@Override
|
||||
public void responsePasstrough(String responseBody) {
|
||||
logger.debug("({}) received response {}", uid, responseBody);
|
||||
publishState(getChannelID(CHANNEL_GROUP_DEBUG, CHANNEL_RESPONSE), getStringType(responseBody));
|
||||
|
@ -224,6 +225,7 @@ public class TapoUniversalDevice extends TapoDevice {
|
|||
* @param channelID String channelID
|
||||
* @return String channel-name
|
||||
*/
|
||||
@Override
|
||||
protected String getChannelFromID(ChannelUID channelID) {
|
||||
String channel = channelID.getIdWithoutGroup();
|
||||
channel = channel.replace(CHANNEL_GROUP_ACTUATOR + "#", "");
|
||||
|
|
|
@ -44,10 +44,10 @@ public class PayloadBuilder {
|
|||
* @param value parameter value (typeOf Bool,Number or String)
|
||||
*/
|
||||
public void addParameter(String name, Object value) {
|
||||
if (value instanceof Boolean) {
|
||||
this.parameters.addProperty(name, (Boolean) value);
|
||||
} else if (value instanceof Number) {
|
||||
this.parameters.addProperty(name, (Number) value);
|
||||
if (value instanceof Boolean bool) {
|
||||
this.parameters.addProperty(name, bool);
|
||||
} else if (value instanceof Number number) {
|
||||
this.parameters.addProperty(name, number);
|
||||
} else {
|
||||
this.parameters.addProperty(name, value.toString());
|
||||
}
|
||||
|
|
|
@ -82,8 +82,7 @@ public class TapoUtils {
|
|||
*/
|
||||
public static String formatMac(String mac, char newDivisionChar) {
|
||||
String unformatedMac = unformatMac(mac);
|
||||
String formatedMac = unformatedMac.replaceAll("(.{2})", "$1" + newDivisionChar).substring(0, 17);
|
||||
return formatedMac;
|
||||
return unformatedMac.replaceAll("(.{2})", "$1" + newDivisionChar).substring(0, 17);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,7 +34,7 @@ public class TapoLightEffect {
|
|||
private Boolean custom = false;
|
||||
private Integer brightness = 0;
|
||||
private Integer[] colorTempRange = { 9000, 9000 }; // :[9000,9000]
|
||||
private Color displayColors[] = { Color.WHITE };
|
||||
private Color[] displayColors = { Color.WHITE };
|
||||
|
||||
private JsonObject jsonObject = new JsonObject();
|
||||
|
||||
|
|
|
@ -84,8 +84,7 @@ public class TapoDiscoveryService extends AbstractDiscoveryService implements Th
|
|||
|
||||
@Override
|
||||
public void setThingHandler(@Nullable ThingHandler handler) {
|
||||
if (handler instanceof TapoBridgeHandler) {
|
||||
TapoBridgeHandler tapoBridge = (TapoBridgeHandler) handler;
|
||||
if (handler instanceof TapoBridgeHandler tapoBridge) {
|
||||
tapoBridge.setDiscoveryService(this);
|
||||
this.bridge = tapoBridge;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
package org.openhab.binding.tapocontrol.internal.device;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class TapoBridgeHandler extends BaseBridgeHandler {
|
|||
*/
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(TapoDiscoveryService.class);
|
||||
return Set.of(TapoDiscoveryService.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -70,24 +70,24 @@ public class TapoUniversalDevice extends TapoDevice {
|
|||
refreshInfo = true;
|
||||
break;
|
||||
case CHANNEL_BRIGHTNESS:
|
||||
if (command instanceof PercentType) {
|
||||
Float percent = ((PercentType) command).floatValue();
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
Float percent = percentCommand.floatValue();
|
||||
setBrightness(percent.intValue()); // 0..100% = 0..100
|
||||
refreshInfo = true;
|
||||
} else if (command instanceof DecimalType) {
|
||||
setBrightness(((DecimalType) command).intValue());
|
||||
} else if (command instanceof DecimalType decimalCommand) {
|
||||
setBrightness(decimalCommand.intValue());
|
||||
refreshInfo = true;
|
||||
}
|
||||
break;
|
||||
case CHANNEL_COLOR_TEMP:
|
||||
if (command instanceof DecimalType) {
|
||||
setColorTemp(((DecimalType) command).intValue());
|
||||
if (command instanceof DecimalType decimalCommand) {
|
||||
setColorTemp(decimalCommand.intValue());
|
||||
refreshInfo = true;
|
||||
}
|
||||
break;
|
||||
case CHANNEL_COLOR:
|
||||
if (command instanceof HSBType) {
|
||||
setColor((HSBType) command);
|
||||
if (command instanceof HSBType hsbCommand) {
|
||||
setColor(hsbCommand);
|
||||
refreshInfo = true;
|
||||
}
|
||||
break;
|
||||
|
@ -173,6 +173,7 @@ public class TapoUniversalDevice extends TapoDevice {
|
|||
*
|
||||
* @param responseBody
|
||||
*/
|
||||
@Override
|
||||
public void responsePasstrough(String responseBody) {
|
||||
logger.info("({}) received response {}", uid, responseBody);
|
||||
publishState(getChannelID(CHANNEL_GROUP_DEBUG, CHANNEL_RESPONSE), getStringType(responseBody));
|
||||
|
@ -224,6 +225,7 @@ public class TapoUniversalDevice extends TapoDevice {
|
|||
* @param channelID String channelID
|
||||
* @return String channel-name
|
||||
*/
|
||||
@Override
|
||||
protected String getChannelFromID(ChannelUID channelID) {
|
||||
String channel = channelID.getIdWithoutGroup();
|
||||
channel = channel.replace(CHANNEL_GROUP_ACTUATOR + "#", "");
|
||||
|
|
|
@ -34,7 +34,7 @@ public class TapoLightEffect {
|
|||
private Integer custom = 0;
|
||||
private Integer brightness = 0;
|
||||
private Integer[] colorTempRange = { 9000, 9000 }; // :[9000,9000]
|
||||
private Color displayColors[] = { Color.WHITE };
|
||||
private Color[] displayColors = { Color.WHITE };
|
||||
|
||||
private JsonObject jsonObject = new JsonObject();
|
||||
|
||||
|
|
|
@ -22,12 +22,12 @@ import java.time.ZonedDateTime;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -473,7 +473,7 @@ public class TelegramHandler extends BaseThingHandler {
|
|||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(TelegramActions.class);
|
||||
return Set.of(TelegramActions.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,7 +14,6 @@ package org.openhab.binding.telegram.internal;
|
|||
|
||||
import static org.openhab.binding.telegram.internal.TelegramBindingConstants.TELEGRAM_THING;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
|
@ -40,7 +39,7 @@ import org.osgi.service.component.annotations.Reference;
|
|||
@Component(configurationPid = "binding.telegram", service = ThingHandlerFactory.class)
|
||||
public class TelegramHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(TELEGRAM_THING);
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(TELEGRAM_THING);
|
||||
|
||||
private final HttpClient httpClient;
|
||||
|
||||
|
|
|
@ -672,11 +672,11 @@ public class TelegramActions implements ThingActions {
|
|||
|
||||
public static boolean sendTelegramAnswer(ThingActions actions, @Nullable String chatId, @Nullable String replyId,
|
||||
@Nullable String message) {
|
||||
if (actions instanceof TelegramActions) {
|
||||
if (actions instanceof TelegramActions telegramActions) {
|
||||
if (chatId == null) {
|
||||
return false;
|
||||
}
|
||||
return ((TelegramActions) actions).sendTelegramAnswer(Long.valueOf(chatId), replyId, message);
|
||||
return telegramActions.sendTelegramAnswer(Long.valueOf(chatId), replyId, message);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Actions is not an instance of TelegramActions");
|
||||
}
|
||||
|
@ -689,11 +689,11 @@ public class TelegramActions implements ThingActions {
|
|||
|
||||
public static boolean sendTelegramAnswer(ThingActions actions, @Nullable String chatId, @Nullable String callbackId,
|
||||
@Nullable String messageId, @Nullable String message) {
|
||||
if (actions instanceof TelegramActions) {
|
||||
if (actions instanceof TelegramActions telegramActions) {
|
||||
if (chatId == null) {
|
||||
return false;
|
||||
}
|
||||
return ((TelegramActions) actions).sendTelegramAnswer(Long.valueOf(chatId), callbackId,
|
||||
return telegramActions.sendTelegramAnswer(Long.valueOf(chatId), callbackId,
|
||||
messageId != null ? Long.parseLong(messageId) : null, message);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Actions is not an instance of TelegramActions");
|
||||
|
|
|
@ -187,8 +187,8 @@ public class TeleinfoDiscoveryService extends AbstractDiscoveryService
|
|||
|
||||
@Override
|
||||
public void setThingHandler(@Nullable ThingHandler handler) {
|
||||
if (handler instanceof TeleinfoAbstractControllerHandler) {
|
||||
controllerHandler = (TeleinfoAbstractControllerHandler) handler;
|
||||
if (handler instanceof TeleinfoAbstractControllerHandler teleinfoAbstractControllerHandler) {
|
||||
controllerHandler = teleinfoAbstractControllerHandler;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
package org.openhab.binding.teleinfo.internal.handler;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
|
@ -52,6 +51,6 @@ public abstract class TeleinfoAbstractControllerHandler extends BaseBridgeHandle
|
|||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(TeleinfoDiscoveryService.class);
|
||||
return Set.of(TeleinfoDiscoveryService.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,8 +120,8 @@ public class TellstickHandlerFactory extends BaseThingHandlerFactory {
|
|||
|
||||
@Override
|
||||
protected void removeHandler(ThingHandler thingHandler) {
|
||||
if (thingHandler instanceof TelldusBridgeHandler) {
|
||||
unregisterDeviceDiscoveryService((TelldusBridgeHandler) thingHandler);
|
||||
if (thingHandler instanceof TelldusBridgeHandler telldusBridgeHandler) {
|
||||
unregisterDeviceDiscoveryService(telldusBridgeHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,10 +156,10 @@ public class TelldusCoreDeviceController implements DeviceChangeListener, Sensor
|
|||
turnOn(device);
|
||||
} else if (command == OnOffType.OFF) {
|
||||
turnOff(device);
|
||||
} else if (command instanceof PercentType) {
|
||||
dim(device, (PercentType) command);
|
||||
} else if (command instanceof IncreaseDecreaseType) {
|
||||
increaseDecrease(device, ((IncreaseDecreaseType) command));
|
||||
} else if (command instanceof PercentType percentCommand) {
|
||||
dim(device, percentCommand);
|
||||
} else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
|
||||
increaseDecrease(device, increaseDecreaseCommand);
|
||||
}
|
||||
} else if (device instanceof SwitchableDevice) {
|
||||
if (command == OnOffType.ON) {
|
||||
|
@ -198,29 +198,29 @@ public class TelldusCoreDeviceController implements DeviceChangeListener, Sensor
|
|||
double value = command.doubleValue();
|
||||
|
||||
// 0 means OFF and 100 means ON
|
||||
if (value == 0 && dev instanceof SwitchableDevice) {
|
||||
((SwitchableDevice) dev).off();
|
||||
} else if (value == 100 && dev instanceof SwitchableDevice) {
|
||||
((SwitchableDevice) dev).on();
|
||||
} else if (dev instanceof DimmableDevice) {
|
||||
if (value == 0 && dev instanceof SwitchableDevice device) {
|
||||
device.off();
|
||||
} else if (value == 100 && dev instanceof SwitchableDevice device) {
|
||||
device.on();
|
||||
} else if (dev instanceof DimmableDevice device) {
|
||||
long tdVal = Math.round((value / 100) * 255);
|
||||
((DimmableDevice) dev).dim((int) tdVal);
|
||||
device.dim((int) tdVal);
|
||||
} else {
|
||||
throw new TelldusBindingException("Cannot send DIM to " + dev);
|
||||
}
|
||||
}
|
||||
|
||||
private void turnOff(Device dev) throws TellstickException {
|
||||
if (dev instanceof SwitchableDevice) {
|
||||
((SwitchableDevice) dev).off();
|
||||
if (dev instanceof SwitchableDevice device) {
|
||||
device.off();
|
||||
} else {
|
||||
throw new TelldusBindingException("Cannot send OFF to " + dev);
|
||||
}
|
||||
}
|
||||
|
||||
private void turnOn(Device dev) throws TellstickException {
|
||||
if (dev instanceof SwitchableDevice) {
|
||||
((SwitchableDevice) dev).on();
|
||||
if (dev instanceof SwitchableDevice device) {
|
||||
device.on();
|
||||
} else {
|
||||
throw new TelldusBindingException("Cannot send ON to " + dev);
|
||||
}
|
||||
|
|
|
@ -135,16 +135,16 @@ public class TellstickDiscoveryService extends AbstractDiscoveryService implemen
|
|||
} else if (device instanceof SwitchableDevice) {
|
||||
thingUID = new ThingUID(TellstickBindingConstants.SWITCH_THING_TYPE, bridge.getUID(),
|
||||
device.getUUId());
|
||||
} else if (device instanceof TellstickNetDevice) {
|
||||
if ((((TellstickNetDevice) device).getMethods() & JNA.CLibrary.TELLSTICK_DIM) > 0) {
|
||||
} else if (device instanceof TellstickNetDevice netDevice) {
|
||||
if ((netDevice.getMethods() & JNA.CLibrary.TELLSTICK_DIM) > 0) {
|
||||
thingUID = new ThingUID(TellstickBindingConstants.DIMMER_THING_TYPE, bridge.getUID(),
|
||||
device.getUUId());
|
||||
} else {
|
||||
thingUID = new ThingUID(TellstickBindingConstants.SWITCH_THING_TYPE, bridge.getUID(),
|
||||
device.getUUId());
|
||||
}
|
||||
} else if (device instanceof TellstickLocalDeviceDTO) {
|
||||
if ((((TellstickLocalDeviceDTO) device).getMethods() & JNA.CLibrary.TELLSTICK_DIM) > 0) {
|
||||
} else if (device instanceof TellstickLocalDeviceDTO localDevice) {
|
||||
if ((localDevice.getMethods() & JNA.CLibrary.TELLSTICK_DIM) > 0) {
|
||||
thingUID = new ThingUID(TellstickBindingConstants.DIMMER_THING_TYPE, bridge.getUID(),
|
||||
device.getUUId());
|
||||
} else {
|
||||
|
@ -162,8 +162,7 @@ public class TellstickDiscoveryService extends AbstractDiscoveryService implemen
|
|||
private ThingTypeUID findSensorType(Device device) {
|
||||
logger.debug("Device: {}", device);
|
||||
ThingTypeUID sensorThingId;
|
||||
if (device instanceof TellstickSensor) {
|
||||
TellstickSensor sensor = (TellstickSensor) device;
|
||||
if (device instanceof TellstickSensor sensor) {
|
||||
logger.debug("Sensor: {}", device);
|
||||
if (sensor.getData(DataType.WINDAVERAGE) != null || sensor.getData(DataType.WINDGUST) != null
|
||||
|| sensor.getData(DataType.WINDDIRECTION) != null) {
|
||||
|
@ -173,8 +172,7 @@ public class TellstickDiscoveryService extends AbstractDiscoveryService implemen
|
|||
} else {
|
||||
sensorThingId = TellstickBindingConstants.SENSOR_THING_TYPE;
|
||||
}
|
||||
} else if (device instanceof TellstickNetSensor) {
|
||||
TellstickNetSensor sensor = (TellstickNetSensor) device;
|
||||
} else if (device instanceof TellstickNetSensor sensor) {
|
||||
if (sensor.isSensorOfType(LiveDataType.WINDAVERAGE) || sensor.isSensorOfType(LiveDataType.WINDDIRECTION)
|
||||
|| sensor.isSensorOfType(LiveDataType.WINDGUST)) {
|
||||
sensorThingId = TellstickBindingConstants.WINDSENSOR_THING_TYPE;
|
||||
|
|
|
@ -241,29 +241,29 @@ public class TelldusDevicesHandler extends BaseThingHandler implements DeviceSta
|
|||
}
|
||||
|
||||
private boolean isSensor() {
|
||||
return (getThing().getThingTypeUID().equals(TellstickBindingConstants.SENSOR_THING_TYPE)
|
||||
return getThing().getThingTypeUID().equals(TellstickBindingConstants.SENSOR_THING_TYPE)
|
||||
|| getThing().getThingTypeUID().equals(TellstickBindingConstants.RAINSENSOR_THING_TYPE)
|
||||
|| getThing().getThingTypeUID().equals(TellstickBindingConstants.WINDSENSOR_THING_TYPE)
|
||||
|| getThing().getThingTypeUID().equals(TellstickBindingConstants.POWERSENSOR_THING_TYPE));
|
||||
|| getThing().getThingTypeUID().equals(TellstickBindingConstants.POWERSENSOR_THING_TYPE);
|
||||
}
|
||||
|
||||
private void updateSensorStates(Device dev) {
|
||||
if (dev instanceof TellstickSensor) {
|
||||
if (dev instanceof TellstickSensor sensor) {
|
||||
updateStatus(ThingStatus.ONLINE);
|
||||
for (DataType type : ((TellstickSensor) dev).getData().keySet()) {
|
||||
updateSensorDataState(type, ((TellstickSensor) dev).getData(type));
|
||||
for (DataType type : sensor.getData().keySet()) {
|
||||
updateSensorDataState(type, sensor.getData(type));
|
||||
}
|
||||
} else if (dev instanceof TellstickNetSensor) {
|
||||
if (((TellstickNetSensor) dev).getOnline()) {
|
||||
} else if (dev instanceof TellstickNetSensor netSensor) {
|
||||
if (netSensor.getOnline()) {
|
||||
updateStatus(ThingStatus.ONLINE);
|
||||
} else {
|
||||
updateStatus(ThingStatus.OFFLINE);
|
||||
}
|
||||
for (DataTypeValue type : ((TellstickNetSensor) dev).getData()) {
|
||||
for (DataTypeValue type : netSensor.getData()) {
|
||||
updateSensorDataState(type);
|
||||
}
|
||||
} else if (dev instanceof TellstickLocalSensorDTO) {
|
||||
for (LocalDataTypeValueDTO type : ((TellstickLocalSensorDTO) dev).getData()) {
|
||||
} else if (dev instanceof TellstickLocalSensorDTO localSensor) {
|
||||
for (LocalDataTypeValueDTO type : localSensor.getData()) {
|
||||
updateSensorDataState(type);
|
||||
}
|
||||
}
|
||||
|
@ -283,14 +283,11 @@ public class TelldusDevicesHandler extends BaseThingHandler implements DeviceSta
|
|||
if (device.getUUId().equals(deviceId)) {
|
||||
if (event instanceof TellstickDeviceEvent) {
|
||||
updateDeviceState(device);
|
||||
} else if (event instanceof TellstickNetSensorEvent) {
|
||||
TellstickNetSensorEvent sensorevent = (TellstickNetSensorEvent) event;
|
||||
} else if (event instanceof TellstickNetSensorEvent sensorevent) {
|
||||
updateSensorDataState(sensorevent.getDataTypeValue());
|
||||
} else if (event instanceof TellstickLocalSensorEventDTO) {
|
||||
TellstickLocalSensorEventDTO sensorevent = (TellstickLocalSensorEventDTO) event;
|
||||
} else if (event instanceof TellstickLocalSensorEventDTO sensorevent) {
|
||||
updateSensorDataState(sensorevent.getDataTypeValue());
|
||||
} else if (event instanceof TellstickSensorEvent) {
|
||||
TellstickSensorEvent sensorevent = (TellstickSensorEvent) event;
|
||||
} else if (event instanceof TellstickSensorEvent sensorevent) {
|
||||
updateSensorDataState(sensorevent.getDataType(), sensorevent.getData());
|
||||
} else {
|
||||
logger.debug("Unhandled Device {}.", device.getDeviceType());
|
||||
|
@ -356,7 +353,7 @@ public class TelldusDevicesHandler extends BaseThingHandler implements DeviceSta
|
|||
new QuantityType<>(new BigDecimal(dataType.getValue()), WIND_SPEED_UNIT_MS));
|
||||
break;
|
||||
case WATT:
|
||||
if (dataType.getUnit() != null && dataType.getUnit().equals("A")) {
|
||||
if ("A".equals(dataType.getUnit())) {
|
||||
updateState(ampereChannel, new QuantityType<>(new BigDecimal(dataType.getValue()), ELECTRIC_UNIT));
|
||||
} else {
|
||||
updateState(wattChannel, new QuantityType<>(new BigDecimal(dataType.getValue()), POWER_UNIT));
|
||||
|
|
|
@ -129,10 +129,10 @@ public class TelldusLiveDeviceController implements DeviceChangeListener, Sensor
|
|||
turnOn(device);
|
||||
} else if (command == OnOffType.OFF) {
|
||||
turnOff(device);
|
||||
} else if (command instanceof PercentType) {
|
||||
dim(device, (PercentType) command);
|
||||
} else if (command instanceof IncreaseDecreaseType) {
|
||||
increaseDecrease(device, ((IncreaseDecreaseType) command));
|
||||
} else if (command instanceof PercentType percentCommand) {
|
||||
dim(device, percentCommand);
|
||||
} else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
|
||||
increaseDecrease(device, increaseDecreaseCommand);
|
||||
}
|
||||
} else if (device instanceof SwitchableDevice) {
|
||||
if (command == OnOffType.ON) {
|
||||
|
@ -172,22 +172,21 @@ public class TelldusLiveDeviceController implements DeviceChangeListener, Sensor
|
|||
turnOff(dev);
|
||||
} else if (value == 100 && dev instanceof TellstickNetDevice) {
|
||||
turnOn(dev);
|
||||
} else if (dev instanceof TellstickNetDevice
|
||||
&& (((TellstickNetDevice) dev).getMethods() & JNA.CLibrary.TELLSTICK_DIM) > 0) {
|
||||
} else if (dev instanceof TellstickNetDevice device && (device.getMethods() & JNA.CLibrary.TELLSTICK_DIM) > 0) {
|
||||
long tdVal = Math.round((value / 100) * 255);
|
||||
TelldusLiveResponse response = callRestMethod(String.format(HTTP_TELLDUS_DEVICE_DIM, dev.getId(), tdVal),
|
||||
TelldusLiveResponse.class);
|
||||
handleResponse((TellstickNetDevice) dev, response);
|
||||
handleResponse(device, response);
|
||||
} else {
|
||||
throw new TelldusBindingException("Cannot send DIM to " + dev);
|
||||
}
|
||||
}
|
||||
|
||||
private void turnOff(Device dev) throws TellstickException {
|
||||
if (dev instanceof TellstickNetDevice) {
|
||||
if (dev instanceof TellstickNetDevice device) {
|
||||
TelldusLiveResponse response = callRestMethod(String.format(HTTP_TELLDUS_DEVICE_TURNOFF, dev.getId()),
|
||||
TelldusLiveResponse.class);
|
||||
handleResponse((TellstickNetDevice) dev, response);
|
||||
handleResponse(device, response);
|
||||
} else {
|
||||
throw new TelldusBindingException("Cannot send OFF to " + dev);
|
||||
}
|
||||
|
@ -197,21 +196,21 @@ public class TelldusLiveDeviceController implements DeviceChangeListener, Sensor
|
|||
if (response == null || (response.status == null && response.error == null)) {
|
||||
throw new TelldusBindingException("No response " + response);
|
||||
} else if (response.error != null) {
|
||||
if (response.error.equals("The client for this device is currently offline")) {
|
||||
if ("The client for this device is currently offline".equals(response.error)) {
|
||||
device.setOnline(false);
|
||||
device.setUpdated(true);
|
||||
}
|
||||
throw new TelldusBindingException("Error " + response.error);
|
||||
} else if (!response.status.trim().equals("success")) {
|
||||
} else if (!"success".equals(response.status.trim())) {
|
||||
throw new TelldusBindingException("Response " + response.status);
|
||||
}
|
||||
}
|
||||
|
||||
private void turnOn(Device dev) throws TellstickException {
|
||||
if (dev instanceof TellstickNetDevice) {
|
||||
if (dev instanceof TellstickNetDevice device) {
|
||||
TelldusLiveResponse response = callRestMethod(String.format(HTTP_TELLDUS_DEVICE_TURNON, dev.getId()),
|
||||
TelldusLiveResponse.class);
|
||||
handleResponse((TellstickNetDevice) dev, response);
|
||||
handleResponse(device, response);
|
||||
} else {
|
||||
throw new TelldusBindingException("Cannot send ON to " + dev);
|
||||
}
|
||||
|
|
|
@ -90,10 +90,10 @@ public class TelldusLocalDeviceController implements DeviceChangeListener, Senso
|
|||
turnOn(device);
|
||||
} else if (command == OnOffType.OFF) {
|
||||
turnOff(device);
|
||||
} else if (command instanceof PercentType) {
|
||||
dim(device, (PercentType) command);
|
||||
} else if (command instanceof IncreaseDecreaseType) {
|
||||
increaseDecrease(device, ((IncreaseDecreaseType) command));
|
||||
} else if (command instanceof PercentType percentCommand) {
|
||||
dim(device, percentCommand);
|
||||
} else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
|
||||
increaseDecrease(device, increaseDecreaseCommand);
|
||||
}
|
||||
} else if (device instanceof SwitchableDevice) {
|
||||
if (command == OnOffType.ON) {
|
||||
|
@ -137,22 +137,22 @@ public class TelldusLocalDeviceController implements DeviceChangeListener, Senso
|
|||
turnOff(dev);
|
||||
} else if (value == 100 && dev instanceof TellstickLocalDeviceDTO) {
|
||||
turnOn(dev);
|
||||
} else if (dev instanceof TellstickLocalDeviceDTO
|
||||
&& (((TellstickLocalDeviceDTO) dev).getMethods() & JNA.CLibrary.TELLSTICK_DIM) > 0) {
|
||||
} else if (dev instanceof TellstickLocalDeviceDTO device
|
||||
&& (device.getMethods() & JNA.CLibrary.TELLSTICK_DIM) > 0) {
|
||||
long tdVal = Math.round((value / 100) * 255);
|
||||
TelldusLocalResponseDTO response = callRestMethod(
|
||||
String.format(HTTP_LOCAL_API_DEVICE_DIM, dev.getId(), tdVal), TelldusLocalResponseDTO.class);
|
||||
handleResponse((TellstickLocalDeviceDTO) dev, response);
|
||||
handleResponse(device, response);
|
||||
} else {
|
||||
throw new TelldusBindingException("Cannot send DIM to " + dev);
|
||||
}
|
||||
}
|
||||
|
||||
private void turnOff(Device dev) throws TellstickException, InterruptedException {
|
||||
if (dev instanceof TellstickLocalDeviceDTO) {
|
||||
if (dev instanceof TellstickLocalDeviceDTO device) {
|
||||
TelldusLocalResponseDTO response = callRestMethod(String.format(HTTP_LOCAL_API_DEVICE_TURNOFF, dev.getId()),
|
||||
TelldusLocalResponseDTO.class);
|
||||
handleResponse((TellstickLocalDeviceDTO) dev, response);
|
||||
handleResponse(device, response);
|
||||
} else {
|
||||
throw new TelldusBindingException("Cannot send OFF to " + dev);
|
||||
}
|
||||
|
@ -165,16 +165,16 @@ public class TelldusLocalDeviceController implements DeviceChangeListener, Senso
|
|||
} else if (response.getError() != null) {
|
||||
device.setUpdated(true);
|
||||
throw new TelldusBindingException("Error " + response.getError());
|
||||
} else if (!response.getStatus().trim().equals("success")) {
|
||||
} else if (!"success".equals(response.getStatus().trim())) {
|
||||
throw new TelldusBindingException("Response " + response.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
private void turnOn(Device dev) throws TellstickException, InterruptedException {
|
||||
if (dev instanceof TellstickLocalDeviceDTO) {
|
||||
if (dev instanceof TellstickLocalDeviceDTO device) {
|
||||
TelldusLocalResponseDTO response = callRestMethod(String.format(HTTP_LOCAL_DEVICE_TURNON, dev.getId()),
|
||||
TelldusLocalResponseDTO.class);
|
||||
handleResponse((TellstickLocalDeviceDTO) dev, response);
|
||||
handleResponse(device, response);
|
||||
} else {
|
||||
throw new TelldusBindingException("Cannot send ON to " + dev);
|
||||
}
|
||||
|
|
|
@ -964,7 +964,7 @@ public class TeslaChannelSelectorProxy {
|
|||
VEHICLE_NAME("vehicle_name", "name", StringType.class, true) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
return super.getState(s.replaceAll("\"", ""));
|
||||
return super.getState(s.replace("\"", ""));
|
||||
}
|
||||
},
|
||||
VALET_MODE("valet_mode", "valetmode", OnOffType.class, false) {
|
||||
|
|
|
@ -18,7 +18,6 @@ import java.time.Instant;
|
|||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -472,6 +471,6 @@ public class TeslaAccountHandler extends BaseBridgeHandler {
|
|||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singletonList(TeslaVehicleDiscoveryService.class);
|
||||
return List.of(TeslaVehicleDiscoveryService.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -256,8 +256,8 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
|||
try {
|
||||
switch (selector) {
|
||||
case CHARGE_LIMIT_SOC: {
|
||||
if (command instanceof PercentType) {
|
||||
setChargeLimit(((PercentType) command).intValue());
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
setChargeLimit(percentCommand.intValue());
|
||||
} else if (command instanceof OnOffType && command == OnOffType.ON) {
|
||||
setChargeLimit(100);
|
||||
} else if (command instanceof OnOffType && command == OnOffType.OFF) {
|
||||
|
@ -273,11 +273,11 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
|||
}
|
||||
case CHARGE_AMPS:
|
||||
Integer amps = null;
|
||||
if (command instanceof DecimalType) {
|
||||
amps = ((DecimalType) command).intValue();
|
||||
if (command instanceof DecimalType decimalCommand) {
|
||||
amps = decimalCommand.intValue();
|
||||
}
|
||||
if (command instanceof QuantityType<?>) {
|
||||
QuantityType<?> qamps = ((QuantityType<?>) command).toUnit(Units.AMPERE);
|
||||
if (command instanceof QuantityType<?> quantityCommand) {
|
||||
QuantityType<?> qamps = quantityCommand.toUnit(Units.AMPERE);
|
||||
if (qamps != null) {
|
||||
amps = qamps.intValue();
|
||||
}
|
||||
|
@ -324,8 +324,8 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
|||
break;
|
||||
}
|
||||
case CHARGE_TO_MAX: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
if (onOffCommand == OnOffType.ON) {
|
||||
setMaxRangeCharging(true);
|
||||
} else {
|
||||
setMaxRangeCharging(false);
|
||||
|
@ -334,8 +334,8 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
|||
break;
|
||||
}
|
||||
case CHARGE: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
if (onOffCommand == OnOffType.ON) {
|
||||
charge(true);
|
||||
} else {
|
||||
charge(false);
|
||||
|
@ -344,32 +344,32 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
|||
break;
|
||||
}
|
||||
case FLASH: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
if (onOffCommand == OnOffType.ON) {
|
||||
flashLights();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HONK_HORN: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
if (onOffCommand == OnOffType.ON) {
|
||||
honkHorn();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CHARGEPORT: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
if (onOffCommand == OnOffType.ON) {
|
||||
openChargePort();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DOOR_LOCK: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
if (onOffCommand == OnOffType.ON) {
|
||||
lockDoors(true);
|
||||
} else {
|
||||
lockDoors(false);
|
||||
|
@ -378,8 +378,8 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
|||
break;
|
||||
}
|
||||
case AUTO_COND: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
if (onOffCommand == OnOffType.ON) {
|
||||
autoConditioning(true);
|
||||
} else {
|
||||
autoConditioning(false);
|
||||
|
@ -388,24 +388,24 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
|||
break;
|
||||
}
|
||||
case WAKEUP: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
if (onOffCommand == OnOffType.ON) {
|
||||
wakeUp();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FT: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
if (onOffCommand == OnOffType.ON) {
|
||||
openFrunk();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RT: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
if (onOffCommand == OnOffType.ON) {
|
||||
if (vehicleState.rt == 0) {
|
||||
openTrunk();
|
||||
}
|
||||
|
@ -416,9 +416,9 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
|||
break;
|
||||
}
|
||||
case VALET_MODE: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
int valetpin = ((BigDecimal) getConfig().get(VALETPIN)).intValue();
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
if (onOffCommand == OnOffType.ON) {
|
||||
setValetMode(true, valetpin);
|
||||
} else {
|
||||
setValetMode(false, valetpin);
|
||||
|
@ -427,16 +427,16 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
|||
break;
|
||||
}
|
||||
case RESET_VALET_PIN: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
if (onOffCommand == OnOffType.ON) {
|
||||
resetValetPin();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case STEERINGWHEEL_HEATER: {
|
||||
if (command instanceof OnOffType) {
|
||||
boolean commandBooleanValue = ((OnOffType) command) == OnOffType.ON ? true : false;
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
boolean commandBooleanValue = onOffCommand == OnOffType.ON ? true : false;
|
||||
setSteeringWheelHeater(commandBooleanValue);
|
||||
}
|
||||
break;
|
||||
|
@ -1025,7 +1025,7 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
|||
case "data:update":
|
||||
logger.debug("Event : Received an update: '{}'", event.value);
|
||||
|
||||
String vals[] = event.value.split(",");
|
||||
String[] vals = event.value.split(",");
|
||||
long currentTimeStamp = Long.parseLong(vals[0]);
|
||||
long systemTimeStamp = System.currentTimeMillis();
|
||||
if (logger.isDebugEnabled()) {
|
||||
|
|
|
@ -26,7 +26,7 @@ public class Vehicle {
|
|||
public String option_codes;
|
||||
public String vehicle_id;
|
||||
public String vin;
|
||||
public String tokens[];
|
||||
public String[] tokens;
|
||||
public String state;
|
||||
public boolean remote_start_enabled;
|
||||
public boolean calendar_enabled;
|
||||
|
|
|
@ -26,7 +26,7 @@ public class VehicleData {
|
|||
public String option_codes;
|
||||
public String vehicle_id;
|
||||
public String vin;
|
||||
public String tokens[];
|
||||
public String[] tokens;
|
||||
public String state;
|
||||
public boolean remote_start_enabled;
|
||||
public boolean calendar_enabled;
|
||||
|
|
|
@ -14,7 +14,6 @@ package org.openhab.binding.tivo.internal;
|
|||
|
||||
import static org.openhab.binding.tivo.internal.TiVoBindingConstants.THING_TYPE_TIVO;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
|
@ -39,7 +38,7 @@ import org.osgi.service.component.annotations.Component;
|
|||
@NonNullByDefault
|
||||
@Component(configurationPid = "binding.tivo", service = ThingHandlerFactory.class)
|
||||
public class TiVoHandlerFactory extends BaseThingHandlerFactory {
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_TIVO);
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_TIVO);
|
||||
|
||||
@Override
|
||||
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
|
||||
|
|
|
@ -15,7 +15,6 @@ package org.openhab.binding.tivo.internal.discovery;
|
|||
import static org.openhab.binding.tivo.internal.TiVoBindingConstants.*;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -48,7 +47,7 @@ public class TiVoDiscoveryParticipant implements MDNSDiscoveryParticipant {
|
|||
|
||||
@Override
|
||||
public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
|
||||
return Collections.singleton(THING_TYPE_TIVO);
|
||||
return Set.of(THING_TYPE_TIVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -73,7 +73,7 @@ public class TiVoHandler extends BaseThingHandler {
|
|||
// Handles the commands from the various TiVo channel objects
|
||||
logger.debug("handleCommand '{}', parameter: {}", channelUID, command);
|
||||
|
||||
if (!isInitialized() || !tivoConnection.isPresent()) {
|
||||
if (!isInitialized() || tivoConnection.isEmpty()) {
|
||||
logger.debug("handleCommand '{}' device is not initialized yet, command '{}' will be ignored.",
|
||||
getThing().getUID(), channelUID + " " + command);
|
||||
return;
|
||||
|
@ -122,7 +122,7 @@ public class TiVoHandler extends BaseThingHandler {
|
|||
|
||||
private void sendCommand(String commandKeyword, String commandParameter, TivoStatusData currentStatus)
|
||||
throws InterruptedException {
|
||||
if (!tivoConnection.isPresent()) {
|
||||
if (tivoConnection.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -299,8 +299,7 @@ public class TiVoHandler extends BaseThingHandler {
|
|||
}
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
logger.warn("TiVo'{}' unable to parse channel integer, value sent was: '{}'", getThing().getUID(),
|
||||
command.toString());
|
||||
logger.warn("TiVo'{}' unable to parse channel integer, value sent was: '{}'", getThing().getUID(), command);
|
||||
}
|
||||
return tmpStatus;
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public class TivoStatusData {
|
|||
UNKNOWN,
|
||||
OFFLINE,
|
||||
STANDBY,
|
||||
ONLINE;
|
||||
ONLINE
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -124,7 +124,7 @@ public class TivoStatusProvider {
|
|||
}
|
||||
for (int i = 1; i <= repeatCount; i++) {
|
||||
// Send the command
|
||||
streamWriter.println(tivoCommand.toString() + "\r");
|
||||
streamWriter.println(tivoCommand + "\r");
|
||||
if (streamWriter.checkError()) {
|
||||
logger.debug("TiVo '{}' - called cmdTivoSend and encountered an IO error",
|
||||
tivoConfigData.getCfgIdentifier());
|
||||
|
|
|
@ -57,8 +57,7 @@ public class TouchWandAlarmSensorHandler extends TouchWandBaseUnitHandler {
|
|||
|
||||
@Override
|
||||
void updateTouchWandUnitState(TouchWandUnitData unitData) {
|
||||
if (unitData instanceof TouchWandUnitDataAlarmSensor) {
|
||||
TouchWandUnitDataAlarmSensor sensor = (TouchWandUnitDataAlarmSensor) unitData;
|
||||
if (unitData instanceof TouchWandUnitDataAlarmSensor sensor) {
|
||||
if (isFirstUpdateTouchWandUnitState) {
|
||||
removeUnsupportedChannels(sensor);
|
||||
isFirstUpdateTouchWandUnitState = false;
|
||||
|
|
|
@ -42,21 +42,21 @@ public class TouchWandBSensorHandler extends TouchWandBaseUnitHandler {
|
|||
|
||||
@Override
|
||||
void updateTouchWandUnitState(TouchWandUnitData unitData) {
|
||||
if (unitData instanceof TouchWandBSensorUnitData) {
|
||||
if (unitData instanceof TouchWandBSensorUnitData bSensorUnitData) {
|
||||
if (isFirstUpdateTouchWandUnitState) {
|
||||
removeUnsupportedChannels((TouchWandBSensorUnitData) unitData);
|
||||
removeUnsupportedChannels(bSensorUnitData);
|
||||
isFirstUpdateTouchWandUnitState = false;
|
||||
}
|
||||
String sensorSubType = ((TouchWandBSensorUnitData) unitData).getIdData().getSubType();
|
||||
String sensorSubType = bSensorUnitData.getIdData().getSubType();
|
||||
switch (sensorSubType) {
|
||||
case BSENSOR_SUBTYPE_DOORWINDOW:
|
||||
updateChannelDoorWindow((TouchWandBSensorUnitData) unitData);
|
||||
updateChannelDoorWindow(bSensorUnitData);
|
||||
break;
|
||||
case BSENSOR_SUBTYPE_MOTION:
|
||||
updateChannelMotion((TouchWandBSensorUnitData) unitData);
|
||||
updateChannelMotion(bSensorUnitData);
|
||||
break;
|
||||
case BSENSOR_SUBTYPE_SMOKE:
|
||||
updateChannelSmoke((TouchWandBSensorUnitData) unitData);
|
||||
updateChannelSmoke(bSensorUnitData);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ public abstract class TouchWandBaseUnitHandler extends BaseThingHandler implemen
|
|||
|
||||
@Override
|
||||
public void onItemStatusUpdate(TouchWandUnitData unitData) {
|
||||
if (unitData.getStatus().equals("ALIVE")) {
|
||||
if ("ALIVE".equals(unitData.getStatus())) {
|
||||
updateStatus(ThingStatus.ONLINE);
|
||||
} else {
|
||||
// updateStatus(ThingStatus.OFFLINE); // comment - OFFLINE status is not accurate at the moment
|
||||
|
|
|
@ -15,7 +15,6 @@ package org.openhab.binding.touchwand.internal;
|
|||
import static org.openhab.binding.touchwand.internal.TouchWandBindingConstants.THING_TYPE_BRIDGE;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
@ -45,7 +44,7 @@ import org.slf4j.LoggerFactory;
|
|||
*/
|
||||
@NonNullByDefault
|
||||
public class TouchWandBridgeHandler extends BaseBridgeHandler implements TouchWandUnitStatusUpdateListener {
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_BRIDGE);
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_BRIDGE);
|
||||
private final Logger logger = LoggerFactory.getLogger(TouchWandBridgeHandler.class);
|
||||
private boolean addSecondaryUnits;
|
||||
private @Nullable TouchWandWebSockets touchWandWebSockets;
|
||||
|
@ -138,6 +137,6 @@ public class TouchWandBridgeHandler extends BaseBridgeHandler implements TouchWa
|
|||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(TouchWandUnitDiscoveryService.class);
|
||||
return Set.of(TouchWandUnitDiscoveryService.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,8 +39,8 @@ public class TouchWandDimmerHandler extends TouchWandBaseUnitHandler {
|
|||
void touchWandUnitHandleCommand(Command command) {
|
||||
TouchWandBridgeHandler touchWandBridgeHandler = bridgeHandler;
|
||||
if (touchWandBridgeHandler != null) {
|
||||
if (command instanceof OnOffType) {
|
||||
touchWandBridgeHandler.touchWandClient.cmdSwitchOnOff(unitId, (OnOffType) command);
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
touchWandBridgeHandler.touchWandClient.cmdSwitchOnOff(unitId, onOffCommand);
|
||||
} else {
|
||||
touchWandBridgeHandler.touchWandClient.cmdDimmerPosition(unitId, command.toString());
|
||||
}
|
||||
|
@ -49,8 +49,8 @@ public class TouchWandDimmerHandler extends TouchWandBaseUnitHandler {
|
|||
|
||||
@Override
|
||||
void updateTouchWandUnitState(TouchWandUnitData unitData) {
|
||||
if (unitData instanceof TouchWandShutterSwitchUnitData) {
|
||||
int status = ((TouchWandShutterSwitchUnitData) unitData).getCurrStatus();
|
||||
if (unitData instanceof TouchWandShutterSwitchUnitData shutterSwitchUnitData) {
|
||||
int status = shutterSwitchUnitData.getCurrStatus();
|
||||
PercentType state = PercentType.ZERO;
|
||||
int convertStatus = status;
|
||||
state = new PercentType(convertStatus);
|
||||
|
|
|
@ -203,8 +203,7 @@ public class TouchWandRestClient {
|
|||
}
|
||||
|
||||
private String buildUrl(String command) {
|
||||
String url = "http://" + touchWandIpAddr + ":" + touchWandPort + COMMAND_MAP.get(command);
|
||||
return url;
|
||||
return "http://" + touchWandIpAddr + ":" + touchWandPort + COMMAND_MAP.get(command);
|
||||
}
|
||||
|
||||
private synchronized String sendCommand(String command, HttpMethod method, String content) {
|
||||
|
|
|
@ -59,8 +59,8 @@ public class TouchWandShutterHandler extends TouchWandBaseUnitHandler {
|
|||
|
||||
@Override
|
||||
void updateTouchWandUnitState(TouchWandUnitData unitData) {
|
||||
if (unitData instanceof TouchWandShutterSwitchUnitData) {
|
||||
int status = ((TouchWandShutterSwitchUnitData) unitData).getCurrStatus();
|
||||
if (unitData instanceof TouchWandShutterSwitchUnitData shutterSwitchUnitData) {
|
||||
int status = shutterSwitchUnitData.getCurrStatus();
|
||||
PercentType state = PercentType.ZERO;
|
||||
int convertStatus = 100 - status;
|
||||
state = new PercentType(convertStatus);
|
||||
|
|
|
@ -37,9 +37,9 @@ public class TouchWandSwitchHandler extends TouchWandBaseUnitHandler {
|
|||
|
||||
@Override
|
||||
void updateTouchWandUnitState(TouchWandUnitData unitData) {
|
||||
if (unitData instanceof TouchWandShutterSwitchUnitData) {
|
||||
if (unitData instanceof TouchWandShutterSwitchUnitData shutterSwitchUnitData) {
|
||||
OnOffType state;
|
||||
int status = ((TouchWandShutterSwitchUnitData) unitData).getCurrStatus();
|
||||
int status = shutterSwitchUnitData.getCurrStatus();
|
||||
String sStatus = Integer.toString(status);
|
||||
|
||||
if (sStatus.equals(SWITCH_STATUS_OFF)) {
|
||||
|
@ -58,10 +58,10 @@ public class TouchWandSwitchHandler extends TouchWandBaseUnitHandler {
|
|||
|
||||
@Override
|
||||
void touchWandUnitHandleCommand(Command command) {
|
||||
if (command instanceof OnOffType) {
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
TouchWandBridgeHandler touchWandBridgeHandler = bridgeHandler;
|
||||
if (touchWandBridgeHandler != null) {
|
||||
touchWandBridgeHandler.touchWandClient.cmdSwitchOnOff(unitId, (OnOffType) command);
|
||||
touchWandBridgeHandler.touchWandClient.cmdSwitchOnOff(unitId, onOffCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,8 +40,7 @@ public class TouchWandThermostatHandler extends TouchWandBaseUnitHandler {
|
|||
|
||||
@Override
|
||||
void updateTouchWandUnitState(TouchWandUnitData unitData) {
|
||||
if (unitData instanceof TouchWandThermostatUnitData) {
|
||||
TouchWandThermostatUnitData thermostat = (TouchWandThermostatUnitData) unitData;
|
||||
if (unitData instanceof TouchWandThermostatUnitData thermostat) {
|
||||
updateThermostatState(thermostat);
|
||||
updateTargetTemperature(thermostat);
|
||||
updateRoomTemperature(thermostat);
|
||||
|
@ -56,12 +55,12 @@ public class TouchWandThermostatHandler extends TouchWandBaseUnitHandler {
|
|||
void touchWandUnitHandleCommand(Command command) {
|
||||
TouchWandBridgeHandler touchWandBridgeHandler = bridgeHandler;
|
||||
if (touchWandBridgeHandler != null) {
|
||||
if (command instanceof OnOffType) {
|
||||
touchWandBridgeHandler.touchWandClient.cmdThermostatOnOff(unitId, (OnOffType) command);
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
touchWandBridgeHandler.touchWandClient.cmdThermostatOnOff(unitId, onOffCommand);
|
||||
return;
|
||||
}
|
||||
if (command instanceof QuantityType) {
|
||||
final QuantityType<?> value = ((QuantityType<?>) command).toUnit(SIUnits.CELSIUS);
|
||||
if (command instanceof QuantityType quantityCommand) {
|
||||
final QuantityType<?> value = quantityCommand.toUnit(SIUnits.CELSIUS);
|
||||
String targetTemperature = String.valueOf(value.intValue());
|
||||
touchWandBridgeHandler.touchWandClient.cmdThermostatTargetTemperature(unitId, targetTemperature);
|
||||
return;
|
||||
|
|
|
@ -48,8 +48,8 @@ public class TouchWandWallControllerHandler extends TouchWandBaseUnitHandler {
|
|||
|
||||
@Override
|
||||
void updateTouchWandUnitState(TouchWandUnitData unitData) {
|
||||
if (unitData instanceof TouchWandUnitDataWallController) {
|
||||
Csc status = ((TouchWandUnitDataWallController) unitData).getCurrStatus();
|
||||
if (unitData instanceof TouchWandUnitDataWallController unitDataWallController) {
|
||||
Csc status = unitDataWallController.getCurrStatus();
|
||||
long ts = status.getTs();
|
||||
long timeDiff = ts - timeLastEventMs;
|
||||
if ((timeDiff) > ADJACENT_EVENT_FILTER_TIME_MILLISEC) {
|
||||
|
|
|
@ -79,7 +79,7 @@ public class TouchWandWebSockets {
|
|||
|
||||
public void connect() {
|
||||
try {
|
||||
uri = new URI("ws://" + controllerAddress + ":" + String.valueOf(port) + WS_ENDPOINT_TOUCHWAND);
|
||||
uri = new URI("ws://" + controllerAddress + ":" + port + WS_ENDPOINT_TOUCHWAND);
|
||||
} catch (URISyntaxException e) {
|
||||
logger.warn("URI not valid {} message {}", uri, e.getMessage());
|
||||
return;
|
||||
|
@ -152,12 +152,12 @@ public class TouchWandWebSockets {
|
|||
TouchWandUnitData touchWandUnit;
|
||||
try {
|
||||
JsonObject unitObj = JsonParser.parseString(msg).getAsJsonObject();
|
||||
boolean eventUnitChanged = unitObj.get("type").getAsString().equals("UNIT_CHANGED");
|
||||
boolean eventUnitChanged = "UNIT_CHANGED".equals(unitObj.get("type").getAsString());
|
||||
if (!eventUnitChanged) {
|
||||
return;
|
||||
}
|
||||
touchWandUnit = TouchWandUnitFromJson.parseResponse(unitObj.get("unit").getAsJsonObject());
|
||||
if (!touchWandUnit.getStatus().equals("ALIVE")) {
|
||||
if (!"ALIVE".equals(touchWandUnit.getStatus())) {
|
||||
logger.debug("UNIT_CHANGED unit status not ALIVE : {}", touchWandUnit.getStatus());
|
||||
}
|
||||
boolean supportedUnitType = Arrays.asList(SUPPORTED_TOUCHWAND_TYPES).contains(touchWandUnit.getType());
|
||||
|
|
|
@ -91,7 +91,7 @@ public class TouchWandControllerDiscoveryService extends AbstractDiscoveryServic
|
|||
}
|
||||
|
||||
private void addDeviceDiscoveryResult(String label, String ip) {
|
||||
String id = ip.replaceAll("\\.", "");
|
||||
String id = ip.replace(".", "");
|
||||
ThingUID thingUID = new ThingUID(THING_TYPE_BRIDGE, id);
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("label", label);
|
||||
|
@ -138,7 +138,7 @@ public class TouchWandControllerDiscoveryService extends AbstractDiscoveryServic
|
|||
String sentence = new String(dgram.getData(), 0, dgram.getLength(), StandardCharsets.US_ASCII);
|
||||
JsonObject bridge = JsonParser.parseString(sentence).getAsJsonObject();//
|
||||
String name = bridge.get("name").getAsString();
|
||||
addDeviceDiscoveryResult(name, address.getHostAddress().toString());
|
||||
addDeviceDiscoveryResult(name, address.getHostAddress());
|
||||
logger.debug("Received Datagram from {}:{} on Port {} message {}", address.getHostAddress(),
|
||||
dgram.getPort(), mySocket.getLocalPort(), sentence);
|
||||
}
|
||||
|
|
|
@ -191,8 +191,8 @@ public class TouchWandUnitDiscoveryService extends AbstractDiscoveryService impl
|
|||
|
||||
@Override
|
||||
public void setThingHandler(@NonNullByDefault({}) ThingHandler handler) {
|
||||
if (handler instanceof TouchWandBridgeHandler) {
|
||||
touchWandBridgeHandler = (TouchWandBridgeHandler) handler;
|
||||
if (handler instanceof TouchWandBridgeHandler touchWandBridgeHandler) {
|
||||
this.touchWandBridgeHandler = touchWandBridgeHandler;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public class AlarmSensorUnitDataDeserializer implements JsonDeserializer<TouchWa
|
|||
|
||||
for (Entry<String, JsonElement> entry : currentStatusObj.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String splits[] = key.split("_"); // the key is xxxx_n where xxx is sensor type and n is
|
||||
String[] splits = key.split("_"); // the key is xxxx_n where xxx is sensor type and n is
|
||||
String keyName = splits[0];
|
||||
int index = 0;
|
||||
|
||||
|
|
|
@ -70,12 +70,12 @@ public class BulbDevice extends SmartHomeDevice {
|
|||
final int transitionPeriod = configuration.transitionPeriod;
|
||||
final HasErrorResponse response;
|
||||
|
||||
if (command instanceof OnOffType && CHANNELS_BULB_SWITCH.contains(channelId)) {
|
||||
response = handleOnOffType(channelId, (OnOffType) command, transitionPeriod);
|
||||
} else if (command instanceof HSBType && CHANNEL_COLOR.equals(channelId)) {
|
||||
response = handleHSBType(channelId, (HSBType) command, transitionPeriod);
|
||||
} else if (command instanceof DecimalType) {
|
||||
response = handleDecimalType(channelId, (DecimalType) command, transitionPeriod);
|
||||
if (command instanceof OnOffType onOffCommand && CHANNELS_BULB_SWITCH.contains(channelId)) {
|
||||
response = handleOnOffType(channelId, onOffCommand, transitionPeriod);
|
||||
} else if (command instanceof HSBType hsbCommand && CHANNEL_COLOR.equals(channelId)) {
|
||||
response = handleHSBType(channelId, hsbCommand, transitionPeriod);
|
||||
} else if (command instanceof DecimalType decimalCommand) {
|
||||
response = handleDecimalType(channelId, decimalCommand, transitionPeriod);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -56,11 +56,9 @@ public class DimmerDevice extends SwitchDevice {
|
|||
private boolean handleBrightnessChannel(ChannelUID channelUid, Command command) throws IOException {
|
||||
HasErrorResponse response = null;
|
||||
|
||||
if (command instanceof OnOffType) {
|
||||
response = setOnOffState(channelUid, (OnOffType) command);
|
||||
} else if (command instanceof PercentType) {
|
||||
PercentType percentCommand = (PercentType) command;
|
||||
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
response = setOnOffState(channelUid, onOffCommand);
|
||||
} else if (command instanceof PercentType percentCommand) {
|
||||
// Don't send value 0 as brightness value as it will give an error from the device.
|
||||
if (percentCommand.intValue() > 0) {
|
||||
response = commands.setDimmerBrightnessResponse(
|
||||
|
|
|
@ -41,7 +41,7 @@ public class SwitchDevice extends SmartHomeDevice {
|
|||
|
||||
@Override
|
||||
public boolean handleCommand(ChannelUID channelUid, Command command) throws IOException {
|
||||
return command instanceof OnOffType && handleOnOffType(channelUid, (OnOffType) command);
|
||||
return command instanceof OnOffType onOffCommand && handleOnOffType(channelUid, onOffCommand);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -58,8 +58,8 @@ public class TPLinkSmartHomeActions implements ThingActions, ThingHandlerService
|
|||
|
||||
@Override
|
||||
public void setThingHandler(final ThingHandler handler) {
|
||||
if (handler instanceof SmartHomeHandler) {
|
||||
this.handler = (SmartHomeHandler) handler;
|
||||
if (handler instanceof SmartHomeHandler smartHomeHandler) {
|
||||
this.handler = smartHomeHandler;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ public class FritzboxActions implements ThingActions {
|
|||
|
||||
Optional<SCPDServiceType> scpdService = scpdUtil.getDevice("")
|
||||
.flatMap(deviceType -> deviceType.getServiceList().stream().filter(
|
||||
service -> service.getServiceId().equals("urn:DeviceConfig-com:serviceId:DeviceConfig1"))
|
||||
service -> "urn:DeviceConfig-com:serviceId:DeviceConfig1".equals(service.getServiceId()))
|
||||
.findFirst());
|
||||
if (scpdService.isEmpty()) {
|
||||
logger.warn("Could not get service.");
|
||||
|
|
|
@ -53,8 +53,8 @@ public class Tr064DiscoveryService extends AbstractDiscoveryService implements T
|
|||
|
||||
@Override
|
||||
public void setThingHandler(ThingHandler thingHandler) {
|
||||
if (thingHandler instanceof Tr064RootHandler) {
|
||||
this.bridgeHandler = (Tr064RootHandler) thingHandler;
|
||||
if (thingHandler instanceof Tr064RootHandler tr064RootHandler) {
|
||||
this.bridgeHandler = tr064RootHandler;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -111,8 +111,8 @@ public class Tr064HandlerFactory extends BaseThingHandlerFactory {
|
|||
|
||||
@Override
|
||||
protected void removeHandler(ThingHandler thingHandler) {
|
||||
if (thingHandler instanceof Tr064RootHandler) {
|
||||
phonebookProfileFactory.unregisterPhonebookProvider((Tr064RootHandler) thingHandler);
|
||||
if (thingHandler instanceof Tr064RootHandler tr064RootHandler) {
|
||||
phonebookProfileFactory.unregisterPhonebookProvider(tr064RootHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -242,7 +242,7 @@ public class Tr064RootHandler extends BaseBridgeHandler implements PhonebookProv
|
|||
SCPDDeviceType device = scpdUtil.getDevice("")
|
||||
.orElseThrow(() -> new SCPDException("Root device not found"));
|
||||
SCPDServiceType deviceService = device.getServiceList().stream()
|
||||
.filter(service -> service.getServiceId().equals("urn:DeviceInfo-com:serviceId:DeviceInfo1"))
|
||||
.filter(service -> "urn:DeviceInfo-com:serviceId:DeviceInfo1".equals(service.getServiceId()))
|
||||
.findFirst().orElseThrow(() -> new SCPDException(
|
||||
"service 'urn:DeviceInfo-com:serviceId:DeviceInfo1' not found"));
|
||||
|
||||
|
@ -282,7 +282,7 @@ public class Tr064RootHandler extends BaseBridgeHandler implements PhonebookProv
|
|||
SCPDActionType getInfoAction = scpdUtil.getService(deviceService.getServiceId())
|
||||
.orElseThrow(() -> new SCPDException(
|
||||
"Could not get service definition for 'urn:DeviceInfo-com:serviceId:DeviceInfo1'"))
|
||||
.getActionList().stream().filter(action -> action.getName().equals("GetInfo")).findFirst()
|
||||
.getActionList().stream().filter(action -> "GetInfo".equals(action.getName())).findFirst()
|
||||
.orElseThrow(() -> new SCPDException("Action 'GetInfo' not found"));
|
||||
SOAPMessage soapResponse1 = soapConnector
|
||||
.doSOAPRequest(new SOAPRequest(deviceService, getInfoAction.getName()));
|
||||
|
|
|
@ -98,17 +98,17 @@ public class PhonebookProfile implements StateProfile {
|
|||
phonebookName = UIDUtils.decode(phonebookParams[1]);
|
||||
}
|
||||
if (matchCountParam != null) {
|
||||
if (matchCountParam instanceof BigDecimal) {
|
||||
matchCount = ((BigDecimal) matchCountParam).intValue();
|
||||
} else if (matchCountParam instanceof String) {
|
||||
matchCount = Integer.parseInt((String) matchCountParam);
|
||||
if (matchCountParam instanceof BigDecimal bigDecimal) {
|
||||
matchCount = bigDecimal.intValue();
|
||||
} else if (matchCountParam instanceof String string) {
|
||||
matchCount = Integer.parseInt(string);
|
||||
}
|
||||
}
|
||||
if (phoneNumberIndexParam != null) {
|
||||
if (phoneNumberIndexParam instanceof BigDecimal) {
|
||||
phoneNumberIndex = ((BigDecimal) phoneNumberIndexParam).intValue();
|
||||
} else if (phoneNumberIndexParam instanceof String) {
|
||||
phoneNumberIndex = Integer.parseInt((String) phoneNumberIndexParam);
|
||||
if (phoneNumberIndexParam instanceof BigDecimal bigDecimal) {
|
||||
phoneNumberIndex = bigDecimal.intValue();
|
||||
} else if (phoneNumberIndexParam instanceof String string) {
|
||||
phoneNumberIndex = Integer.parseInt(string);
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
|
|
@ -153,8 +153,8 @@ public class SOAPConnector {
|
|||
return soapMessage;
|
||||
} catch (IllegalArgumentException e) {
|
||||
Throwable cause = e.getCause();
|
||||
if (cause instanceof Tr064CommunicationException) {
|
||||
throw (Tr064CommunicationException) cause;
|
||||
if (cause instanceof Tr064CommunicationException tr064CommunicationException) {
|
||||
throw tr064CommunicationException;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
|
|
|
@ -78,9 +78,8 @@ public class SOAPValueConverter {
|
|||
// we don't have data to send
|
||||
return Optional.of("");
|
||||
}
|
||||
if (command instanceof QuantityType) {
|
||||
QuantityType<?> value = (unit.isEmpty()) ? ((QuantityType<?>) command)
|
||||
: ((QuantityType<?>) command).toUnit(unit);
|
||||
if (command instanceof QuantityType quantityCommand) {
|
||||
QuantityType<?> value = (unit.isEmpty()) ? quantityCommand : quantityCommand.toUnit(unit);
|
||||
if (value == null) {
|
||||
logger.warn("Could not convert {} to unit {}", command, unit);
|
||||
return Optional.empty();
|
||||
|
@ -95,8 +94,8 @@ public class SOAPValueConverter {
|
|||
default -> {
|
||||
}
|
||||
}
|
||||
} else if (command instanceof DecimalType) {
|
||||
BigDecimal value = ((DecimalType) command).toBigDecimal();
|
||||
} else if (command instanceof DecimalType decimalCommand) {
|
||||
BigDecimal value = decimalCommand.toBigDecimal();
|
||||
switch (dataType) {
|
||||
case "ui1", "ui2" -> {
|
||||
return Optional.of(String.valueOf(value.shortValue()));
|
||||
|
@ -139,7 +138,7 @@ public class SOAPValueConverter {
|
|||
// map rawValue to State
|
||||
switch (dataType) {
|
||||
case "boolean" -> {
|
||||
return rawValue.equals("0") ? OnOffType.OFF : OnOffType.ON;
|
||||
return "0".equals(rawValue) ? OnOffType.OFF : OnOffType.ON;
|
||||
}
|
||||
case "string" -> {
|
||||
return new StringType(rawValue);
|
||||
|
@ -170,8 +169,8 @@ public class SOAPValueConverter {
|
|||
Method method = SOAPValueConverter.class.getDeclaredMethod(postProcessor, State.class,
|
||||
Tr064ChannelConfig.class);
|
||||
Object o = method.invoke(this, state, channelConfig);
|
||||
if (o instanceof State) {
|
||||
return (State) o;
|
||||
if (o instanceof State stateInstance) {
|
||||
return stateInstance;
|
||||
}
|
||||
} catch (NoSuchMethodException | IllegalAccessException e) {
|
||||
logger.warn("Postprocessor {} not found, this most likely is a programming error", postProcessor, e);
|
||||
|
|
|
@ -281,10 +281,10 @@ public class Util {
|
|||
// get parameters by reflection from thing config
|
||||
Field paramField = thingConfig.getClass().getField(parameter.getThingParameter());
|
||||
Object rawFieldValue = paramField.get(thingConfig);
|
||||
if ((rawFieldValue instanceof List<?>)) {
|
||||
((List<?>) rawFieldValue).forEach(obj -> {
|
||||
if (obj instanceof String) {
|
||||
parameters.add((String) obj);
|
||||
if ((rawFieldValue instanceof List<?> list)) {
|
||||
list.forEach(obj -> {
|
||||
if (obj instanceof String string) {
|
||||
parameters.add(string);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -52,9 +52,9 @@ public class TradfriBindingConstants {
|
|||
.unmodifiableSet(Stream.of(THING_TYPE_DIMMABLE_LIGHT, THING_TYPE_COLOR_TEMP_LIGHT, THING_TYPE_COLOR_LIGHT)
|
||||
.collect(Collectors.toSet()));
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_PLUG_TYPES_UIDS = Collections.singleton(THING_TYPE_ONOFF_PLUG);
|
||||
public static final Set<ThingTypeUID> SUPPORTED_PLUG_TYPES_UIDS = Set.of(THING_TYPE_ONOFF_PLUG);
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_BLINDS_TYPES_UIDS = Collections.singleton(THING_TYPE_BLINDS);
|
||||
public static final Set<ThingTypeUID> SUPPORTED_BLINDS_TYPES_UIDS = Set.of(THING_TYPE_BLINDS);
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_AIR_PURIFIER_TYPES_UIDS = Set.of(THING_TYPE_AIR_PURIFIER);
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class TradfriBindingConstants {
|
|||
.unmodifiableSet(Stream.of(THING_TYPE_DIMMER, THING_TYPE_REMOTE_CONTROL,
|
||||
THING_TYPE_OPEN_CLOSE_REMOTE_CONTROL, THING_TYPE_MOTION_SENSOR).collect(Collectors.toSet()));
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_BRIDGE_TYPES_UIDS = Collections.singleton(GATEWAY_TYPE_UID);
|
||||
public static final Set<ThingTypeUID> SUPPORTED_BRIDGE_TYPES_UIDS = Set.of(GATEWAY_TYPE_UID);
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_DEVICE_TYPES_UIDS = Collections.unmodifiableSet(Stream
|
||||
.of(SUPPORTED_LIGHT_TYPES_UIDS.stream(), SUPPORTED_CONTROLLER_TYPES_UIDS.stream(),
|
||||
|
|
|
@ -86,8 +86,8 @@ public class TradfriDiscoveryService extends AbstractDiscoveryService
|
|||
|
||||
@Override
|
||||
public void setThingHandler(@Nullable ThingHandler handler) {
|
||||
if (handler instanceof TradfriGatewayHandler) {
|
||||
this.handler = (TradfriGatewayHandler) handler;
|
||||
if (handler instanceof TradfriGatewayHandler gatewayHandler) {
|
||||
this.handler = gatewayHandler;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,8 +75,8 @@ public class TradfriAirPurifierHandler extends TradfriThingHandler {
|
|||
}
|
||||
|
||||
private void handleFanModeCommand(Command command) {
|
||||
if (command instanceof Number) {
|
||||
set(new TradfriAirPurifierData().setFanMode((Number) command).getJsonString());
|
||||
if (command instanceof Number numberCommand) {
|
||||
set(new TradfriAirPurifierData().setFanMode(numberCommand).getJsonString());
|
||||
} else {
|
||||
logger.debug("Cannot handle command '{}' of type {} for channel '{}'", command, command.getClass(),
|
||||
CHANNEL_FAN_MODE);
|
||||
|
@ -84,8 +84,8 @@ public class TradfriAirPurifierHandler extends TradfriThingHandler {
|
|||
}
|
||||
|
||||
private void handleDisableLed(Command command) {
|
||||
if (command instanceof OnOffType) {
|
||||
set(new TradfriAirPurifierData().setDisableLed((OnOffType) command).getJsonString());
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
set(new TradfriAirPurifierData().setDisableLed(onOffCommand).getJsonString());
|
||||
} else {
|
||||
logger.debug("Cannot handle command '{}' of type {} for channel '{}'", command, command.getClass(),
|
||||
CHANNEL_DISABLE_LED);
|
||||
|
@ -93,8 +93,8 @@ public class TradfriAirPurifierHandler extends TradfriThingHandler {
|
|||
}
|
||||
|
||||
private void handleLockButton(Command command) {
|
||||
if (command instanceof OnOffType) {
|
||||
set(new TradfriAirPurifierData().setLockPhysicalButton((OnOffType) command).getJsonString());
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
set(new TradfriAirPurifierData().setLockPhysicalButton(onOffCommand).getJsonString());
|
||||
} else {
|
||||
logger.debug("Cannot handle command '{}' of type {} for channel '{}'", command, command.getClass(),
|
||||
CHANNEL_DISABLE_LED);
|
||||
|
|
|
@ -108,8 +108,8 @@ public class TradfriBlindHandler extends TradfriThingHandler {
|
|||
}
|
||||
|
||||
private void handlePositionCommand(Command command) {
|
||||
if (command instanceof PercentType) {
|
||||
setPosition((PercentType) command);
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
setPosition(percentCommand);
|
||||
} else if (command instanceof StopMoveType) {
|
||||
if (StopMoveType.STOP.equals(command)) {
|
||||
triggerStop();
|
||||
|
|
|
@ -18,7 +18,6 @@ import java.io.IOException;
|
|||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
@ -137,7 +136,7 @@ public class TradfriGatewayHandler extends BaseBridgeHandler implements CoapCall
|
|||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(TradfriDiscoveryService.class);
|
||||
return Set.of(TradfriDiscoveryService.class);
|
||||
}
|
||||
|
||||
private void establishConnection() {
|
||||
|
|
|
@ -154,10 +154,10 @@ public class TradfriLightHandler extends TradfriThingHandler {
|
|||
}
|
||||
|
||||
private void handleBrightnessCommand(Command command) {
|
||||
if (command instanceof PercentType) {
|
||||
setBrightness((PercentType) command);
|
||||
} else if (command instanceof OnOffType) {
|
||||
setState(((OnOffType) command));
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
setBrightness(percentCommand);
|
||||
} else if (command instanceof OnOffType onOffCommand) {
|
||||
setState(onOffCommand);
|
||||
} else if (command instanceof IncreaseDecreaseType) {
|
||||
final TradfriLightData state = this.state;
|
||||
if (state != null && state.getBrightness() != null) {
|
||||
|
@ -177,8 +177,8 @@ public class TradfriLightHandler extends TradfriThingHandler {
|
|||
}
|
||||
|
||||
private void handleColorTemperatureCommand(Command command) {
|
||||
if (command instanceof PercentType) {
|
||||
setColorTemperature((PercentType) command);
|
||||
if (command instanceof PercentType percentCommand) {
|
||||
setColorTemperature(percentCommand);
|
||||
} else if (command instanceof IncreaseDecreaseType) {
|
||||
final TradfriLightData state = this.state;
|
||||
if (state != null && state.getColorTemperature() != null) {
|
||||
|
@ -198,13 +198,13 @@ public class TradfriLightHandler extends TradfriThingHandler {
|
|||
}
|
||||
|
||||
private void handleColorCommand(Command command) {
|
||||
if (command instanceof HSBType) {
|
||||
setColor((HSBType) command);
|
||||
setBrightness(((HSBType) command).getBrightness());
|
||||
} else if (command instanceof OnOffType) {
|
||||
setState(((OnOffType) command));
|
||||
} else if (command instanceof PercentType) {
|
||||
setBrightness((PercentType) command);
|
||||
if (command instanceof HSBType hsbCommand) {
|
||||
setColor(hsbCommand);
|
||||
setBrightness(hsbCommand.getBrightness());
|
||||
} else if (command instanceof OnOffType onOffCommand) {
|
||||
setState(onOffCommand);
|
||||
} else if (command instanceof PercentType percentCommand) {
|
||||
setBrightness(percentCommand);
|
||||
} else if (command instanceof IncreaseDecreaseType) {
|
||||
final TradfriLightData state = this.state;
|
||||
// increase or decrease only the brightness, but keep color
|
||||
|
|
|
@ -75,8 +75,8 @@ public class TradfriPlugHandler extends TradfriThingHandler {
|
|||
|
||||
switch (channelUID.getId()) {
|
||||
case CHANNEL_POWER:
|
||||
if (command instanceof OnOffType) {
|
||||
setState(((OnOffType) command));
|
||||
if (command instanceof OnOffType onOffCommand) {
|
||||
setState(onOffCommand);
|
||||
} else {
|
||||
logger.debug("Cannot handle command '{}' for channel '{}'", command, CHANNEL_POWER);
|
||||
}
|
||||
|
|
|
@ -135,8 +135,8 @@ public class TradfriAirPurifierData extends TradfriDeviceData {
|
|||
public @Nullable State getAirQualityRating() {
|
||||
State pm25State = getAirQualityPM25();
|
||||
if (pm25State != null) {
|
||||
if (pm25State instanceof Number) {
|
||||
int pm25Value = ((Number) pm25State).intValue();
|
||||
if (pm25State instanceof Number number) {
|
||||
int pm25Value = number.intValue();
|
||||
int qualityRating = 1;
|
||||
|
||||
if (pm25Value >= AIR_PURIFIER_AIR_QUALITY_BAD) {
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.io.IOException;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class TwitterHandler extends BaseThingHandler {
|
|||
// creates list of available Actions
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singletonList(TwitterActions.class);
|
||||
return List.of(TwitterActions.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,7 +118,7 @@ public class TwitterHandler extends BaseThingHandler {
|
|||
Twitter localClient = client;
|
||||
if (localClient != null) {
|
||||
ResponseList<Status> statuses = localClient.getUserTimeline();
|
||||
if (statuses.size() > 0) {
|
||||
if (!statuses.isEmpty()) {
|
||||
updateState(CHANNEL_LASTTWEET, StringType.valueOf(statuses.get(0).getText()));
|
||||
} else {
|
||||
logger.debug("No Statuses Found");
|
||||
|
|
|
@ -112,8 +112,8 @@ public class TwitterActions implements ThingActions {
|
|||
|
||||
@Override
|
||||
public void setThingHandler(@Nullable ThingHandler handler) {
|
||||
if (handler instanceof TwitterHandler) {
|
||||
this.handler = (TwitterHandler) handler;
|
||||
if (handler instanceof TwitterHandler twitterHandler) {
|
||||
this.handler = twitterHandler;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -259,8 +259,8 @@ public class UniFiSiteActions implements ThingActions {
|
|||
|
||||
@Override
|
||||
public void setThingHandler(ThingHandler handler) {
|
||||
if (handler instanceof UniFiSiteThingHandler) {
|
||||
this.handler = (UniFiSiteThingHandler) handler;
|
||||
if (handler instanceof UniFiSiteThingHandler siteThingHandler) {
|
||||
this.handler = siteThingHandler;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -206,13 +206,13 @@ class UniFiControllerRequest<T> {
|
|||
} else if (cause instanceof SSLException) {
|
||||
// cannot establish ssl connection
|
||||
throw new UniFiSSLException(cause);
|
||||
} else if (cause instanceof HttpResponseException
|
||||
&& ((HttpResponseException) cause).getResponse() instanceof ContentResponse) {
|
||||
} else if (cause instanceof HttpResponseException httpResponseException
|
||||
&& httpResponseException.getResponse() instanceof ContentResponse) {
|
||||
// the UniFi controller violates the HTTP protocol
|
||||
// - it returns 401 UNAUTHORIZED without the WWW-Authenticate response header
|
||||
// - this causes an ExecutionException to be thrown
|
||||
// - we unwrap the response from the exception for proper handling of the 401 status code
|
||||
response = ((HttpResponseException) cause).getResponse();
|
||||
response = httpResponseException.getResponse();
|
||||
} else {
|
||||
// catch all
|
||||
throw new UniFiException(cause);
|
||||
|
|
|
@ -107,8 +107,10 @@ public class UniFiVoucher implements HasId {
|
|||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
"UniFiVoucher{id: '%s', code: '%s', created: '%s', duration: '%s', quota: '%s', used: '%s', qosUsageQuota: '%s', "
|
||||
+ "qosRateMaxUp: '%s', qosRateMaxDown: '%s', qosOverwrite: '%s', note: '%s', status: '%s', site: %s}",
|
||||
"""
|
||||
UniFiVoucher{id: '%s', code: '%s', created: '%s', duration: '%s', quota: '%s', used: '%s', qosUsageQuota: '%s', \
|
||||
qosRateMaxUp: '%s', qosRateMaxDown: '%s', qosOverwrite: '%s', note: '%s', status: '%s', site: %s}\
|
||||
""",
|
||||
id, code, createTime, duration, quota, used, qosUsageQuota, qosRateMaxUp, qosRateMaxDown, qosOverwrite,
|
||||
note, status, getSite());
|
||||
}
|
||||
|
|
|
@ -245,13 +245,13 @@ public class UniFiClientThingHandler extends UniFiBaseThingHandler<UniFiClient,
|
|||
|
||||
default:
|
||||
// mgb: additional wired client channels
|
||||
if (client.isWired() && (client instanceof UniFiWiredClient)) {
|
||||
state = getWiredChannelState((UniFiWiredClient) client, channelId, state);
|
||||
if (client.isWired() && (client instanceof UniFiWiredClient wiredClient)) {
|
||||
state = getWiredChannelState(wiredClient, channelId, state);
|
||||
}
|
||||
|
||||
// mgb: additional wireless client channels
|
||||
else if (client.isWireless() && (client instanceof UniFiWirelessClient)) {
|
||||
state = getWirelessChannelState((UniFiWirelessClient) client, channelId, state);
|
||||
else if (client.isWireless() && (client instanceof UniFiWirelessClient wirelessClient)) {
|
||||
state = getWirelessChannelState(wirelessClient, channelId, state);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -199,8 +199,8 @@ public class UniFiControllerThingHandler extends BaseBridgeHandler {
|
|||
getThing().getThings().forEach((thing) -> {
|
||||
final ThingHandler handler = thing.getHandler();
|
||||
|
||||
if (handler instanceof UniFiBaseThingHandler) {
|
||||
((UniFiBaseThingHandler<?, ?>) handler).refresh();
|
||||
if (handler instanceof UniFiBaseThingHandler baseThingHandler) {
|
||||
baseThingHandler.refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ package org.openhab.binding.unifi.internal.handler;
|
|||
import static org.openhab.binding.unifi.internal.UniFiBindingConstants.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
|
@ -134,6 +134,6 @@ public class UniFiSiteThingHandler extends UniFiBaseThingHandler<UniFiSite, UniF
|
|||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(UniFiSiteActions.class);
|
||||
return Set.of(UniFiSiteActions.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,8 +76,8 @@ public class UniFiThingDiscoveryService extends AbstractDiscoveryService
|
|||
|
||||
@Override
|
||||
public void setThingHandler(final ThingHandler handler) {
|
||||
if (handler instanceof UniFiControllerThingHandler) {
|
||||
bridgeHandler = (UniFiControllerThingHandler) handler;
|
||||
if (handler instanceof UniFiControllerThingHandler controllerThingHandler) {
|
||||
bridgeHandler = controllerThingHandler;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -135,8 +135,8 @@ public class UniFiWlanThingHandler extends UniFiBaseThingHandler<UniFiWlan, UniF
|
|||
return UnDefType.UNDEF;
|
||||
} else {
|
||||
return new DecimalType(site.getCache().countClients(site,
|
||||
c -> c instanceof UniFiWirelessClient
|
||||
&& (wlan.getName() != null && wlan.getName().equals(((UniFiWirelessClient) c).getEssid()))
|
||||
c -> c instanceof UniFiWirelessClient wirelessClient
|
||||
&& (wlan.getName() != null && wlan.getName().equals(wirelessClient.getEssid()))
|
||||
&& filter.test(c)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
*/
|
||||
package org.openhab.binding.unifiedremote.internal;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
|
@ -31,8 +30,7 @@ public class UnifiedRemoteBindingConstants {
|
|||
|
||||
// List of all Thing Type UIDs
|
||||
public static final ThingTypeUID THING_TYPE_UNIFIED_REMOTE_SERVER = new ThingTypeUID(BINDING_ID, "server");
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections
|
||||
.singleton(THING_TYPE_UNIFIED_REMOTE_SERVER);
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_UNIFIED_REMOTE_SERVER);
|
||||
|
||||
// List of all Channel ids
|
||||
public static final String MOUSE_CHANNEL = "mouse-move";
|
||||
|
|
|
@ -87,16 +87,14 @@ public class UPBController {
|
|||
}
|
||||
|
||||
public void deviceAdded(final ThingHandler childHandler, final Thing childThing) {
|
||||
if (childHandler instanceof UPBThingHandler) {
|
||||
final UPBThingHandler hnd = (UPBThingHandler) childHandler;
|
||||
things.put(mkAddr(hnd.getNetworkId(), hnd.getUnitId()), hnd);
|
||||
if (childHandler instanceof UPBThingHandler upbThingHandler) {
|
||||
things.put(mkAddr(upbThingHandler.getNetworkId(), upbThingHandler.getUnitId()), upbThingHandler);
|
||||
}
|
||||
}
|
||||
|
||||
public void deviceRemoved(final ThingHandler childHandler, final Thing childThing) {
|
||||
if (childHandler instanceof UPBThingHandler) {
|
||||
final UPBThingHandler hnd = (UPBThingHandler) childHandler;
|
||||
things.remove(mkAddr(hnd.getNetworkId(), hnd.getUnitId()), hnd);
|
||||
if (childHandler instanceof UPBThingHandler upbThingHandler) {
|
||||
things.remove(mkAddr(upbThingHandler.getNetworkId(), upbThingHandler.getUnitId()), upbThingHandler);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -144,8 +144,8 @@ public class UPBThingHandler extends BaseThingHandler {
|
|||
message = MessageBuilder.forCommand(ACTIVATE);
|
||||
} else if (cmd == OnOffType.OFF) {
|
||||
message = MessageBuilder.forCommand(DEACTIVATE);
|
||||
} else if (cmd instanceof PercentType) {
|
||||
message = MessageBuilder.forCommand(GOTO).args(((PercentType) cmd).byteValue());
|
||||
} else if (cmd instanceof PercentType percentCommand) {
|
||||
message = MessageBuilder.forCommand(GOTO).args(percentCommand.byteValue());
|
||||
} else if (cmd == RefreshType.REFRESH) {
|
||||
refreshDeviceState();
|
||||
return;
|
||||
|
|
|
@ -52,8 +52,7 @@ public class UpnpDynamicCommandDescriptionProvider implements DynamicCommandDesc
|
|||
@Override
|
||||
public @Nullable CommandDescription getCommandDescription(Channel channel,
|
||||
@Nullable CommandDescription originalCommandDescription, @Nullable Locale locale) {
|
||||
CommandDescription description = descriptions.get(channel.getUID());
|
||||
return description;
|
||||
return descriptions.get(channel.getUID());
|
||||
}
|
||||
|
||||
@Deactivate
|
||||
|
|
|
@ -52,8 +52,7 @@ public class UpnpDynamicStateDescriptionProvider implements DynamicStateDescript
|
|||
@Override
|
||||
public @Nullable StateDescription getStateDescription(Channel channel,
|
||||
@Nullable StateDescription originalStateDescription, @Nullable Locale locale) {
|
||||
StateDescription description = descriptions.get(channel.getUID());
|
||||
return description;
|
||||
return descriptions.get(channel.getUID());
|
||||
}
|
||||
|
||||
@Deactivate
|
||||
|
|
|
@ -333,7 +333,7 @@ public abstract class UpnpHandler extends BaseThingHandler implements UpnpIOPart
|
|||
* Invoke ConnectionComplete on UPnP Connection Manager.
|
||||
*/
|
||||
protected void connectionComplete() {
|
||||
Map<String, String> inputs = Collections.singletonMap(CONNECTION_ID, Integer.toString(connectionId));
|
||||
Map<String, String> inputs = Map.of(CONNECTION_ID, Integer.toString(connectionId));
|
||||
|
||||
invokeAction(CONNECTION_MANAGER, "ConnectionComplete", inputs);
|
||||
}
|
||||
|
@ -367,7 +367,7 @@ public abstract class UpnpHandler extends BaseThingHandler implements UpnpIOPart
|
|||
isRcsIdSet = new CompletableFuture<Boolean>();
|
||||
|
||||
// ConnectionID will default to 0 if not set through prepareForConnection method
|
||||
Map<String, String> inputs = Collections.singletonMap(CONNECTION_ID, Integer.toString(connectionId));
|
||||
Map<String, String> inputs = Map.of(CONNECTION_ID, Integer.toString(connectionId));
|
||||
|
||||
invokeAction(CONNECTION_MANAGER, "GetCurrentConnectionInfo", inputs);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
@ -317,7 +316,7 @@ public class UpnpRendererHandler extends UpnpHandler {
|
|||
// received
|
||||
}
|
||||
|
||||
Map<String, String> inputs = Collections.singletonMap(INSTANCE_ID, Integer.toString(avTransportId));
|
||||
Map<String, String> inputs = Map.of(INSTANCE_ID, Integer.toString(avTransportId));
|
||||
|
||||
invokeAction(AV_TRANSPORT, "Stop", inputs);
|
||||
}
|
||||
|
@ -353,7 +352,7 @@ public class UpnpRendererHandler extends UpnpHandler {
|
|||
* Invoke Pause on UPnP AV Transport.
|
||||
*/
|
||||
protected void pause() {
|
||||
Map<String, String> inputs = Collections.singletonMap(INSTANCE_ID, Integer.toString(avTransportId));
|
||||
Map<String, String> inputs = Map.of(INSTANCE_ID, Integer.toString(avTransportId));
|
||||
|
||||
invokeAction(AV_TRANSPORT, "Pause", inputs);
|
||||
}
|
||||
|
@ -362,7 +361,7 @@ public class UpnpRendererHandler extends UpnpHandler {
|
|||
* Invoke Next on UPnP AV Transport.
|
||||
*/
|
||||
protected void next() {
|
||||
Map<String, String> inputs = Collections.singletonMap(INSTANCE_ID, Integer.toString(avTransportId));
|
||||
Map<String, String> inputs = Map.of(INSTANCE_ID, Integer.toString(avTransportId));
|
||||
|
||||
invokeAction(AV_TRANSPORT, "Next", inputs);
|
||||
}
|
||||
|
@ -371,7 +370,7 @@ public class UpnpRendererHandler extends UpnpHandler {
|
|||
* Invoke Previous on UPnP AV Transport.
|
||||
*/
|
||||
protected void previous() {
|
||||
Map<String, String> inputs = Collections.singletonMap(INSTANCE_ID, Integer.toString(avTransportId));
|
||||
Map<String, String> inputs = Map.of(INSTANCE_ID, Integer.toString(avTransportId));
|
||||
|
||||
invokeAction(AV_TRANSPORT, "Previous", inputs);
|
||||
}
|
||||
|
@ -456,7 +455,7 @@ public class UpnpRendererHandler extends UpnpHandler {
|
|||
* Result is received in {@link #onValueReceived}.
|
||||
*/
|
||||
protected void getTransportState() {
|
||||
Map<String, String> inputs = Collections.singletonMap(INSTANCE_ID, Integer.toString(avTransportId));
|
||||
Map<String, String> inputs = Map.of(INSTANCE_ID, Integer.toString(avTransportId));
|
||||
|
||||
invokeAction(AV_TRANSPORT, "GetTransportInfo", inputs);
|
||||
}
|
||||
|
@ -466,7 +465,7 @@ public class UpnpRendererHandler extends UpnpHandler {
|
|||
* Result is received in {@link #onValueReceived}.
|
||||
*/
|
||||
protected void getPositionInfo() {
|
||||
Map<String, String> inputs = Collections.singletonMap(INSTANCE_ID, Integer.toString(avTransportId));
|
||||
Map<String, String> inputs = Map.of(INSTANCE_ID, Integer.toString(avTransportId));
|
||||
|
||||
invokeAction(AV_TRANSPORT, "GetPositionInfo", inputs);
|
||||
}
|
||||
|
@ -476,7 +475,7 @@ public class UpnpRendererHandler extends UpnpHandler {
|
|||
* Result is received in {@link #onValueReceived}.
|
||||
*/
|
||||
protected void getMediaInfo() {
|
||||
Map<String, String> inputs = Collections.singletonMap(INSTANCE_ID, Integer.toString(avTransportId));
|
||||
Map<String, String> inputs = Map.of(INSTANCE_ID, Integer.toString(avTransportId));
|
||||
|
||||
invokeAction(AV_TRANSPORT, "smarthome:audio stream http://icecast.vrtcdn.be/stubru_tijdloze-high.mp3", inputs);
|
||||
}
|
||||
|
@ -696,24 +695,24 @@ public class UpnpRendererHandler extends UpnpHandler {
|
|||
private void handleCommandVolume(Command command, String id) {
|
||||
if (command instanceof RefreshType) {
|
||||
getVolume("volume".equals(id) ? UPNP_MASTER : id.replace("volume", ""));
|
||||
} else if (command instanceof PercentType) {
|
||||
setVolume("volume".equals(id) ? UPNP_MASTER : id.replace("volume", ""), (PercentType) command);
|
||||
} else if (command instanceof PercentType percentCommand) {
|
||||
setVolume("volume".equals(id) ? UPNP_MASTER : id.replace("volume", ""), percentCommand);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleCommandMute(Command command, String id) {
|
||||
if (command instanceof RefreshType) {
|
||||
getMute("mute".equals(id) ? UPNP_MASTER : id.replace("mute", ""));
|
||||
} else if (command instanceof OnOffType) {
|
||||
setMute("mute".equals(id) ? UPNP_MASTER : id.replace("mute", ""), (OnOffType) command);
|
||||
} else if (command instanceof OnOffType onOffCommand) {
|
||||
setMute("mute".equals(id) ? UPNP_MASTER : id.replace("mute", ""), onOffCommand);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleCommandLoudness(Command command, String id) {
|
||||
if (command instanceof RefreshType) {
|
||||
getLoudness("loudness".equals(id) ? UPNP_MASTER : id.replace("loudness", ""));
|
||||
} else if (command instanceof OnOffType) {
|
||||
setLoudness("loudness".equals(id) ? UPNP_MASTER : id.replace("loudness", ""), (OnOffType) command);
|
||||
} else if (command instanceof OnOffType onOffCommand) {
|
||||
setLoudness("loudness".equals(id) ? UPNP_MASTER : id.replace("loudness", ""), onOffCommand);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -884,8 +883,8 @@ public class UpnpRendererHandler extends UpnpHandler {
|
|||
private void handleCommandTrackPosition(ChannelUID channelUID, Command command) {
|
||||
if (command instanceof RefreshType) {
|
||||
updateState(channelUID, new QuantityType<>(trackPosition, Units.SECOND));
|
||||
} else if (command instanceof QuantityType<?>) {
|
||||
QuantityType<?> position = ((QuantityType<?>) command).toUnit(Units.SECOND);
|
||||
} else if (command instanceof QuantityType<?> quantityCommand) {
|
||||
QuantityType<?> position = quantityCommand.toUnit(Units.SECOND);
|
||||
if (position != null) {
|
||||
int pos = Integer.min(trackDuration, position.intValue());
|
||||
seek(String.format("%02d:%02d:%02d", pos / 3600, (pos % 3600) / 60, pos % 60));
|
||||
|
@ -897,8 +896,8 @@ public class UpnpRendererHandler extends UpnpHandler {
|
|||
if (command instanceof RefreshType) {
|
||||
int relPosition = (trackDuration != 0) ? (trackPosition * 100) / trackDuration : 0;
|
||||
updateState(channelUID, new PercentType(relPosition));
|
||||
} else if (command instanceof PercentType) {
|
||||
int pos = ((PercentType) command).intValue() * trackDuration / 100;
|
||||
} else if (command instanceof PercentType percentCommand) {
|
||||
int pos = percentCommand.intValue() * trackDuration / 100;
|
||||
seek(String.format("%02d:%02d:%02d", pos / 3600, (pos % 3600) / 60, pos % 60));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -321,8 +321,8 @@ public class UpnpServerHandler extends UpnpHandler {
|
|||
private void handleCommandUpnpRenderer(ChannelUID channelUID, Command command) {
|
||||
UpnpRendererHandler renderer = null;
|
||||
UpnpRendererHandler previousRenderer = currentRendererHandler;
|
||||
if (command instanceof StringType) {
|
||||
renderer = (upnpRenderers.get(((StringType) command).toString()));
|
||||
if (command instanceof StringType stringCommand) {
|
||||
renderer = (upnpRenderers.get(stringCommand.toString()));
|
||||
currentRendererHandler = renderer;
|
||||
if (config.filter) {
|
||||
// only refresh title list if filtering by renderer capabilities
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue