From ff52144a55d994c642930df3378bcdb7f299e98f Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 16 Nov 2026 13:18:43 +0100 Subject: fix: a 4.xx/5.xx CoAP response is a failure coap-client exits 0 on an error response and prints the code on stderr, so show() marked rejected requests as shown and never retried them. Co-Authored-By: Claude Opus 5.5 --- agent-lamp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/agent-lamp b/agent-lamp index 6c0791a..1ff34c5 100755 --- a/agent-lamp +++ b/agent-lamp @@ -138,11 +138,15 @@ def coap(method, url, ident, key, payload=None): if payload is not None: cmd += ["-e", json.dumps(payload, separators=(",", ":"))] try: - out = subprocess.run(cmd + [url], capture_output=True, text=True, - timeout=TIMEOUT + 2, check=True).stdout + done = subprocess.run(cmd + [url], capture_output=True, text=True, + timeout=TIMEOUT + 2) except (subprocess.SubprocessError, OSError): return None - return out.strip() + # coap-client exits 0 on a 4.xx/5.xx response and prints the code on + # stderr only (verified against the gateway: "4.04 Not Found"). + if done.returncode or done.stderr.lstrip()[:2] in ("4.", "5."): + return None + return done.stdout.strip() def put(url, auth, state): -- cgit v1.2.3