Repository navigation
feat(sensor): make User-Agent configurable per feed - #164
Open
davenicoll wants to merge 1 commit into
Open
davenicoll wants to merge 1 commit into
davenicoll wants to merge 1 commit into
Conversation
- Add optional `user_agent` setting; default stays the integration's agent - Send the configured agent on every feed request - Document the option in the README - Add tests for the default agent, a custom agent and the config schema - Raise ruff max-args to 11 for the new constructor argument Some servers stall or reject clients they don't recognise. CBC's RSS feeds, for example, hang indefinitely for generic agents. A per-feed setting lets users work around this without patching the integration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
Summary
Adds an optional per-sensor
user_agentsetting. The default is unchanged (Home Assistant Feed-parser Integration <version>), so existing configurations behave identically.Some servers stall or reject clients they don't recognise. CBC's RSS feeds, for example, hang indefinitely for generic agents. Today the only workaround is patching the integration.
Changes
sensor.py: newCONF_USER_AGENToption inPLATFORM_SCHEMA(defaultUSER_AGENT), passed toFeedParserSensorand sent on every request. The constructor argument is last and defaulted, so direct callers are unaffected.README.md: document the option, with an example.tests/test_sensors.py: tests for the default agent, a custom agent (checked on the request actually sent), and the schema default/override.pyproject.toml: ruffmax-args10 → 11 for the new constructor argument, in line with how the limit was sized previously.Testing
pytest tests/: 113 passed (88 before; 25 new cases across the test feeds) on Home Assistant 2026.9 / Python 3.14..pre-commit-config.yaml) are clean.--ignore-missing-imports, the same asmaster. I couldn't run the full pre-commit mypy hook locally becausehomeassistant-stubsneeds Home Assistant installed; CI will cover it.🤖 Generated with Claude Code