Skip to content

Two small fixes: OTA update-check guard (undefined definition) + permitJoin countdown reset on close - #2974

Open
krobipd wants to merge 2 commits into
ioBroker:masterfrom
krobipd:fix/ota-guard-and-permitjoin-reset
Open

Two small fixes: OTA update-check guard (undefined definition) + permitJoin countdown reset on close#2974
krobipd wants to merge 2 commits into
ioBroker:masterfrom
krobipd:fix/ota-guard-and-permitjoin-reset

Conversation

@krobipd

@krobipd krobipd commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Two small, independent fixes, each triggered by a real event on a production ember coordinator (EmberZNet 8.0.2). Both are one-line changes; eslint passes. No test scenarios added (small changes) — the production logs below are the "seen it happen".

They surfaced on the same instance but are unrelated (different subsystems) — happy to split into two PRs if you'd rather.


1. fix(pairing) — permitJoin countdown not reset on close

Symptom (same session, ~16 min apart):

16:08:06 info: Opening network.
16:08:06 info: Opened zigbee Network for 60 seconds
16:09:06 info: Closed Zigbee network with 1 second remaining.
16:25:06 info: Extending open network.        <-- network had closed 16 min earlier
16:25:07 info: Opened zigbee Network for 60 seconds

Opening the network a second time logs "Extending open network" although the previous window had already timed out and closed — the adapter still considers a pairing window active long after the radio closed.

Cause: in handlePermitJoinChanged, the timeout-close branch clears the countdown interval but never resets _permitJoinTime (it is left at ~1 — the value shown in "1 second remaining"). permitJoin() then treats _permitJoinTime > 0 as an already-open window and logs "Extending …" instead of "Opening …". The manual stop path (permitJoin(0)) already resets it; only the timeout path did not.

Fix: reset _permitJoinTime = 0 when the network closes.


2. fix(ota) — update-availability check throws for devices without a definition

Symptom (repeats every OTA cycle for un-interviewed devices):

warn: Failed to check if update available for 'unnamed (0xb4e3f9fffe56ebc8)' Cannot read properties of undefined (reading 'ota')
warn: Failed to check if update available for 'unnamed (0x0c4314fffe0ed00e)' Cannot read properties of undefined (reading 'ota')

A device that never completed interview has no resolved definition (entity.mapped is undefined). lib/ota.js accessed entity.mapped.ota directly, so the check throws and is logged as a misleading "Failed to check if update available" warning.

Cause / consistency: that line was the only entity.mapped.* access in the function not using optional chaining — the four adjacent accesses already use entity?.mapped?.model.

Fix: entity?.mapped?.ota. Such devices now take the existing not_supported branch (which already logs a clean debug line with the id), and the warn is reserved for genuine check failures (device didn't respond).


Found on ember; neither change is stack-specific (both are adapter-side JS).

krobipd and others added 2 commits August 10, 2026 22:48
On a pairing-window timeout, handlePermitJoinChanged clears the countdown
interval but left _permitJoinTime at its last value (~1). A later permitJoin()
then logs "Extending open network" instead of "Opening network", because it
treats _permitJoinTime > 0 as a still-active window - so the adapter's pairing
state stays "open" long after the radio has closed.

Reset _permitJoinTime to 0 on close so the internal state matches the
(correctly closed) radio state.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
For a device without a resolved definition (e.g. one that never completed
interview), entity.mapped is undefined, so entity.mapped.ota threw
"Cannot read properties of undefined (reading 'ota')" - surfacing as a
misleading "Failed to check if update available" warning on every OTA cycle.

Use optional chaining (entity?.mapped?.ota), matching the four adjacent
entity?.mapped?.model accesses in the same function. Such devices now take the
existing not_supported path, and the warning is reserved for real check failures.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant