Reduce SAT warnings ()

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
Holger Friedrich 2023-06-15 00:02:10 +02:00 committed by GitHub
parent 7ef268f4d2
commit a5c47aebee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 8 additions and 56 deletions
bundles
org.openhab.binding.alarmdecoder/src/main/java/org/openhab/binding/alarmdecoder/internal
org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal
org.openhab.binding.bluetooth.radoneye/src/main/java/org/openhab/binding/bluetooth/radoneye/internal
org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/grxprg
org.openhab.binding.miio
org.openhab.binding.modbus.sunspec/src/main/java/org/openhab/binding/modbus/sunspec/internal
org.openhab.binding.qbus/src/main/java/org/openhab/binding/qbus/internal/protocol
org.openhab.binding.sensorcommunity/src/main/java/org/openhab/binding/sensorcommunity/internal
org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal
org.openhab.binding.solarwatt
org.openhab.binding.sonnen/src/main/java/org/openhab/binding/sonnen/internal
org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema
org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/constants
org.openhab.binding.wundergroundupdatereceiver/src/test/java/org/openhab/binding/wundergroundupdatereceiver/internal
itests/org.openhab.binding.modbus.tests/src/main/java/org/openhab/binding/modbus/tests

@ -85,7 +85,6 @@ public abstract class ADThingHandler extends BaseThingHandler {
if (bridgeStatus == ThingStatus.ONLINE
&& getThing().getStatusInfo().getStatusDetail() == ThingStatusDetail.BRIDGE_OFFLINE) {
initDeviceState();
} else if (bridgeStatus == ThingStatus.OFFLINE) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
}

@ -82,7 +82,6 @@ public class KeypadMessage extends ADMessage {
this.nbeeps = Integer.parseInt(parts.get(0).substring(6, 7));
this.lower = Integer.parseInt(parts.get(0).substring(7, 17), 2);
this.status = ((upper & 0x1F) << 13) | ((nbeeps & 0x3) << 10) | lower;
} catch (NumberFormatException e) {
throw new IllegalArgumentException("keypad msg contains invalid number: " + e.getMessage(), e);
}

@ -488,7 +488,6 @@ public class WebSocketConnection {
sum += toUnsignedInt((data[index] & 0xFF) << ((index & 3 ^ 3) << 3));
overflow += computeBits(sum, 32);
sum = toUnsignedInt((int) sum & (int) 4294967295L);
} else {
index = exclusionEnd - 1;
}

@ -80,10 +80,7 @@ public class RadoneyeDiscoveryParticipant implements BluetoothDiscoveryParticipa
private boolean isRadoneyeDevice(BluetoothDiscoveryDevice device) {
String manufacturerMacId = device.getAddress().toString().toLowerCase().replace(":", "").substring(0, 6);
if (manufacturerMacId.equals(RADONEYE_BLUETOOTH_COMPANY_ID.toLowerCase())) {
return true;
}
return false;
return manufacturerMacId.equals(RADONEYE_BLUETOOTH_COMPANY_ID.toLowerCase());
}
private String getSerial(BluetoothDiscoveryDevice device) {
@ -120,7 +117,6 @@ public class RadoneyeDiscoveryParticipant implements BluetoothDiscoveryParticipa
Map<String, Object> properties = new HashMap<>();
properties.put(BluetoothBindingConstants.CONFIGURATION_ADDRESS, device.getAddress().toString());
properties.put(Thing.PROPERTY_VENDOR, "RadonEye");
String name = device.getName();
String serialNumber = device.getSerialNumber();
String firmwareRevision = device.getFirmwareRevision();
String model = device.getModel();

@ -112,49 +112,42 @@ public class GrafikEyeHandler extends BaseThingHandler {
} else {
logger.error("Received a SCENE command with a non DecimalType: {}", command);
}
} else if (id.equals(PrgConstants.CHANNEL_SCENELOCK)) {
if (command instanceof OnOffType) {
getProtocolHandler().setSceneLock(config.getControlUnit(), command == OnOffType.ON);
} else {
logger.error("Received a SCENELOCK command with a non OnOffType: {}", command);
}
} else if (id.equals(PrgConstants.CHANNEL_SCENESEQ)) {
if (command instanceof OnOffType) {
getProtocolHandler().setSceneSequence(config.getControlUnit(), command == OnOffType.ON);
} else {
logger.error("Received a SCENESEQ command with a non OnOffType: {}", command);
}
} else if (id.equals(PrgConstants.CHANNEL_ZONELOCK)) {
if (command instanceof OnOffType) {
getProtocolHandler().setZoneLock(config.getControlUnit(), command == OnOffType.ON);
} else {
logger.error("Received a ZONELOCK command with a non OnOffType: {}", command);
}
} else if (id.startsWith(PrgConstants.CHANNEL_ZONELOWER)) {
final Integer zone = getTrailingNbr(id, PrgConstants.CHANNEL_ZONELOWER);
if (zone != null) {
getProtocolHandler().setZoneLower(config.getControlUnit(), zone);
}
} else if (id.startsWith(PrgConstants.CHANNEL_ZONERAISE)) {
final Integer zone = getTrailingNbr(id, PrgConstants.CHANNEL_ZONERAISE);
if (zone != null) {
getProtocolHandler().setZoneRaise(config.getControlUnit(), zone);
}
} else if (id.equals(PrgConstants.CHANNEL_ZONEFADE)) {
if (command instanceof DecimalType) {
setFade(((DecimalType) command).intValue());
} else {
logger.error("Received a ZONEFADE command with a non DecimalType: {}", command);
}
} else if (id.startsWith(PrgConstants.CHANNEL_ZONEINTENSITY)) {
final Integer zone = getTrailingNbr(id, PrgConstants.CHANNEL_ZONEINTENSITY);
@ -172,7 +165,6 @@ public class GrafikEyeHandler extends BaseThingHandler {
logger.error("Received a ZONEINTENSITY command with a non DecimalType: {}", command);
}
}
} else if (id.startsWith(PrgConstants.CHANNEL_ZONESHADE)) {
final Integer zone = getTrailingNbr(id, PrgConstants.CHANNEL_ZONESHADE);
@ -190,7 +182,6 @@ public class GrafikEyeHandler extends BaseThingHandler {
logger.error("Received a ZONEINTENSITY command with a non DecimalType: {}", command);
}
}
} else {
logger.error("Unknown/Unsupported Channel id: {}", id);
}
@ -209,7 +200,6 @@ public class GrafikEyeHandler extends BaseThingHandler {
if (id.equals(PrgConstants.CHANNEL_SCENE)) {
getProtocolHandler().refreshScene();
} else if (id.equals(PrgConstants.CHANNEL_ZONEINTENSITY)) {
getProtocolHandler().refreshZoneIntensity(config.getControlUnit());
} else if (id.equals(PrgConstants.CHANNEL_ZONEFADE)) {

@ -162,10 +162,8 @@ public class PrgBridgeHandler extends BaseBridgeHandler {
if (id.equals(PrgConstants.CHANNEL_ZONELOWERSTOP)) {
protocolHandler.setZoneLowerStop();
} else if (id.equals(PrgConstants.CHANNEL_ZONERAISESTOP)) {
protocolHandler.setZoneRaiseStop();
} else if (id.equals(PrgConstants.CHANNEL_TIMECLOCK)) {
if (command instanceof DateTimeType) {
final ZonedDateTime zdt = ((DateTimeType) command).getZonedDateTime();
@ -180,15 +178,12 @@ public class PrgBridgeHandler extends BaseBridgeHandler {
} else {
logger.error("Received a SCHEDULE channel command with a non DecimalType: {}", command);
}
} else if (id.startsWith(PrgConstants.CHANNEL_SUPERSEQUENCESTART)) {
protocolHandler.startSuperSequence();
} else if (id.startsWith(PrgConstants.CHANNEL_SUPERSEQUENCEPAUSE)) {
protocolHandler.pauseSuperSequence();
} else if (id.startsWith(PrgConstants.CHANNEL_SUPERSEQUENCERESUME)) {
protocolHandler.resumeSuperSequence();
} else {
logger.error("Unknown/Unsupported Channel id: {}", id);
}
@ -207,16 +202,12 @@ public class PrgBridgeHandler extends BaseBridgeHandler {
if (id.equals(PrgConstants.CHANNEL_TIMECLOCK)) {
protocolHandler.refreshTime();
} else if (id.equals(PrgConstants.CHANNEL_SCHEDULE)) {
protocolHandler.refreshSchedule();
} else if (id.equals(PrgConstants.CHANNEL_SUNRISE)) {
protocolHandler.refreshSunriseSunset();
} else if (id.equals(PrgConstants.CHANNEL_SUNSET)) {
protocolHandler.refreshSunriseSunset();
} else if (id.equals(PrgConstants.CHANNEL_SUPERSEQUENCESTATUS)) {
protocolHandler.reportSuperSequenceStatus();
} else if (id.equals(PrgConstants.CHANNEL_SUPERSEQUENCENEXTSTEP)) {
@ -277,7 +268,6 @@ public class PrgBridgeHandler extends BaseBridgeHandler {
return;
}
}
} catch (Exception e) {
logger.error("Exception during connection attempt", e);
}

@ -109,6 +109,7 @@ However, many devices share large similarities with existing devices.
The binding allows to try/test if your new device is working with database files of older devices as well.
There are 3 ways to get unsupported devices working:
- by overriding the model with the model of a similar supported device. E.g. this works great for roborock vacuum devices and yeelight devices). See [Substitute model for unsupported devices](#substitute-model-for-unsupported-devices)
- by switching on the `(experimental) Create channels for new/unsupported devices (MIOT protocol)` channel, this works for most newer devices. See [Create support for new devices based on online published spec database](#create-support-for-new-devices-based-on-online-published-spec-database)
- by switching on the `(experimental) Create channels / test properties for unsupported devices (legacy protocol)` channel. This works for older / legacy devices. It test all known properties to see which are supported by your device. See [Supported property test for unsupported devices](#supported-property-test-for-unsupported-devices)

@ -109,6 +109,7 @@ However, many devices share large similarities with existing devices.
The binding allows to try/test if your new device is working with database files of older devices as well.
There are 3 ways to get unsupported devices working:
- by overriding the model with the model of a similar supported device. E.g. this works great for roborock vacuum devices and yeelight devices). See [Substitute model for unsupported devices](#substitute-model-for-unsupported-devices)
- by switching on the `(experimental) Create channels for new/unsupported devices (MIOT protocol)` channel, this works for most newer devices. See [Create support for new devices based on online published spec database](#create-support-for-new-devices-based-on-online-published-spec-database)
- by switching on the `(experimental) Create channels / test properties for unsupported devices (legacy protocol)` channel. This works for older / legacy devices. It test all known properties to see which are supported by your device. See [Supported property test for unsupported devices](#supported-property-test-for-unsupported-devices)

@ -146,7 +146,6 @@ public class SunspecDiscoveryProcess {
* @throws EndpointNotInitializedException
*/
public void detectModel() {
if (possibleAddresses.isEmpty()) {
parsingFinished();
return;
@ -189,7 +188,6 @@ public class SunspecDiscoveryProcess {
* Look for a valid model block at the current base address
*/
private void lookForModelBlock() {
ModbusReadRequestBlueprint request = new ModbusReadRequestBlueprint(slaveId,
ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS, baseAddress, // Start address
MODEL_HEADER_SIZE, // number or words to return
@ -233,7 +231,6 @@ public class SunspecDiscoveryProcess {
createDiscoveryResult(block);
lookForModelBlock();
}
}
}

@ -129,7 +129,6 @@ public abstract class AbstractSunSpecHandler extends BaseThingHandler {
* Start the periodic polling
*/
private void startUp() {
connectEndpoint();
if (comms == null || config == null) {

@ -38,7 +38,6 @@ public class CommonModelParser extends AbstractBaseParser implements SunspecPars
@Override
public CommonModelBlock parse(ModbusRegisterArray raw) {
CommonModelBlock block = new CommonModelBlock();
block.sunSpecDID = extractUInt16(raw, 0, 0);

@ -92,7 +92,6 @@ class QbusMessageDeserializer implements JsonDeserializer<QbusMessageBase> {
if (jsonObject.has("outputs")) {
jsonOutputs = jsonObject.get("outputs");
}
if (ctd != null && cmd != null) {
@ -115,7 +114,6 @@ class QbusMessageDeserializer implements JsonDeserializer<QbusMessageBase> {
}
((QbusMessageListMap) message).setOutputs(outputsList);
}
} else {
message = new QbusMessageMap();
@ -145,7 +143,6 @@ class QbusMessageDeserializer implements JsonDeserializer<QbusMessageBase> {
if (setpoint != null) {
message.setSetPoint(setpoint);
}
}
}
return message;

@ -108,7 +108,6 @@ public class HTTPHandler {
latestTime = iterTime;
latestData = iterData;
} // else - found item is older - nothing to do
} else {
logger.warn("One or two dates cannot be decoded 1) {} 2) {}", iterTimeStr, latestTimeStr);
}

@ -35,7 +35,6 @@ public class DateTimeUtils {
public static synchronized @Nullable LocalDateTime toDate(String dateTime) {
try {
return LocalDateTime.from(DTF.parse(dateTime));
} catch (DateTimeParseException e) {
LOGGER.debug("Unable to parse date {}", dateTime);
return null;

@ -289,7 +289,6 @@ public class Shelly2ApiClient extends ShellyHttpClient {
return false;
}
boolean updated = false;
ShellySettingsMeter sm = new ShellySettingsMeter();
ShellySettingsEMeter emeter = status.emeters.get(0);
sm.isValid = emeter.isValid = true;

@ -145,9 +145,6 @@ public class ShellyDiscoveryParticipant implements MDNSDiscoveryParticipant {
try {
ShellyApiInterface api = gen2 ? new Shelly2ApiRpc(name, config, httpClient)
: new Shelly1HttpApi(name, config, httpClient);
if (name.contains("plus1pm")) {
int i = 1;
}
api.initialize();
profile = api.getDeviceProfile(thingType);
api.close();

@ -5,9 +5,11 @@ Binding to query a [solarwatt](https://www.solarwatt.de/) [energy manager](https
All supported values and devices were discovered while playing with my own energy manager.
## Supported devices
* Solarwatt Energymanager; ie. the DIN rail mounted device in your house distribution.
## Not supported by this binding
* Solarwatt Manager/Manager Flex; ie. the black square device that is wall mounted.
The Solarwatt Manager already contains an OpenHAB installation which can be connected to

@ -289,6 +289,7 @@ public class SonnenHandler extends BaseThingHandler {
}
}
@SuppressWarnings("PMD.SimplifyBooleanReturns")
private boolean arePowerMeterChannelsLinked() {
if (isLinked(CHANNELENERGYIMPORTEDSTATEPRODUCTION)) {
return true;

@ -135,7 +135,6 @@ public class ApiPageParser extends AbstractSimpleMarkupHandler {
public void handleStandaloneElement(final @Nullable String elementName,
final @Nullable Map<String, String> attributes, final boolean minimized, final int line, final int col)
throws ParseException {
logger.debug("Unexpected StandaloneElement in {}:{}: {} [{}]", line, col, elementName, attributes);
}
@ -143,7 +142,6 @@ public class ApiPageParser extends AbstractSimpleMarkupHandler {
@NonNullByDefault({})
public void handleOpenElement(final @Nullable String elementName, final @Nullable Map<String, String> attributes,
final int line, final int col) throws ParseException {
if (this.parserState == ParserState.INIT && "div".equals(elementName)) {
this.parserState = ParserState.DATA_ENTRY;
String classFlags;
@ -272,7 +270,6 @@ public class ApiPageParser extends AbstractSimpleMarkupHandler {
@Override
public void handleText(final char @Nullable [] buffer, final int offset, final int len, final int line,
final int col) throws ParseException {
if (buffer == null) {
return;
}

@ -77,7 +77,6 @@ public class ChangerX2Parser extends AbstractSimpleMarkupHandler {
@NonNullByDefault({})
public void handleStandaloneElement(final String elementName, final Map<String, String> attributes,
final boolean minimized, final int line, final int col) throws ParseException {
logger.debug("Error parsing options for {}: Unexpected StandaloneElement in {}{}: {} [{}]", channelName, line,
col, elementName, attributes);
}
@ -86,7 +85,6 @@ public class ChangerX2Parser extends AbstractSimpleMarkupHandler {
@NonNullByDefault({})
public void handleOpenElement(final String elementName, final Map<String, String> attributes, final int line,
final int col) throws ParseException {
String id = attributes == null ? null : attributes.get("id");
if (this.parserState == ParserState.INIT && "input".equals(elementName) && "changeadr".equals(id)) {
@ -206,7 +204,6 @@ public class ChangerX2Parser extends AbstractSimpleMarkupHandler {
@Override
public void handleText(final char @Nullable [] buffer, final int offset, final int len, final int line,
final int col) throws ParseException {
if (buffer == null) {
return;
}

@ -111,8 +111,9 @@ public enum TapoErrorCode {
public static TapoErrorCode fromCode(int errorCode) {
for (TapoErrorCode e : TapoErrorCode.values()) {
if (e.code.equals(errorCode))
if (e.code.equals(errorCode)) {
return e;
}
}
return ERR_UNKNOWN;
}

@ -54,7 +54,6 @@ import org.openhab.core.thing.type.ChannelKind;
import org.openhab.core.thing.type.ChannelTypeProvider;
import org.openhab.core.thing.type.ChannelTypeRegistry;
import org.openhab.core.thing.type.ChannelTypeUID;
import org.osgi.service.http.HttpService;
import org.osgi.service.http.NamespaceException;
/**
@ -88,7 +87,6 @@ class WundergroundUpdateReceiverDiscoveryServiceTest {
TestChannelTypeRegistry channelTypeRegistry = new TestChannelTypeRegistry();
WundergroundUpdateReceiverDiscoveryService discoveryService = new WundergroundUpdateReceiverDiscoveryService(
true);
HttpService httpService = mock(HttpService.class);
WundergroundUpdateReceiverServlet sut = new WundergroundUpdateReceiverServlet(discoveryService);
discoveryService.addUnhandledStationId(REQ_STATION_ID, sut.normalizeParameterMap(req.getParameterMap()));
Thing thing = ThingBuilder.create(SUPPORTED_THING_TYPES_UIDS.stream().findFirst().get(), TEST_THING_UID)
@ -179,7 +177,6 @@ class WundergroundUpdateReceiverDiscoveryServiceTest {
TestChannelTypeRegistry channelTypeRegistry = new TestChannelTypeRegistry();
WundergroundUpdateReceiverDiscoveryService discoveryService = new WundergroundUpdateReceiverDiscoveryService(
false);
HttpService httpService = mock(HttpService.class);
WundergroundUpdateReceiverServlet sut = new WundergroundUpdateReceiverServlet(discoveryService);
discoveryService.addUnhandledStationId(REQ_STATION_ID, sut.normalizeParameterMap(req.getParameterMap()));
Thing thing = ThingBuilder.create(SUPPORTED_THING_TYPES_UIDS.stream().findFirst().get(), TEST_THING_UID)
@ -225,7 +222,6 @@ class WundergroundUpdateReceiverDiscoveryServiceTest {
TestChannelTypeRegistry channelTypeRegistry = new TestChannelTypeRegistry();
WundergroundUpdateReceiverDiscoveryService discoveryService = new WundergroundUpdateReceiverDiscoveryService(
true);
HttpService httpService = mock(HttpService.class);
WundergroundUpdateReceiverServlet sut = new WundergroundUpdateReceiverServlet(discoveryService);
discoveryService.addUnhandledStationId(REQ_STATION_ID, sut.normalizeParameterMap(req1.getParameterMap()));
Thing thing = ThingBuilder.create(SUPPORTED_THING_TYPES_UIDS.stream().findFirst().get(), TEST_THING_UID)
@ -292,7 +288,6 @@ class WundergroundUpdateReceiverDiscoveryServiceTest {
TestChannelTypeRegistry channelTypeRegistry = new TestChannelTypeRegistry();
WundergroundUpdateReceiverDiscoveryService discoveryService = new WundergroundUpdateReceiverDiscoveryService(
true);
HttpService httpService = mock(HttpService.class);
WundergroundUpdateReceiverServlet sut = new WundergroundUpdateReceiverServlet(discoveryService);
discoveryService.addUnhandledStationId(REQ_STATION_ID, sut.normalizeParameterMap(req1.getParameterMap()));
Thing thing = ThingBuilder.create(SUPPORTED_THING_TYPES_UIDS.stream().findFirst().get(), TEST_THING_UID)
@ -356,7 +351,6 @@ class WundergroundUpdateReceiverDiscoveryServiceTest {
UpdatingChannelTypeRegistry channelTypeRegistry = new UpdatingChannelTypeRegistry();
WundergroundUpdateReceiverDiscoveryService discoveryService = new WundergroundUpdateReceiverDiscoveryService(
true);
HttpService httpService = mock(HttpService.class);
WundergroundUpdateReceiverServlet sut = new WundergroundUpdateReceiverServlet(discoveryService);
discoveryService.addUnhandledStationId(REQ_STATION_ID, sut.normalizeParameterMap(req1.getParameterMap()));
Thing thing = ThingBuilder.create(SUPPORTED_THING_TYPES_UIDS.stream().findFirst().get(), TEST_THING_UID)

@ -789,7 +789,6 @@ public class ModbusPollerThingHandlerTest extends AbstractModbusOSGiTest {
@Test
public void testRefreshWithOldPreviousData() throws IllegalArgumentException, IllegalAccessException,
NoSuchFieldException, SecurityException, InterruptedException {
Configuration pollerConfig = new Configuration();
pollerConfig.put("refresh", 0L);
pollerConfig.put("start", 5);