fix: wired is unknown, media contract shapes, raise on failed reads (#2, #11) #12

Merged
christianmanivong merged 2 commits from fix/bugs-2026-11-02b into main 2026-11-02 09:14:50 +00:00
Owner

Two fixes, one commit each.

#2: wired vs. wireless is unknown (option C, as decided)

  • What changed: the wired check is gone. It read device_properties, which SoCo does not have, and swallowed the AttributeError.
    • In SoCo 0.31.2, deviceProperties is the UPnP DeviceProperties service. None of its actions says whether a speaker is wired or wireless.
    • GetZoneInfo returns serial, versions, IP, MAC, HTAudioIn, Flags and ExtraInfo, with no documented meaning for the last two.
    • EthLink exists only as an evented variable.
  • What the driver reports now: one interface, wlan0, described as "Network (wired or wireless unknown)". The name is kept so existing interface records stay as they are. It never reports eth0.
  • Docs: the README and the get_interfaces() docstring say that wired vs. wireless is not known.
  • Test: test_a_speaker_reports_no_eth0. Red first: the old guess claimed eth0 for a speaker object carrying the WifiMode it looked for.

#11: the media contract's shapes, raising on failed reads

  • get_playback_state() returns {"state", "source"} as napalm-device-types' MediaDriver declares it.
    • state maps UPnP's PLAYING, PAUSED_PLAYBACK, STOPPED and TRANSITIONING to the contract's four values. NO_MEDIA_PRESENT counts as stopped.
    • Any other state (UPnP's recording states) raises CommandErrorException.
    • source is SoCo's music_source in lower case (radio, line_in, tv, none, …).
  • get_zone_info() returns [{"name", "coordinator", "members"}] for the speaker's group, with the other speakers listed by name. A speaker in no group gives []. The speaker details it used to return stay in get_facts().
  • get_group_info() keeps its shape.
  • Both getters raise like the others since #9: ConnectionClosedException when not connected, ConnectionException / CommandErrorException when the read fails. Before, they answered {}.
  • Breaking, pre-1.0: the get_playback_state() and get_zone_info() shapes change. The CHANGELOG says so.
  • netOrk: git grep on netOrk origin/main finds no consumer of the media contract. There are no calls to get_playback_state, get_zone_info or get_group_info, and no import of napalm_device_types.media. netOrk only uses the role key media (device_class, the driver list, tests/test_vendor_drivers.py).
  • Tests: they use MagicMock(spec=soco.SoCo) and spec=soco.groups.ZoneGroup. Red first: the shape tests, the not-connected cases for both getters, and the failed group reads.

Checks

No real speaker was used; all tests run on mocks.

Check Result
pytest 55 passed
ruff format / ruff check green
mypy green
bandit green
napalm-standard check / napalm-standard ratchet green
coverage 83.5 % (floor 71)

Closes #2
Closes #11

Two fixes, one commit each. ## #2: wired vs. wireless is unknown (option C, as decided) - **What changed:** the wired check is gone. It read `device_properties`, which SoCo does not have, and swallowed the `AttributeError`. - In SoCo 0.31.2, `deviceProperties` is the UPnP `DeviceProperties` service. None of its actions says whether a speaker is wired or wireless. - `GetZoneInfo` returns serial, versions, IP, MAC, `HTAudioIn`, `Flags` and `ExtraInfo`, with no documented meaning for the last two. - `EthLink` exists only as an evented variable. - **What the driver reports now:** one interface, `wlan0`, described as "Network (wired or wireless unknown)". The name is kept so existing interface records stay as they are. It never reports `eth0`. - **Docs:** the README and the `get_interfaces()` docstring say that wired vs. wireless is not known. - **Test:** `test_a_speaker_reports_no_eth0`. Red first: the old guess claimed `eth0` for a speaker object carrying the `WifiMode` it looked for. ## #11: the media contract's shapes, raising on failed reads - **`get_playback_state()`** returns `{"state", "source"}` as napalm-device-types' `MediaDriver` declares it. - `state` maps UPnP's `PLAYING`, `PAUSED_PLAYBACK`, `STOPPED` and `TRANSITIONING` to the contract's four values. `NO_MEDIA_PRESENT` counts as `stopped`. - Any other state (UPnP's recording states) raises `CommandErrorException`. - `source` is SoCo's `music_source` in lower case (`radio`, `line_in`, `tv`, `none`, …). - **`get_zone_info()`** returns `[{"name", "coordinator", "members"}]` for the speaker's group, with the other speakers listed by name. A speaker in no group gives `[]`. The speaker details it used to return stay in `get_facts()`. - **`get_group_info()`** keeps its shape. - **Both getters raise like the others since #9:** `ConnectionClosedException` when not connected, `ConnectionException` / `CommandErrorException` when the read fails. Before, they answered `{}`. - **Breaking, pre-1.0:** the `get_playback_state()` and `get_zone_info()` shapes change. The CHANGELOG says so. - **netOrk:** `git grep` on netOrk origin/main finds no consumer of the media contract. There are no calls to `get_playback_state`, `get_zone_info` or `get_group_info`, and no import of `napalm_device_types.media`. netOrk only uses the role key `media` (`device_class`, the driver list, `tests/test_vendor_drivers.py`). - **Tests:** they use `MagicMock(spec=soco.SoCo)` and `spec=soco.groups.ZoneGroup`. Red first: the shape tests, the not-connected cases for both getters, and the failed group reads. ## Checks No real speaker was used; all tests run on mocks. | Check | Result | |---|---| | pytest | 55 passed | | ruff format / ruff check | green | | mypy | green | | bandit | green | | `napalm-standard check` / `napalm-standard ratchet` | green | | coverage | 83.5 % (floor 71) | Closes #2 Closes #11
christianmanivong added 2 commits 2026-11-02 08:28:56 +00:00
The wired check read device_properties, which SoCo does not have
(deviceProperties is the UPnP service, and none of its actions says
wired or wireless), and swallowed the AttributeError, so eth0 was never
reported and the guess served nothing. It is gone: a speaker reports
its one connection as wlan0, described as of unknown medium, and the
README and the getter docstrings say that wired vs. wireless is not
known.

Closes #2
fix(driver): follow the media contract's shapes, raise on failed reads
driver / standard (pull_request) Successful in 19s
driver / lint (pull_request) Successful in 15s
driver / types (pull_request) Successful in 1m9s
driver / test (3.12) (pull_request) Successful in 4m21s
driver / test (3.13) (pull_request) Successful in 4m16s
driver / lowest (pull_request) Successful in 3m46s
driver / build (pull_request) Successful in 32s
driver / security (pull_request) Successful in 1m14s
CI / driver (pull_request) Successful in 6m10s
driver / publish (pull_request) Skipped
218e2c7a7b
get_playback_state returned SoCo's transport string and get_zone_info
the speaker's details, where napalm-device-types' MediaDriver declares
{"state", "source"} and a list of {"name", "coordinator", "members"}.
Both now return those shapes; the speaker's details stay in get_facts.

get_group_info and get_zone_info caught every exception and answered
{}, so a failed read looked like a speaker in no group. They now raise
like the other getters (#9); {} and [] mean no group.

Closes #11
christianmanivong merged commit a86fb6cc3e into main 2026-11-02 09:14:50 +00:00
christianmanivong deleted branch fix/bugs-2026-11-02b 2026-11-02 09:14:50 +00:00
Sign in to join this conversation.