Skip to content

Fix the issues found in the review of 1.0.0 - #6

Merged
DAB-LABS merged 1 commit into
masterfrom
fixes-1.0.1
Sep 5, 2026
Merged

Fix the issues found in the review of 1.0.0#6
DAB-LABS merged 1 commit into
masterfrom
fixes-1.0.1

Conversation

@DAB-LABS

@DAB-LABS DAB-LABS commented Sep 5, 2026

Copy link
Copy Markdown
Owner

I had 1.0.0 reviewed by an outside party before asking Home Assistant to switch to it. The review confirmed the library talks to devices like the original does.

They also mentioned that the new version keeps one network socket open per device, a slow reply to an old request could get mistaken for the reply to a new one. Poor connectivity could show up as a wrong sensor reading or state.

We think we fixed it after confirming on bench hardware. Tested on Python 3.13 and 3.14, 252 tests, plus a live run against an RM4 Pro.

Coding assistant's notes on this change:

Replies are now matched to their request by the packet counter the device echoes back at offset 0x28 (verified on an RM4 Pro, six for six). A reply carrying the counter of a request that already timed out is dropped. A reply whose counter matches nothing we sent is still accepted, so firmware that does not echo the counter keeps working as before.

Also in this change: concurrent callers hitting an expired session key share one re-authentication, and the "logged out" code (-2) now triggers re-auth; changing device.host reopens the socket; aclose() during a request fails it immediately instead of waiting out the timeout; capture() treats ReadError (-10) as "nothing yet" alongside StorageError (-5), which the CLI inherits; a capture() generator abandoned without closing no longer blocks the next one, and there is a new capture_active property; the README explains that broadlink and python-broadlink cannot share an environment; and the changelog no longer describes the carried-over device commits as intact (they were squash-merged with Co-authored-by credit).

I had 1.0.0 reviewed by an outside party before asking Home Assistant to
switch to it. The review confirmed the library talks to devices exactly the
way the original did, and found one real bug plus a few small things. This
fixes them. No change to the wire format or the public API. Tested on
Python 3.13 and 3.14 (252 tests) and live against an RM4 Pro.

Technical details:
- Replies are matched to their request by the packet counter the device
  echoes at offset 0x28. A reply for a request that already timed out is
  dropped; a reply whose counter matches nothing sent is still accepted,
  so firmware that does not echo the counter keeps working.
- Concurrent callers hitting an expired session key share one
  re-authentication. The logged-out code (-2) now triggers re-auth.
- Changing device.host reopens the socket.
- aclose() during a request fails it immediately.
- capture() treats ReadError (-10) as "nothing yet" alongside
  StorageError (-5); the CLI inherits this.
- An abandoned capture() generator no longer blocks the next one; new
  capture_active property.
- README: broadlink and python-broadlink cannot share an environment.
- Changelog: carried-over device commits were squash-merged with
  Co-authored-by credit; oracle description corrected.
- Version 1.0.1.
@DAB-LABS
DAB-LABS merged commit ffc7ef8 into master Sep 5, 2026
3 checks passed
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