Skip to main content

rn301 — Contrôle complet d'un Yamaha R-N301 (Python + web)

Français · English

CI License: MIT Python

Librairie Python et serveur web pour piloter un ampli hi-fi Yamaha R-N301 (2013) sans l'application officielle. Protocole YNC (Yamaha Network Control) reverse-engineered à partir de l'APK NP Controller 4.60 + validation live commande par commande sur le firmware 1.13/0.05.

100 % stdlib — zéro dépendance.

Le R-N301 ne publie aucun descripteur YNC (desc.xml → 404) : les librairies YNC génériques, qui découvrent les commandes via ce fichier, sont incapables de fonctionner avec lui. Les ~90 commandes ont donc été extraites en dur de l'APK NP Controller puis validées en live.

Le projet couvre les trois canaux de l'ampli — YNC (:80), MediaRenderer UPnP (:8080) et injection IR Remote_Signal — et exploite le MediaRenderer pour pousser de l'audio vers l'ampli (module localfilecontroller de l'app officielle).

                             ┌────────────────┐
                             │     rn301/     │
                             │   (library)    │
                             └───┬────────▲───┘
                HTTP + XML (YNC) │        │ UPnP/SOAP + GENA + HTTP
                             :80 │        │ :8080 (+ file server)
                         ┌───────▼────────▼──────┐
                         │      Yamaha R-N301     │
                         │      192.168.1.XX      │
                         │    (SSDP discovered)   │
                         └────────────────────────┘

Développé avec Qwen3.8 Max et Qwen3.8 Flash via Pi, dans Zed via ACP.

Démarrage rapide

# dans ce repo (aucune installation nécessaire)
python -c "from rn301 import discover_one, RN301; amp=RN301(discover_one()['host']); amp.power_on()"

# serveur web → http://localhost:8080
python -m webapp.server --port 8080 --amp 192.168.1.91

# tests hors-ligne (aucun ampli requis)
python -m unittest discover tests

Installer la lib dans un autre projet :

pip install -e ../rn301          # ou : uv add ../rn301 --editable

Le package expose deux CLI : rn301-discover (scan SSDP → JSON) et rn301-gena (écoute live des events GENA). Type hints inclus (py.typed).

Librairie rn301/

Client YNC complet, ~90 opérations validées en live. Gère les quirks firmware : requête unique par POST, retry sur réponses vides/400, délai 5 s sur RC=3 (ampli "occupé" après changement de source réseau).

from rn301 import RN301, discover_one
amp = RN301(discover_one()["host"])

amp.power_on(); amp.set_volume(25); amp.set_mute(True)
amp.set_input("SERVER")                    # 11 sources disponibles
amp.playback("SERVER", "Play")            # Play/Stop/Pause/Skip Fwd/Skip Rev
amp.set_shuffle("SERVER", True)
amp.cursor("SERVER", "Down")              # navigation menu DLNA/Net Radio
amp.tune_fm(99.1); amp.select_preset(3)   # tuner FM/AM
amp.remote_key("shuffle")                  # injection IR (device 7F01)

# escape hatch
amp.get("Main_Zone/Power_Control/Power")
amp.put("Main_Zone/Input/Input_Sel", "CD")

Référence complète : docs/YNC_COMMANDS.md.

Serveur web webapp/

Page de contrôle simple, responsive, sans dépendance externe + API JSON. Thème auto (sombre/clair). Refresh auto 4 s, volume/mute poussés par GENA via SSE (/api/events).

Fonctions : power, volume, mute, 11 sources, now-playing (pochette, play/pause/ skip, shuffle/repeat), tuner, navigateur DLNA/Net-Radio cliquable, push audio, Network Standby, touches IR.

Push DLNA

Le R-N301 expose un MediaRenderer UPnP sur :8080. Le projet sert le fichier en HTTP (Range/206) puis envoie SetAVTransportURI + Play en SOAP. L'ampli devient une source audio : TTS, webradios arbitraires, fichiers poussés depuis un téléphone — tout devient possible.

from rn301 import PushServer
push = PushServer("192.168.1.91")
push.push_file("track.flac", title="Morceau", artist="Moi")
push.wait_stopped(timeout=600)    # bloque sur l'event GENA, zéro polling
push.close()

Formats audio supportés : WAV, MP3, FLAC, MP4/M4A (l'audio d'une vidéo MP4 est bien lu), ALAC. Non supportés : WMA, OGG/Opus (le renderer affiche PLAYING mais aucun son ne sort).

Contraintes firmware : docs/DLNA_PUSH.md.

Télécommande virtuelle (à venir)

Le device IR 7F01 a été scanné intégralement (256/256 OBC acceptés par le firmware). Prochaine étape : capture des codes de la télécommande physique RAX31 (volume, power, Speaker A/B, Balance…) pour enrichir remote_key() avec les fonctions non exposées en YNC.

Reverse engineering

Le R-N301 n'expose aucun descripteur YNC (desc.xml → 404) : l'app officielle code les commandes en dur par modèle. Méthode : décompilation APK (androguard), sondage live, brute-force IR, validation croisée. Scripts d'analyse documentés dans tools/README.md, journal complet dans docs/RESEARCH.md.

Arborescence

├── rn301/               # librairie
│   ├── rn301.py         #   client YNC (~90 ops, retries, verrou)
│   ├── push.py          #   push DLNA (FileServer + SOAP + events GENA)
│   ├── gena.py          #   abonné GENA
│   ├── discover.py      #   découverte SSDP
│   └── _locks.py        #   sérialisation par ampli
├── webapp/              # serveur web + page de contrôle + API JSON
├── tests/               # tests hors-ligne (unittest + faux renderer UPnP)
├── docs/                # documentation avancée
├── tools/               # scripts d'analyse → voir tools/README.md
└── amp/                 # réponses live archivées (probes, scans IR, SCPDs)

Avertissements

  • Projet amateur non affilié à Yamaha. YNC non documenté officiellement.
  • Firmware capricieux : toujours prévoir des retries (la lib gère ça).
  • System/Misc/Update peut déclencher une mise à jour firmware — à n'utiliser qu'en connaissance de cause.
  • NET RADIO : le service vTuner intégré au R-N301 nécessite un compte payant (stations réduites) — c'est côté Yamaha/vTuner, pas côté protocole.

Licence

MIT (voir LICENSE). L'APK et les PDF Yamaha restent propriété Yamaha — non redistribués ici.

Metadata

Release files for rn301 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rn301 1.0.0
File Size Uploaded Provenance Actions
rn301-1.0.0.tar.gz 42.0 kB With provenance Details for rn301-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rn301 1.0.0
File Interpreter ABI Platform Actions
rn301-1.0.0-py3-none-any.whl Python 3 none any Details for rn301-1.0.0-py3-none-any.whl

Total release size: 77.7 kB

Release files / rn301-1.0.0.tar.gz

Download URL rn301-1.0.0.tar.gz
Size 42.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3647b2ae78a97a0b56c62ed76ae221415f71076f1a5b783cac3e943144b3995c
BLAKE2b-256 checksum
How to use checksums
213a7064012bfdacbc505fbc2538194ee8cfa2fb967c7e3f16bca2093b40d833
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / rn301-1.0.0-py3-none-any.whl

Download URL rn301-1.0.0-py3-none-any.whl
Size 35.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
05db0df8a1a9be9190205856d772c01b7052881cbe2f2f19527f705dfe38fca8
BLAKE2b-256 checksum
How to use checksums
3657b2ff78997e8e7edc8517ccfad9d7ee001614a614df726c1fce4ce179e401
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Security for rn301 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for rn301-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page