Skip to content

fix(lock): ignore advertisements with an unknown lock status - #363

Merged
donavanbecker merged 1 commit into
latestfrom
fix/unknown-lock-status
Nov 13, 2026
Merged

donavanbecker merged 1 commit into
latestfrom
fix/unknown-lock-status

Conversation

@donavanbecker

Copy link
Copy Markdown
Contributor

What

A Lock Ultra on firmware 3.1 reports lock status values 11, 13, 14 and 15. pySwitchbot's LockStatus only defines 0–7. This was reported in SwitchBotAPI-BLE#54 and pySwitchbot#595.

In 6.1.0, lockStateFromStatus mapped every unknown value to locked, so one of these advertisements could show an unlocked door as locked.

Fix

This follows pySwitchbot's open fix, pySwitchbot#596: an update with an unknown status is ignored, so the last known state stands.

  • parseLockAdvertisement returns null for an unknown status, which is distinct from undefined for missing or short data. The scanner drops that advertisement, so it never replaces the device's last good data.
  • lockStateFromStatus returns undefined for unknown values.
  • isKnownLockStatus is exported.

Tests

  • Statuses 11, 13, 14 and 15, written into pySwitchbot's own Lock Ultra fixture, are ignored. A known status in the same layout still parses.
  • The Lock Nano layout behaves the same way.
  • The scanner drops the advertisement.

518 tests pass. Build and lint pass.

No breaking changes. Patch release (6.1.1).


Generated by Claude Code

A Lock Ultra on firmware 3.1 reports lock status values 11, 13, 14 and 15,
which pySwitchbot's LockStatus does not define (SwitchBotAPI-BLE #54,
pySwitchbot #595). lockStateFromStatus mapped every unknown value to
"locked", so such an advertisement could show an unlocked door as locked.

As in pySwitchbot PR #596, an advertisement with an unknown status is now
ignored entirely, so the last known state stands: parseLockAdvertisement
returns null and the scanner drops the advertisement. lockStateFromStatus
returns undefined for unknown values, and isKnownLockStatus is exported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TYWa2RXoWsaUTWh76oNv8s
@donavanbecker donavanbecker added the patch label Nov 13, 2026 — with Claude
@donavanbecker
donavanbecker merged commit fa754c8 into latest Nov 13, 2026
3 checks passed
@donavanbecker
donavanbecker deleted the fix/unknown-lock-status branch November 13, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants