Skip to content

fix: prevent redundant auth for basic_http modems (v3.13.1)#122

Merged
kwschulz merged 2 commits intomainfrom
feature/v3.13.1
Feb 27, 2026
Merged

fix: prevent redundant auth for basic_http modems (v3.13.1)#122
kwschulz merged 2 commits intomainfrom
feature/v3.13.1

Conversation

@kwschulz
Copy link
Copy Markdown
Collaborator

Summary

  • Fixed redundant authentication for basic_http modems (CM1200, C7000v2, CM600, C3700, TC4400). The _pre_authenticate() gate condition used HTML presence as a proxy for "was auth performed?" but basic_http is stateless and never returns HTML — causing a second _login() call and extra HTTP request every poll cycle. Modems that rate-limit rapid HTTPS requests (e.g., CM1200) returned zero channel data as a result.
  • Changed _pre_authenticate() to return an explicit auth_performed flag instead of inferring from HTML.

Test plan

  • All 2545 tests pass, ruff/black/mypy clean
  • Verified fix reduces basic_http polls from 4 HTTP requests to 3 (1 login + 2 data pages)
  • Verified no behavior change for other auth strategies (form_plain, hnap_json, url_token_session, no_auth)
  • Dogfood on local HA (if warranted)
  • User (@DeFlanko) confirms CM1200 channel data restored

Related to #121

🤖 Generated with Claude Code

kwschulz and others added 2 commits February 27, 2026 16:24
The _pre_authenticate() gate condition used `if not pre_auth_html` as a
proxy for "was auth performed?" but basic_http auth is stateless and
intentionally never returns HTML. This caused _authenticate() to always
run for basic_http modems, making 2 login() calls and 4 HTTP requests
per poll instead of 1 and 3. The extra requests triggered connection
resets on modems that rate-limit rapid HTTPS requests (e.g., CM1200).

Changed _pre_authenticate() to return a 3-tuple (success, html,
auth_performed) with an explicit boolean flag, and gate on
`if not pre_auth_performed` instead.

Related to #121

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kwschulz kwschulz merged commit 80892b6 into main Feb 27, 2026
11 checks passed
@DeFlanko
Copy link
Copy Markdown

Screenshot_20260227_145225_Home Assistant.png

Looks to be still broken.

When I get back to my desk I'll get you a fresh diagnostics output.

@kwschulz kwschulz deleted the feature/v3.13.1 branch February 28, 2026 22:44
kwschulz added a commit that referenced this pull request Apr 6, 2026
fix: prevent redundant auth for basic_http modems (v3.13.1)
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