mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-25 11:45:49 +01:00
Fix parsing of mac address in SDDP Discovery (#4284)
* Fix SDDP mac address Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
This commit is contained in:
parent
d2489bb65e
commit
425d0f43f2
@ -35,8 +35,8 @@ public class SddpDevice {
|
||||
|
||||
/**
|
||||
* The host address of the device.
|
||||
* For example: JVC_PROJECTOR-E0DADC152802
|
||||
* Note: the last 12 characters represent the MAC address of the device.
|
||||
* For example: JVC_PROJECTOR-E0DADC152802 or JVC_PROJECTOR-E0:DA:DC:15:28:02
|
||||
* Note: the last 12 resp. 17 characters represent the MAC address of the device.
|
||||
*/
|
||||
public final String host;
|
||||
|
||||
@ -131,7 +131,7 @@ public class SddpDevice {
|
||||
|
||||
String[] hostParts = host.split("-|_");
|
||||
macAddress = hostParts.length <= 1 ? ""
|
||||
: hostParts[hostParts.length - 1].replaceAll("(..)(?!$)", "$1-").toLowerCase();
|
||||
: hostParts[hostParts.length - 1].replace(":", "").replaceAll("(..)(?!$)", "$1-").toLowerCase();
|
||||
|
||||
expireInstant = offline ? Instant.now().minusMillis(1)
|
||||
: Instant.now().plusSeconds(maxAge.isBlank() ? 0 : Integer.parseInt(maxAge));
|
||||
|
@ -57,7 +57,7 @@ public class SddpDiscoveryServiceTests {
|
||||
private static final String IDENTIFY_NOTIFICATION = """
|
||||
NOTIFY IDENTIFY SDDP/1.0
|
||||
From: "192.168.4.237:1902"
|
||||
Host: "JVC_PROJECTOR-E0DADC152802"
|
||||
Host: "JVC_PROJECTOR-E0:DA:DC:15:28:02"
|
||||
Type: "JVCKENWOOD:Projector"
|
||||
Primary-Proxy: "projector"
|
||||
Proxies: "projector"
|
||||
@ -136,7 +136,7 @@ public class SddpDiscoveryServiceTests {
|
||||
SddpDevice device = deviceOptional.orElse(null);
|
||||
assertNotNull(device);
|
||||
assertEquals("192.168.4.237:1902", device.from);
|
||||
assertEquals("JVC_PROJECTOR-E0DADC152802", device.host);
|
||||
assertEquals("JVC_PROJECTOR-E0:DA:DC:15:28:02", device.host);
|
||||
assertTrue(device.maxAge.isBlank());
|
||||
assertEquals("JVCKENWOOD:Projector", device.type);
|
||||
assertEquals("projector", device.primaryProxy);
|
||||
|
Loading…
Reference in New Issue
Block a user