Skip to content

Commit

Permalink
Applied spotless and removed other SAT warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Hilbrand Bouwkamp <[email protected]>
  • Loading branch information
Hilbrand committed Dec 9, 2019
1 parent cb0939b commit 9012897
Show file tree
Hide file tree
Showing 25 changed files with 115 additions and 99 deletions.
3 changes: 2 additions & 1 deletion bundles/org.openhab.binding.dsmr/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

Expand Down
12 changes: 6 additions & 6 deletions bundles/org.openhab.binding.dsmr/src/main/feature/feature.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.dsmr-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${project.version}/xml/features</repository>
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${project.version}/xml/features</repository>

<feature name="openhab-binding-dsmr" description="DSMR Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<feature>openhab-transport-serial</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.dsmr/${project.version}</bundle>
</feature>
<feature name="openhab-binding-dsmr" description="DSMR Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<feature>openhab-transport-serial</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.dsmr/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ public class DSMRSerialAutoDevice implements DSMRDevice, DSMREventListener {
* Enum to keep track of the internal state of {@link DSMRSerialAutoDevice}.
*/
enum DeviceState {
/**
* Discovers the settings of the serial port.
*/
DISCOVER_SETTINGS,
/**
* Device is receiving telegram data from the serial port.
*/
NORMAL,
/**
* Communication with serial port isn't working.
*/
ERROR
/**
* Discovers the settings of the serial port.
*/
DISCOVER_SETTINGS,
/**
* Device is receiving telegram data from the serial port.
*/
NORMAL,
/**
* Communication with serial port isn't working.
*/
ERROR
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,24 @@ public class P1Telegram {
* The TelegramState described the meta data of the P1Telegram
*/
public enum TelegramState {
/**
* OK. Telegram was successful received and CRC16 checksum is verified (CRC16 only for DSMR V4 and up)
*/
OK("P1 telegram received OK"),
/**
* CRC_ERROR. CRC16 checksum failed (only DSMR V4 and up)
*/
CRC_ERROR("CRC checksum failed for received P1 telegram"),
/**
* DATA_CORRUPTION. The P1 telegram has syntax errors.
*/
DATA_CORRUPTION("Received P1 telegram is corrupted"),
/**
* P1TelegramListener. The smarty telegram was successful received but could not be decoded because of an invalid
* encryption key.
*/
INVALID_ENCRYPTION_KEY("Failed to decrypt P1 telegram due to invalid encryption key");
/**
* OK. Telegram was successful received and CRC16 checksum is verified (CRC16 only for DSMR V4 and up)
*/
OK("P1 telegram received OK"),
/**
* CRC_ERROR. CRC16 checksum failed (only DSMR V4 and up)
*/
CRC_ERROR("CRC checksum failed for received P1 telegram"),
/**
* DATA_CORRUPTION. The P1 telegram has syntax errors.
*/
DATA_CORRUPTION("Received P1 telegram is corrupted"),
/**
* P1TelegramListener. The smarty telegram was successful received but could not be decoded because of an
* invalid
* encryption key.
*/
INVALID_ENCRYPTION_KEY("Failed to decrypt P1 telegram due to invalid encryption key");

/**
* public accessible state details
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ public class P1TelegramParser implements TelegramParser {
* State of the parser
*/
private enum State {
/** Wait for the '/' character */
WAIT_FOR_START,
/** '/' character seen */
HEADER,
/** Waiting for the header to end with a CR & LF */
CRLF,
/** Handling OBIS Identifier */
DATA_OBIS_ID,
/** Parsing OBIS value */
DATA_OBIS_VALUE,
/** OBIS value end seen ')' */
DATA_OBIS_VALUE_END,
/** Parsing CRC value following '!' */
CRC_VALUE
/** Wait for the '/' character */
WAIT_FOR_START,
/** '/' character seen */
HEADER,
/** Waiting for the header to end with a CR & LF */
CRLF,
/** Handling OBIS Identifier */
DATA_OBIS_ID,
/** Parsing OBIS value */
DATA_OBIS_VALUE,
/** OBIS value end seen ')' */
DATA_OBIS_VALUE_END,
/** Parsing CRC value following '!' */
CRC_VALUE
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,36 +82,36 @@ public void telegramReceived(P1Telegram telegram) {
logger.debug("Detect meters from #{} objects", telegram.getCosemObjects().size());
}
final Entry<Collection<DSMRMeterDescriptor>, Map<CosemObjectType, CosemObject>> detectedMeters = meterDetector
.detectMeters(telegram);
.detectMeters(telegram);
verifyUnregisteredCosemObjects(telegram, detectedMeters.getValue());
validateConfiguredMeters(dsmrBridgeHandler.getThing().getThings(),
detectedMeters.getKey().stream().map(md -> md.getMeterType()).collect(Collectors.toSet()));
detectedMeters.getKey().stream().map(md -> md.getMeterType()).collect(Collectors.toSet()));
detectedMeters.getKey().forEach(m -> meterDiscovered(m, dsmrBridgeHandler.getThing().getUID()));
}

protected void verifyUnregisteredCosemObjects(P1Telegram telegram,
Map<CosemObjectType, CosemObject> undetectedCosemObjects) {
Map<CosemObjectType, CosemObject> undetectedCosemObjects) {
if (!undetectedCosemObjects.isEmpty()) {
if (undetectedCosemObjects.entrySet().stream()
.anyMatch(e -> e.getKey() == CosemObjectType.METER_EQUIPMENT_IDENTIFIER
&& e.getValue().getCosemValues().entrySet().stream()
.anyMatch(cv -> cv.getValue() instanceof StringType && cv.getValue().toString().isEmpty()))) {
.anyMatch(e -> e.getKey() == CosemObjectType.METER_EQUIPMENT_IDENTIFIER
&& e.getValue().getCosemValues().entrySet().stream().anyMatch(
cv -> cv.getValue() instanceof StringType && cv.getValue().toString().isEmpty()))) {
// Unregistered meter detected. log to the user.
reportUnregisteredMeters();
} else {
reportUnrecognizedCosemObjects(undetectedCosemObjects);
logger.info("There are unrecognized cosem values in the data received from the meter,"
+ " which means some meters might not be detected. Please report your raw data as reference: {}",
telegram.getRawTelegram());
+ " which means some meters might not be detected. Please report your raw data as reference: {}",
telegram.getRawTelegram());
}
}
if (!telegram.getUnknownCosemObjects().isEmpty()) {
logger.info("There are unrecognized cosem values in the data received from the meter,"
+ " which means you have values that can't be read by a channel: {}. Please report them and your raw data as reference: {}",
telegram.getUnknownCosemObjects().stream()
.map(e -> String.format("obis id:{}, value:{}", e.getKey(), e.getValue()))
.collect(Collectors.joining(", ")),
telegram.getRawTelegram());
+ " which means you have values that can't be read by a channel: {}. Please report them and your raw data as reference: {}",
telegram.getUnknownCosemObjects().stream()
.map(e -> String.format("obis id:{}, value:{}", e.getKey(), e.getValue()))
.collect(Collectors.joining(", ")),
telegram.getRawTelegram());
}
}

Expand All @@ -122,15 +122,15 @@ protected void verifyUnregisteredCosemObjects(P1Telegram telegram,
*/
protected void reportUnrecognizedCosemObjects(Map<CosemObjectType, CosemObject> unidentifiedCosemObjects) {
unidentifiedCosemObjects
.forEach((k, v) -> logger.info("Unrecognized cosem object '{}' found in the data: {}", k, v));
.forEach((k, v) -> logger.info("Unrecognized cosem object '{}' found in the data: {}", k, v));
}

/**
* Called when a meter equipment identifier is found that has an empty value. This
*/
protected void reportUnregisteredMeters() {
logger.info(
"An unregistered meter has been found. Probably a new meter. Retry discovery once the meter is registered with the energy provider.");
"An unregistered meter has been found. Probably a new meter. Retry discovery once the meter is registered with the energy provider.");
}

/**
Expand All @@ -155,10 +155,10 @@ private void validateConfiguredMeters(List<Thing> things, Set<DSMRMeterType> con
// Create list of all configured meters that are not in the detected list. If not empty meters might not be
// correctly configured.
final List<DSMRMeterType> invalidConfigured = configuredMeters.stream()
.filter(dm -> !configuredMeterTypes.contains(dm)).collect(Collectors.toList());
.filter(dm -> !configuredMeterTypes.contains(dm)).collect(Collectors.toList());
// Create a list of all detected meters not yet configured.
final List<DSMRMeterType> unconfiguredMeters = configuredMeterTypes.stream()
.filter(dm -> !configuredMeters.contains(dm)).collect(Collectors.toList());
.filter(dm -> !configuredMeters.contains(dm)).collect(Collectors.toList());

if (!invalidConfigured.isEmpty()) {
reportConfigurationValidationResults(invalidConfigured, unconfiguredMeters);
Expand All @@ -172,12 +172,12 @@ private void validateConfiguredMeters(List<Thing> things, Set<DSMRMeterType> con
* @param unconfiguredMeters The list of meters that were detected, but not configured
*/
protected void reportConfigurationValidationResults(List<DSMRMeterType> invalidConfigured,
List<DSMRMeterType> unconfiguredMeters) {
List<DSMRMeterType> unconfiguredMeters) {
logger.info(
"Possible incorrect meters configured. These are configured: {}."
+ "But the following unconfigured meters are found in the data received from the meter: {}",
invalidConfigured.stream().map(m -> m.name()).collect(Collectors.joining(", ")),
unconfiguredMeters.stream().map(m -> m.name()).collect(Collectors.joining(", ")));
"Possible incorrect meters configured. These are configured: {}."
+ "But the following unconfigured meters are found in the data received from the meter: {}",
invalidConfigured.stream().map(m -> m.name()).collect(Collectors.joining(", ")),
unconfiguredMeters.stream().map(m -> m.name()).collect(Collectors.joining(", ")));
}

public void setLocaleProvider(final LocaleProvider localeProvider) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<binding:binding id="dsmr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:binding="https://openhab.org/schemas/binding/v1.0.0"
<binding:binding id="dsmr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:binding="https://openhab.org/schemas/binding/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/binding/v1.0.0 https://openhab.org/schemas/binding-1.0.0.xsd">

<name>DSMR Binding</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="dsmr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<thing:thing-descriptions bindingId="dsmr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,15 @@
<channel-type id="powerFailureLogEndType" advanced="true">
<item-type>DateTime</item-type>
<label>Power Failure End</label>
<description>Timestamp when the power failure ended. There can be multiple log entries.
Each entry has its own channel (emeter_power_failure_log_timestamp*x*, *x* = 0 - 9)</description>
<description>Timestamp when the power failure ended. There can be multiple log entries.
Each entry has its own channel (emeter_power_failure_log_timestamp*x*, *x* = 0 - 9)</description>
<state readOnly="true" />
</channel-type>
<channel-type id="powerFailureLogDurationType" advanced="true">
<item-type>Number:Time</item-type>
<label>Power Failure Duration</label>
<description>Duration of the power failure.
Each entry has its own channel (emeter_power_failure_log_duration*x*, *x* = 0 - 9)</description>
<description>Duration of the power failure.
Each entry has its own channel (emeter_power_failure_log_duration*x*, *x* = 0 - 9)</description>
<state pattern="%.0f %unit%" readOnly="true" />
</channel-type>
<channel-type id="voltageSagsL1Type" advanced="true">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="dsmr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<thing:thing-descriptions bindingId="dsmr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="dsmr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<thing:thing-descriptions bindingId="dsmr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="dsmr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<thing:thing-descriptions bindingId="dsmr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="dsmr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<thing:thing-descriptions bindingId="dsmr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="dsmr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<thing:thing-descriptions bindingId="dsmr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="dsmr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<thing:thing-descriptions bindingId="dsmr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="dsmr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<thing:thing-descriptions bindingId="dsmr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="dsmr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<thing:thing-descriptions bindingId="dsmr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<thing-type id="device_v4" listed="false">
<supported-bridge-type-refs>
<bridge-type-ref id="dsmrBridge" />
<bridge-type-ref id="smartyBridge"/>
<bridge-type-ref id="smartyBridge" />
</supported-bridge-type-refs>

<label>Device Meter (DSMR V4.x)</label>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="dsmr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<thing:thing-descriptions bindingId="dsmr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="dsmr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<thing:thing-descriptions bindingId="dsmr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="dsmr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<thing:thing-descriptions bindingId="dsmr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="dsmr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<thing:thing-descriptions bindingId="dsmr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="dsmr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<thing:thing-descriptions bindingId="dsmr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

Expand Down
Loading

0 comments on commit 9012897

Please sign in to comment.