I think this was more changes than what was needed. I happened to have to resolve this locally before I knew about this PR, and all I did was:
.../binding/shelly/internal/api1/Shelly1CoapHandler.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api1/Shelly1CoapHandler.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api1/Shelly1CoapHandler.java
index 6998bd2197..59f662cd32 100644
--- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api1/Shelly1CoapHandler.java
+++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api1/Shelly1CoapHandler.java
@@ -187,7 +187,7 @@ public class Shelly1CoapHandler implements Shelly1CoapListener {
// We can't identify device by IP, so we need to check the CoAP header's Global Device ID
for (Option opt : options) {
if (opt.getNumber() == COIOT_OPTION_GLOBAL_DEVID) {
- String devid = opt.getStringValue();
+ String devid = opt.toValueString();
if (devid.contains("#") && profile.device.mac != null) {
// Format: <device type>#<mac address>#<coap version>
String macid = substringBetween(devid, "#", "#");
@@ -231,14 +231,14 @@ public class Shelly1CoapHandler implements Shelly1CoapListener {
for (Option opt : options) {
switch (opt.getNumber()) {
case OptionNumberRegistry.URI_PATH:
- uri = COLOIT_URI_BASE + opt.getStringValue();
+ uri = COLOIT_URI_BASE + opt.toValueString();
break;
case OptionNumberRegistry.URI_HOST: // ignore
break;
case OptionNumberRegistry.CONTENT_FORMAT: // ignore
break;
case COIOT_OPTION_GLOBAL_DEVID:
- devId = opt.getStringValue();
+ devId = opt.toValueString();
String sVersion = substringAfterLast(devId, "#");
int iVersion;
try {
@@ -272,11 +272,11 @@ public class Shelly1CoapHandler implements Shelly1CoapListener {
case COIOT_OPTION_STATUS_VALIDITY:
break;
case COIOT_OPTION_STATUS_SERIAL:
- serial = opt.getIntegerValue();
+ serial = opt.getNumber();
break;
default:
logger.debug("{} ({}): CoAP option {} with value {} skipped", thingName, devId, opt.getNumber(),
- opt.getValue());
+ opt.getDefinition());
}
}
The only thing I'm uncertain about is the getDefinition() call in the log entry, I can't test it either, so I can't see what it outputs, but it "felt" like the most suitable option of those still there.
edit: Looking at it, getNumber() might be the wrong substitution too, but there's also a DataParser.bytesToInt() utility available that might be able to convert it.
Originally posted by @Nadahar in #20704 (comment)
I think this was more changes than what was needed. I happened to have to resolve this locally before I knew about this PR, and all I did was:
The only thing I'm uncertain about is the
getDefinition()call in the log entry, I can't test it either, so I can't see what it outputs, but it "felt" like the most suitable option of those still there.edit: Looking at it,
getNumber()might be the wrong substitution too, but there's also aDataParser.bytesToInt()utility available that might be able to convert it.Originally posted by @Nadahar in #20704 (comment)