Skip to content

Add bands sensor for carrier aggregation (#34) - #35

Merged
crbn60 merged 1 commit into
devfrom
feat/issue-34-bands-sensor
Apr 20, 2026
Merged

Add bands sensor for carrier aggregation (#34)#35
crbn60 merged 1 commit into
devfrom
feat/issue-34-bands-sensor

Conversation

@crbn60

@crbn60 crbn60 commented Apr 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • New bands sensor: compact carrier-aggregation display string (e.g. "LTE 7 (P), 2, 66 + 5G 78×2") with structured carriers + primary_band attributes for template/markdown cards.
  • API now normalizes /modems/status ca_signal into a carriers list on every modem dict.
  • Fixes 5G-NSA band mislabeling: the existing band sensor now reports the primary PCell instead of the NR anchor.

Breaking change

The existing band sensor previously reported the top-level band field from /modems/status. On 5G-NSA this was the NR anchor (e.g. "5G N78"). It now reports the primary carrier from ca_signal (e.g. "LTE B7"). Automations keyed on the old NSA value will need updating.

On non-CA or LTE-only setups, the band value is unchanged.

Test plan

  • .venv/bin/python -m pytest tests/ — 213 passing
  • .venv/bin/ruff check + ruff format --check — clean on touched files
  • pyright custom_components/rutos/ — 0 errors
  • Live smoke test against an RG520N-NA on Bell 5G-NSA: returns "LTE 7 (P), 2, 66 + 5G 78×2" as expected
  • Install on a live HA instance and verify sensor.<modem>_bands state + state_attr(..., 'carriers')

Closes #34

🤖 Generated with Claude Code

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>
@crbn60 crbn60 self-assigned this Apr 20, 2026
@crbn60
crbn60 merged commit 46c4564 into dev Apr 20, 2026
3 checks passed
@crbn60
crbn60 deleted the feat/issue-34-bands-sensor branch April 20, 2026 20:28
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.

Expose connected bands (carrier aggregation + 5G NSA) as a sensor

1 participant