fix: handle ResultCode in get_fire_overview to prevent crash when offline#81
Merged
deviantintegral merged 2 commits intomainfrom Mar 11, 2026
Merged
Conversation
393c333 to
1820bd7
Compare
7b303a6 to
027384f
Compare
Add plan for fixing TypeError crash when fireplace is offline. The API returns ResultCode != 0 with WifiFireOverview: null for offline/failed/unavailable fireplaces, but our client unconditionally accesses WifiFireOverview causing a crash. The plan introduces a FireOverviewResultCode enum, FireUnavailableError exception, and a guard clause in get_fire_overview. Closes #55 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…line The GetFireOverview API returns a ResultCode field that indicates whether the fireplace is reachable. When ResultCode != 0 (offline, failed, no longer available, updating firmware), WifiFireOverview is null. Our client unconditionally accessed it, causing a TypeError crash. - Add FireOverviewResultCode enum mirroring the API's 5 result codes - Add FireUnavailableError exception carrying result_code and optional Fire metadata from FireDetails - Add guard clause in get_fire_overview to check ResultCode before accessing WifiFireOverview - Extract shared _parse_fire helper to deduplicate Fire construction across get_fires, get_fire_overview success path, and error path - Export new types from __init__.py - Add tests for all result code paths, backward compatibility, malformed FireDetails, turn_on/turn_off propagation Refs: deviantintegral/flame_connect_ha#55 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
027384f to
1c1bb48
Compare
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.
Summary
TypeError: 'NoneType' object is not subscriptablecrash when the fireplace is offlineGetFireOverviewAPI returnsResultCode != 0withWifiFireOverview: nullfor offline/failed/unavailable fireplaces, but the client unconditionally accessedWifiFireOverviewFireOverviewResultCodeenum mirroring the API's 5 result codes (Successful, FireOffline, Failed, FireNoLongerAvailable, UpdatingFirmware)FireUnavailableErrorexception (subclass ofFlameConnectError) carryingresult_codeand optionalFiremetadata fromFireDetailsget_fire_overviewto checkResultCodebefore accessingWifiFireOverview, matching the official app's behavior_parse_firehelper to deduplicateFireconstruction acrossget_fires,get_fire_overview, and the error pathResultCodedefault to successTest plan
FireUnavailableErrorwith correct codeFireUnavailableError.firepopulated fromFireDetailswhen present,NoneotherwiseFireDetailsdegrades gracefully tofire=NoneResultCodedefaults to success (backward compatibility)ResultCodevalues (e.g., 99) raiseFireUnavailableErrorResultCode == 0) returnsFireOverviewidentically to beforeturn_onandturn_offpropagateFireUnavailableError_parse_firehelper works with complete and minimal dataRefs: deviantintegral/flame_connect_ha#55
🤖 Generated with Claude Code