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
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
get_volume, get_mute, get_playback_state and get_current_track
answered 0, False, "STOPPED" and {} when the driver was not connected
or the read failed, so an unreachable speaker looked like a silent,
stopped one. They now raise ConnectionClosedException, or
ConnectionException / CommandErrorException with the SoCo error as
the cause.
get_playback_state called get_playback_state() on the SoCo object,
which SoCo does not have; the AttributeError was swallowed and every
speaker read as STOPPED. It now reads current_transport_state from
get_current_transport_info(). The tests mock the speaker with
MagicMock(spec=soco.SoCo), so a call to a method SoCo lacks fails.
Closes#9
play() and the other controls returned silently without a device, so
a control that did nothing looked like it had worked. They now raise
ConnectionClosedException. get_arp_table() takes NAPALM's vrf
argument, and the module docstring moves above the imports so
__doc__ is set again.
The wired-speaker part of the issue stays open: SoCo's
deviceProperties is a UPnP service, not a dict with WifiMode, so
renaming the attribute alone would still never report eth0.
Refs #2
- open() raises ConnectionException from the SoCo error (B904), so the
cause stays attached.
- _check_wired_connection: the except Exception: pass (B110) now logs at
debug level, so a swallowed failure leaves a trace. A module logger is
new.
- nosec for the empty password default (B107): a Sonos speaker takes no
login, the argument exists for NAPALM's constructor signature.
- tests: raise AssertionError instead of assert False (B011).
Mechanical: ruff format, and ruff check --fix with the rule set every NAPALM
driver uses (E, F, I, UP, B at line length 100, Python 3.10). What ruff
cannot fix comes in the next commit.
run_device_action dispatched play, pause, stop, next/previous track,
set_volume:N and toggle_mute by string and returned
{success, action, message} instead of the DeviceActionResultDict its
contract names. The typed methods it called (play(), set_volume(), ...)
are the interface; napalm-device-types deprecates run_device_action.
BREAKING CHANGE: run_device_action is removed.
Closes#3
A Sonos speaker implements none of the access-point surface — no SSIDs, no radio
configuration, no MAC ACL. It has get_playback_state, get_volume, play and
get_zone_info. It inherited AccessPointDriver because nothing better existed,
and netOrk reads that role to decide what belongs in its wireless page and its
AP profile pickers, so a speaker showed up in both.
napalm-device-types now has MediaDriver, which is what this is. TYPE_LABEL
becomes "Media" rather than "Access Point".
Same root cause as netork#117.