Add_new_support_for_keypad_airpurifier#42
Merged
SeraphicRav merged 2 commits intoMar 3, 2026
Merged
Conversation
SeraphicRav
approved these changes
Mar 3, 2026
sarveshbathija
added a commit
to sarveshbathija/py-switchbot-api
that referenced
this pull request
Apr 7, 2026
The SwitchBot Cloud API returns an empty body for IR remote devices (the docstring on `get_status` already notes "No status for IR devices"), so the unwrapped response dict has no `deviceType` key. Since SeraphicCorp#42 introduced an unconditional `response["deviceType"]` lookup to detect Keypad devices, every coordinator backing an IR remote (and any other device whose status response omits `deviceType`) now raises `KeyError: 'deviceType'`. In Home Assistant this surfaces as the `switchbot_cloud` integration repeatedly failing to set up: File ".../switchbot_api/__init__.py", line 265, in get_status device_type = response["deviceType"] KeyError: 'deviceType' Use `dict.get` so the missing-key case falls through to the existing "return response as-is" path, matching the pre-SeraphicCorp#42 behavior for IR remotes while preserving the new keypad special-casing. Adds a regression test + fixture covering an empty status body.
5 tasks
SeraphicRav
pushed a commit
that referenced
this pull request
Apr 10, 2026
The SwitchBot Cloud API returns an empty body for IR remote devices (the docstring on `get_status` already notes "No status for IR devices"), so the unwrapped response dict has no `deviceType` key. Since #42 introduced an unconditional `response["deviceType"]` lookup to detect Keypad devices, every coordinator backing an IR remote (and any other device whose status response omits `deviceType`) now raises `KeyError: 'deviceType'`. In Home Assistant this surfaces as the `switchbot_cloud` integration repeatedly failing to set up: File ".../switchbot_api/__init__.py", line 265, in get_status device_type = response["deviceType"] KeyError: 'deviceType' Use `dict.get` so the missing-key case falls through to the existing "return response as-is" path, matching the pre-#42 behavior for IR remotes while preserving the new keypad special-casing. Adds a regression test + fixture covering an empty status body. Co-authored-by: sarveshbathija <589118+sarveshbathija@users.noreply.github.com>
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.
Keypad status can only be viewed in device details; special handling is required.
Add a decoding function for the keyboard.
Add a new command for the air purifier.