Skip to content

Handle invalid Xiaomi KS1 button events - #1585

Merged
Ernst79 merged 4 commits into
custom-components:masterfrom
IoannisArmamentos:fix/xiaomi-ks1-invalid-button-events
Sep 8, 2026
Merged

Handle invalid Xiaomi KS1 button events#1585
Ernst79 merged 4 commits into
custom-components:masterfrom
IoannisArmamentos:fix/xiaomi-ks1-invalid-button-events

Conversation

@IoannisArmamentos

Copy link
Copy Markdown
Contributor

Summary

Prevent invalid Xiaomi KS1/KS1BP button events from causing parser exceptions.

Problem

obj560c(), obj560d(), and obj560e() returned None for unrecognized click values and unsupported device types.

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

TypeError: 'NoneType' object is not iterable

Both the device identifier and click value originate from the BLE advertisement and may contain unexpected values.

Fix

Return an empty result for unrecognized click values and unsupported device types instead of None.

Recognized KS1/KS1BP single click, double click, and long press events remain unchanged.

Regression tests cover invalid inputs and representative valid button events.

@Ernst79
Ernst79 merged commit f3e045c 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