Skip to content

Handle unknown Xiaomi sleep states - #1583

Merged
Ernst79 merged 1 commit into
custom-components:masterfrom
IoannisArmamentos:fix/xiaomi-unknown-sleep-state
Sep 8, 2026
Merged

Handle unknown Xiaomi sleep states#1583
Ernst79 merged 1 commit into
custom-components:masterfrom
IoannisArmamentos:fix/xiaomi-unknown-sleep-state

Conversation

@IoannisArmamentos

Copy link
Copy Markdown
Contributor

Summary

Prevent unexpected Xiaomi MiBeacon sleep-state values from causing a parser exception.

Problem

obj4810() and obj5010() returned None for unrecognized sleep-state values.

The Xiaomi parser passes object-parser results directly to dict.update(), so an unknown value could result in:

TypeError: 'NoneType' object is not iterable

The sleep-state byte comes directly from the BLE advertisement and may contain unexpected values.

Fix

Return an empty result for unrecognized sleep state values instead of None.

Recognized sleep states remain unchanged.

Regression tests cover unknown and valid sleepstate values for both parsers.

@Ernst79
Ernst79 merged commit 0d39a7f into custom-components:master Sep 8, 2026
6 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.

2 participants