Skip to content

fix: handle ResultCode in get_fire_overview to prevent crash when offline#81

Merged
deviantintegral merged 2 commits intomainfrom
plan/handle-fire-overview-result-code
Mar 11, 2026
Merged

fix: handle ResultCode in get_fire_overview to prevent crash when offline#81
deviantintegral merged 2 commits intomainfrom
plan/handle-fire-overview-result-code

Conversation

@deviantintegral
Copy link
Owner

@deviantintegral deviantintegral commented Mar 11, 2026

Summary

  • Fix TypeError: 'NoneType' object is not subscriptable crash when the fireplace is offline
  • The GetFireOverview API returns ResultCode != 0 with WifiFireOverview: null for offline/failed/unavailable fireplaces, but the client unconditionally accessed WifiFireOverview
  • Add FireOverviewResultCode enum mirroring the API's 5 result codes (Successful, FireOffline, Failed, FireNoLongerAvailable, UpdatingFirmware)
  • Add FireUnavailableError exception (subclass of FlameConnectError) carrying result_code and optional Fire metadata from FireDetails
  • Add guard clause in get_fire_overview to check ResultCode before accessing WifiFireOverview, matching the official app's behavior
  • Extract shared _parse_fire helper to deduplicate Fire construction across get_fires, get_fire_overview, and the error path
  • Backward compatible: responses omitting ResultCode default to success

Test plan

  • All non-success ResultCode values (1-4) raise FireUnavailableError with correct code
  • FireUnavailableError.fire populated from FireDetails when present, None otherwise
  • Malformed FireDetails degrades gracefully to fire=None
  • Omitted ResultCode defaults to success (backward compatibility)
  • Unknown ResultCode values (e.g., 99) raise FireUnavailableError
  • Success path (ResultCode == 0) returns FireOverview identically to before
  • turn_on and turn_off propagate FireUnavailableError
  • _parse_fire helper works with complete and minimal data
  • All 1221 tests pass, mypy strict, ruff clean

Refs: deviantintegral/flame_connect_ha#55

🤖 Generated with Claude Code

@deviantintegral deviantintegral force-pushed the plan/handle-fire-overview-result-code branch from 393c333 to 1820bd7 Compare March 11, 2026 12:54
@deviantintegral deviantintegral changed the title plan: handle ResultCode in get_fire_overview docs: handle ResultCode in get_fire_overview Mar 11, 2026
@deviantintegral deviantintegral changed the title docs: handle ResultCode in get_fire_overview fix: handle ResultCode in get_fire_overview to prevent crash when offline Mar 11, 2026
@deviantintegral deviantintegral force-pushed the plan/handle-fire-overview-result-code branch from 7b303a6 to 027384f Compare March 11, 2026 13:18
@deviantintegral deviantintegral enabled auto-merge (squash) March 11, 2026 13:29
deviantintegral and others added 2 commits March 11, 2026 09:29
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>
@deviantintegral deviantintegral force-pushed the plan/handle-fire-overview-result-code branch from 027384f to 1c1bb48 Compare March 11, 2026 13:29
@deviantintegral deviantintegral merged commit bb3eb7a into main Mar 11, 2026
5 checks passed
@deviantintegral deviantintegral deleted the plan/handle-fire-overview-result-code branch March 11, 2026 13:34
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.

1 participant