Fix ghost device pairing and stale device cache (closes #61) - #62
Open
snurre66 wants to merge 5 commits into
Open
Fix ghost device pairing and stale device cache (closes #61)#62snurre66 wants to merge 5 commits into
snurre66 wants to merge 5 commits into
Conversation
Author
|
Probably also fixes #50 |
snurre66
force-pushed
the
fix/issue-61-pairing-stale-devices
branch
from
August 15, 2026 17:31
0c69945 to
51dc268
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #61 by preventing stale/unreachable discovery entries from being presented and/or accidentally paired, and by ensuring removed devices can be pruned from the discovery cache.
Changes:
- Pair UI now adds only devices explicitly selected by the user (instead of iterating over all discovered devices).
- Device deletion now marks the underlying discovery device as unpaired and unsubscribes it so discovery timeout pruning can remove it.
- Pairing device list now filters out already-paired devices and devices whose
lastSeenis outside the timeout window; also registers an SDK v3list_devicessession handler.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| drivers/homeyduino/pair/add_devices.html | Limits Homey.addDevice calls to selected devices only. |
| drivers/homeyduino/device.js | Ensures deleted devices are marked unpaired/unsubscribed for discovery cleanup. |
| drivers/homeyduino/driver.js | Filters pairing candidates (already paired + stale) and registers list_devices handler for SDK v3. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+109
to
+112
| let settings = existingDevice.getSettings ? existingDevice.getSettings() : null; | ||
| if (settings && settings.id) existingIds.add(settings.id); | ||
| let data = existingDevice.getData ? existingDevice.getData() : null; | ||
| if (data && data.id) existingIds.add(data.id); |
Comment on lines
5
to
9
| var devices = (window.selected_devices || []).map(function(deviceKey){ | ||
| return window.found_devices[deviceKey]; | ||
| }).filter(function(device){ | ||
| return device && device.data && device.data.id; | ||
| }); |
Contributor
|
Hey @snurre66, thanks for your contribution! I tested your fix and everything seems to be in order. If you can resolve the issues pointed out by copilot I'll make sure your PR gets merged. |
Author
|
Thanks for the review!
I have pushed updates addressing both points:
1. Renamed the internal device data variable in driver.js to avoid
shadowing the data parameter in onPairListDevices.
2. Added deduplication for selected devices in the pair UI list and
before calling Homey.addDevice, ensuring devices cannot be added more
than once even if selected repeatedly.
…On Tue, Aug 18, 2026 at 8:58 AM Wouter ***@***.***> wrote:
*wouter-athom* left a comment (athombv/com.athom.homeyduino#62)
<#62 (comment)>
Hey @snurre66 <https://github.com/snurre66>, thanks for your
contribution! I tested your fix and everything seems to be in order. If you
can resolve the issues pointed out by copilot I'll make sure your PR gets
merged.
—
Reply to this email directly, view it on GitHub
<#62?email_source=notifications&email_token=ALUMHI2WQ74IFFSXSMHIZLD5KP5C5A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMZSGQ3TCOJWGQZKM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-5324719642>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALUMHI7FFALWFPUPMFC2GJ35KP5C5AVCNFSNUABFKJSXA33TNF2G64TZHMYTANJQGA2TSOJQHNEXG43VMU5TKMJWGA2TANBRGQ32C5QC>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/ALUMHIZBVMKSEF2N52SXLAD5KP5C5A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMZSGQ3TCOJWGQZKM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJKTGN5XXIZLSL5UW64Y>
and Android
<https://github.com/notifications/mobile/android/ALUMHI3IJ46LBGMBIWN7H2T5KP5C5A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMZSGQ3TCOJWGQZKM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>.
Download it today!
You are receiving this because you were mentioned.Message ID: <athombv/com
.***@***.***>
--
mvh
Thomas Veivåg
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Resolves #61 where unpowered/previously-paired devices remained in the discovery cache indefinitely and were unintentionally added to Homey alongside chosen devices due to the pair wizard iterating over
window.found_devices.Solution
drivers/homeyduino/pair/add_devices.html: Fixed device addition loop to only add devices present inwindow.selected_devices.drivers/homeyduino/device.js: InonDeleted(), resetpaired: falseand unsubscribe the device so discovery timeout pruning (_deleteAfterTimeout()) cleans up offline removed boards.drivers/homeyduino/driver.js: InonPairListDevices(), filter out already-paired devices and stale devices whoselastSeentimestamp has timed out. Registeredsession.setHandler("list_devices")for SDK v3 pair views.