Files
napalm-sonos/README.md
T
Christian Manivong 397917a174
driver / standard (pull_request) Successful in 22s
driver / lint (pull_request) Successful in 16s
driver / types (pull_request) Successful in 1m3s
driver / test (3.12) (pull_request) Successful in 4m13s
driver / test (3.13) (pull_request) Successful in 4m5s
driver / lowest (pull_request) Successful in 3m38s
driver / build (pull_request) Successful in 30s
driver / security (pull_request) Successful in 1m19s
CI / driver (pull_request) Successful in 6m10s
driver / publish (pull_request) Skipped
fix(driver): leave get_interfaces_ip and cli to NAPALM's stubs
get_interfaces_ip reported the speaker's address with a prefix length
of 24 it never read: the speaker info has no netmask, and SoCo offers
no reading for one, so a speaker in a /23 or /25 network was reported
wrongly. cli answered [] -- not even NAPALM's dict shape -- for a
speaker that has no CLI. Both overrides are gone; NAPALM's stubs raise
NotImplementedError.

Closes #15
2026-11-12 19:23:25 +01:00

75 lines
2.6 KiB
Markdown

# napalm-sonos
NAPALM driver for **Sonos** speakers, built on
[napalm-device-types](https://git.netork.io/NAPALM/napalm-device-types) (`MediaDriver`).
It talks to the speaker through [SoCo](https://github.com/SoCo/SoCo).
## Tested against
| Model | Firmware |
|---|---|
| not recorded yet | |
## Connection
UPnP/SOAP over HTTP on port 1400, through SoCo. A Sonos speaker takes no login:
`username` and `password` are accepted for NAPALM's constructor and ignored.
`open()` reads the speaker info once; `is_alive()` checks that TCP port 1400 accepts
a connection.
```python
from napalm import get_network_driver
driver = get_network_driver("sonos")
with driver("192.0.2.20") as speaker:
print(speaker.get_facts())
print(speaker.get_playback_state())
```
## Supported
| Getter / action | |
|---|---|
| `get_facts` | from the speaker info read at `open()` |
| `get_interfaces` | one interface, `wlan0`, for the speaker's network connection (see below) |
| `get_playback_state` | `{"state": "playing"\|"paused"\|"stopped"\|"transitioning", "source": …}` (media contract) |
| `get_current_track` | yes |
| `get_volume`, `set_volume`, `get_mute`, `set_mute` | yes |
| `play`, `pause`, `stop`, `next_track`, `previous_track` | yes |
| `get_zone_info` | `[{"name", "coordinator", "members"}]` (media contract) |
| `get_group_info` | the group's coordinator and members with uid and address |
Whether a speaker is wired or wireless is **not known**: SoCo offers no reading for it
(`deviceProperties` is the UPnP service of that name, and none of its actions says), so
the driver reports no `eth0`. The one interface keeps the name `wlan0`; it stands for the
speaker's connection, whatever its medium.
## Not supported
Configuration management (`load_replace_candidate` and `load_merge_candidate` raise
`NotImplementedError`), configuration export (`get_config`), the CLI (`cli`, NAPALM's
stub), the interface addresses (`get_interfaces_ip`: the speaker reports no prefix
length, and SoCo has no reading for one), and every routing, LLDP, ARP, MAC table, NTP, SNMP, BGP, optics, probe, user, network-instance,
firewall-policy and environment getter. The driver leaves those getters to NAPALM,
whose stubs raise `NotImplementedError`: a speaker has no such data, and an empty
answer would read as "read, nothing there".
## Installation
```bash
pip install napalm-sonos
```
## Development
The rules are in [STANDARDS.md](https://git.netork.io/NAPALM/driver-standard/src/branch/main/STANDARDS.md).
```bash
python -m venv .venv && .venv/bin/pip install -e ".[dev]"
.venv/bin/pytest --cov
```
## License
Apache-2.0