fix: promote connection diagnostics from debug to error/warning level#307
Conversation
Users running at default ERROR logging never saw why connections failed. Connection errors, timeouts, and login failures were all logged at debug level, making it impossible to diagnose issues without enabling debug mode. Changes: - poll(): Timeout, ConnectionError, and unexpected exceptions now log at error level with actionable messages (check network, check gateway) - _get_session(): Connection and login failures now log at error/warning level with specific guidance (check network, check password) - connect(): Mode fallback messages promoted from debug to warning level - Main init: More descriptive error message with debugging guidance Fixes jasonacox#160
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #307 +/- ##
==========================================
- Coverage 26.40% 26.40% -0.01%
==========================================
Files 42 42
Lines 7660 7662 +2
Branches 1101 1102 +1
==========================================
Hits 2023 2023
- Misses 5493 5495 +2
Partials 144 144
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR improves default logging for connection failures so users get actionable diagnostics when the Powerwall gateway (or Tesla APIs) can’t be reached, addressing issue #160 where meaningful details were only visible at DEBUG level.
Changes:
- Promotes several local-mode connection diagnostics in
poll()and_get_session()fromDEBUGtoERROR/WARNING. - Enhances the top-level “unable to connect” message with guidance, and promotes mode-fallback messages in
connect()fromDEBUGtoWARNING.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
pypowerwall/local/pypowerwall_local.py |
Raises visibility of login/connection failures during session creation and polling by logging at warning/error with more actionable text. |
pypowerwall/__init__.py |
Improves user-facing connection failure guidance and makes mode fallback attempts visible at warning level. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| except Exception as e: | ||
| log.debug(f'login failed: {e}') | ||
| raise LoginError("Invalid Powerwall Login") | ||
| log.warning(f'Login failed: {e}') | ||
| raise LoginError(f"Invalid Powerwall Login - check password for {self.host}") |
| except requests.exceptions.ConnectionError: | ||
| log.debug('ERROR Unable to connect to Powerwall at %s' % url) | ||
| log.error('Unable to connect to Powerwall at %s - check that the gateway is reachable and powered on' % self.host) | ||
| return None |
|
@jasonacox-sam This looks good. Address the Copilot reviews and let's start testing. |
…ures, include ConnectionError details
|
@jasonacox Copilot feedback addressed in 83cfcf5:
Ready for testing. — Sam ⚡ (pypowerwall agent) |
|
@jasonacox-sam This looks good. Increment the version number and create a new entry in RELEASE.md for the new version and examine the changes from last tag v0.15.8 to include, in prep for new release. |
|
Version bumped to 0.15.9 and RELEASE.md updated with full changelog for this release. Summary of changes since v0.15.8:
Ready for merge when you approve. |
|
View at: jasonacox/pypowerwall:0.15.9t89 |
Summary
Fixes #160 — pypowerwall silently fails when it can't connect to the gateway, providing no diagnostic information at default logging levels.
Problem
When the Powerwall gateway becomes unreachable (network issue, password change, firmware reset), users see only generic errors like:
This gives no indication of why the connection is failing — is it a network issue? Wrong password? Token expired? Gateway powered off?
All the meaningful diagnostic messages were logged at
DEBUGlevel, invisible to users running at the defaultERRORlevel.Changes
pypowerwall/local/pypowerwall_local.py:poll(): Timeout, ConnectionError, and unexpected exceptions now log at error level with actionable messages"Timeout waiting for Powerwall API /api/... - check network connectivity to <host>""Unable to connect to Powerwall at <host> - check that the gateway is reachable and powered on""Unexpected error connecting to Powerwall at <url>: <exception>"_get_session(): Connection and login failures now log at error/warning level"Unable to connect to Powerwall at https://<host>: <exc> - check that the gateway is reachable on the network""Invalid Powerwall Login - check password for <host>"pypowerwall/__init__.py:connect(): Mode fallback messages promoted fromdebugtowarninglevel"Verify host, credentials, and network connectivity. Enable debug logging for detailed diagnostics."Before (default logging)
After (default logging)
Testing
Noneon errors, same retry logic, same caching)— Sam 🌊