Add bands sensor for carrier aggregation (#34) - #35
Merged
Conversation
The existing `band` sensor reported only the single top-level `band` field from `/modems/status`, which on 5G-NSA is the NR anchor — not the primary PCell. On the reporter's RG520N-NA this surfaced "5G N78" while the actual primary carrier was "LTE B7". - api: normalize `ca_signal` into a `carriers` list and source `band` / `channel_number` from the primary carrier when present. The fallback `/modems/signal/status` path emits `carriers: []` for attribute parity. - sensor: new `bands` entity whose state is a compact display string (e.g. `"LTE 7 (P), 2, 66 + 5G 78×2"`) with structured `carriers` and `primary_band` attributes for template/markdown cards. - `RutOSSensorEntityDescription` gains optional `attributes_fn`; the modem-signal entity now reads it via `extra_state_attributes`. Behavior change: the existing `band` sensor now reports the primary carrier's band instead of the top-level anchor. This fixes NSA mislabeling but is breaking for automations keyed on the old NR-anchor value. Closes #34 Co-Authored-By: Claude Opus 4.7 <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
bandssensor: compact carrier-aggregation display string (e.g."LTE 7 (P), 2, 66 + 5G 78×2") with structuredcarriers+primary_bandattributes for template/markdown cards./modems/statusca_signalinto acarrierslist on every modem dict.bandsensor now reports the primary PCell instead of the NR anchor.Breaking change
The existing
bandsensor previously reported the top-levelbandfield from/modems/status. On 5G-NSA this was the NR anchor (e.g."5G N78"). It now reports the primary carrier fromca_signal(e.g."LTE B7"). Automations keyed on the old NSA value will need updating.On non-CA or LTE-only setups, the
bandvalue is unchanged.Test plan
.venv/bin/python -m pytest tests/— 213 passing.venv/bin/ruff check+ruff format --check— clean on touched filespyright custom_components/rutos/— 0 errors"LTE 7 (P), 2, 66 + 5G 78×2"as expectedsensor.<modem>_bandsstate +state_attr(..., 'carriers')Closes #34
🤖 Generated with Claude Code