Files
napalm-sonos/README.md
T
Christian Manivong 168841ebb8
driver / standard (pull_request) Successful in 13s
driver / lint (pull_request) Successful in 12s
driver / types (pull_request) Successful in 45s
driver / test (3.10) (pull_request) Successful in 2m40s
driver / test (3.11) (pull_request) Successful in 2m40s
driver / test (3.12) (pull_request) Successful in 2m37s
driver / test (3.13) (pull_request) Successful in 2m34s
driver / lowest (pull_request) Successful in 2m16s
driver / security (pull_request) Successful in 47s
driver / build (pull_request) Successful in 22s
CI / driver (pull_request) Successful in 15m6s
driver / publish (pull_request) Skipped
chore: adopt the NAPALM driver standard
- CI moves to .gitea/workflows/ci.yml and calls the shared driver workflow
  of NAPALM/driver-standard; .github/ is gone.
- napalm-device-types >=4.21.1 is now declared: the driver imports
  MediaDriver, PortSpec and FingerprintRule from it, and CI used to
  install it by hand.
- requires-python >=3.10 (napalm-device-types needs it), LICENSE, README,
  CHANGELOG, py.typed, SPDX license string, setuptools>=77, version floors
  on the dev extra, links to git.netork.io; .gitignore as in the template.
- mypy strict for the package; napalm_sonos.sonos_driver is exempt for now
  (5 errors, two of them return types that differ from MediaDriver's),
  recorded in the quality baseline.
- Coverage floor 71 % (measured 71.30 %).
2026-10-23 09:00:07 +02:00

64 lines
1.7 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`, `get_interfaces_ip` | `eth0` when the speaker is wired, always `wlan0` |
| `get_playback_state`, `get_current_track` | yes |
| `get_volume`, `set_volume`, `get_mute`, `set_mute` | yes |
| `play`, `pause`, `stop`, `next_track`, `previous_track` | yes |
| `get_group_info`, `get_zone_info` | yes |
## Not supported
Configuration management (`load_replace_candidate` and `load_merge_candidate` raise
`NotImplementedError`), the CLI, and every routing, LLDP, ARP, NTP, SNMP, BGP, user
and environment getter: they return empty results.
## 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