diff --git a/src/main/java/cz/smarteon/loxone/message/LoxoneMessageCommand.java b/src/main/java/cz/smarteon/loxone/message/LoxoneMessageCommand.java index b00aed24..7798c588 100644 --- a/src/main/java/cz/smarteon/loxone/message/LoxoneMessageCommand.java +++ b/src/main/java/cz/smarteon/loxone/message/LoxoneMessageCommand.java @@ -247,6 +247,16 @@ public static LoxoneMessageCommand oneWireDetails(final @NotNull OneWireDetails.class, MiniserverType.KNOWN); } + /** + * Get 1-wire details of MultiExtensionAir by given extension serial number. + * @param extensionSerial serial number of MultiExtensionAir extension + * @return command requesting 1-wire details + */ + public static LoxoneMessageCommand multiExtensionAirOneWireDetails(final @NotNull String extensionSerial) { + return jsonCommand("jdev/sys/wsdevice/" + requireNonNull(extensionSerial, "extensionSerial can't be null") + "/Statistics", + OneWireDetails.class, MiniserverType.KNOWN); + } + private static LoxoneMessageCommand jsonCommand( final String command, final Class valueType, final MiniserverType[] supportedMiniservers) { return new LoxoneMessageCommand<>(command, Type.JSON, valueType, true, true, supportedMiniservers); diff --git a/src/main/java/cz/smarteon/loxone/message/OneWireDetails.java b/src/main/java/cz/smarteon/loxone/message/OneWireDetails.java index 11ecd45d..45c1d7a2 100644 --- a/src/main/java/cz/smarteon/loxone/message/OneWireDetails.java +++ b/src/main/java/cz/smarteon/loxone/message/OneWireDetails.java @@ -161,7 +161,7 @@ public int hashCode() { public static class Deserializer extends JsonDeserializer { private static final Pattern ONE_WIRE_DETAIL_PATTERN = Pattern.compile( - "^1-Wire\\s+Serial\\s+([0-9A-F.]+):\\s+(\\d+)\\s+Packet Requests," + "^(?:1-Wire\\s+)?Serial\\s+([0-9A-F.]+):\\s+(\\d+)\\s+Packet Requests," + "\\s+(\\d+)\\s+CRC Errors,\\s+(\\d+)\\s+85 Degree Problems$"); @Override public OneWireDetails deserialize( diff --git a/src/main/java/cz/smarteon/loxone/system/status/Device.java b/src/main/java/cz/smarteon/loxone/system/status/Device.java index 5895fbf9..d5a377b8 100644 --- a/src/main/java/cz/smarteon/loxone/system/status/Device.java +++ b/src/main/java/cz/smarteon/loxone/system/status/Device.java @@ -37,4 +37,18 @@ public String getName() { public String getSerialNumber() { return serialNumber; } + + /** + * Serial number transformed for use with 'wsdevice' commands. + * @return serial number for 'wsdevice' commands. + * @see cz.smarteon.loxone.message.LoxoneMessageCommand#oneWireDetails(String) + */ + @Nullable + public String getSerialForCommands() { + if (getSerialNumber() != null) { + return getSerialNumber().replaceAll(":", ""); + } else { + return null; + } + } } diff --git a/src/main/java/cz/smarteon/loxone/system/status/MultiExtensionAir.java b/src/main/java/cz/smarteon/loxone/system/status/MultiExtensionAir.java index 111d18da..ca7527f2 100644 --- a/src/main/java/cz/smarteon/loxone/system/status/MultiExtensionAir.java +++ b/src/main/java/cz/smarteon/loxone/system/status/MultiExtensionAir.java @@ -23,12 +23,13 @@ public List getDevices() { /** * Serial number transformed to the form for getting one wire details. * @return serial number for one wire details command. - * @see cz.smarteon.loxone.message.LoxoneMessageCommand#oneWireDetails(String) + * @see cz.smarteon.loxone.message.LoxoneMessageCommand#multiExtensionAirOneWireDetails(String) */ @NotNull public String getSerialForOneWireDetails() { - if (getSerialNumber() != null) { - return getSerialNumber().replaceAll(":", "").substring(8).toLowerCase(); + final String serial = getSerialForCommands(); + if (serial != null) { + return serial; } else { throw new IllegalStateException("MultiExtensionAir must have set serial number"); } diff --git a/src/test/kotlin/system/status/MiniserverStatusTest.kt b/src/test/kotlin/system/status/MiniserverStatusTest.kt index 5dc430b4..6b3c222f 100644 --- a/src/test/kotlin/system/status/MiniserverStatusTest.kt +++ b/src/test/kotlin/system/status/MiniserverStatusTest.kt @@ -91,7 +91,7 @@ class MiniserverStatusTest { expectThat(airBaseExtensions[0].devices[2] as MultiExtensionAir) { get { devices }.hasSize(3) - get { serialForOneWireDetails }.isEqualTo("fe894bc6") + get { serialForOneWireDetails }.isEqualTo("504F94FFFE894BC6") } val treeExtensions = ms.getExtensions(TreeExtension::class.java) diff --git a/src/test/resources/message/oneWireDetails.json b/src/test/resources/message/oneWireDetails.json index 161fd08a..9f0c0eca 100644 --- a/src/test/resources/message/oneWireDetails.json +++ b/src/test/resources/message/oneWireDetails.json @@ -1,3 +1,3 @@ " 1-Wire Serial 28.BB.CE.AD.07.00.00.2F: 2709 Packet Requests, 0 CRC Errors, 0 85 Degree Problems; -1-Wire Serial 28.62.A9.AC.0A.00.00.A2: 13 Packet Requests, 1230000 CRC Errors, 5 85 Degree Problems; " \ No newline at end of file +Serial 28.62.A9.AC.0A.00.00.A2: 13 Packet Requests, 1230000 CRC Errors, 5 85 Degree Problems; "