The goal of pyavreceiver is to provide a universal Python interface for Audio Video Receiver devices regardless of brand and supported protocols.
Installation
Requires Python >= 3.8
pip install pyavreceiver
Quickstart
python3 -m asyncio
from pyavreceiver import factory
d = await factory("IP address to your receiver, string")
await d.init()
await d.main.update_all()
d.main.power # get state
await d.main.set_power(True) # set state
d.main.state
d.main.commands
await d.disconnect()
Supported Devices
- Denon AVRs (alpha)
- Marantz AVRs (alpha)
Design
pyavreceiver is modeled on, and derivitave of, the pyheos project.
Some primary principals:
- Base classes for AVReceiver, Zone, Command, TelnetConnection, Message, HTTPApi should encapsulate the commonalities between devices
- All IO (other than initial file reads) is asynchronous
- pyavreceiver should subscribe to state rather than poll when possible
- A device can have multiple connections or APIs: telnet, HTTP API, websocket, or UPnP
- The connection to the device should heal itself if it is disconnected
Telnet Queue and Quality of Service
The telnet protocol is useful for maintaining realtime state of an AVR with low latency. pyavreceiver uses telnetlib3. Telnet commands are throttled according to manufacturer specification by means of a PriorityQueue. The PriorityQueue and related ExpectedResponseQueue allow for varying levels of QoS. For example, a QoS 0 command has no QoS and can in fact be issued synchronously (eg. for rapid incremental volume changes).
All commands above 0 QoS will add an ExpectedResponse to the ExpectedResponseQueue. This ExpectedResponse will be cleared from the queue if 1) the device replies to the command or 2) the command expires (retires expended or default expiration of 1.5s exceeded). Higher levels of QoS will be executed before lower QoS commands in the queue even if the lower QoS command was issued first. Only two commands, power and mute, are set to the highest QoS level of 3 with most commands at 2.
Contributions
Testing, bug reports, and contributions are welcome. New devices should be modeled from the denon folder. A new brand of receiver will inherit from the base classes provided by pyavreceiver. Command dictionaries, if necessary, should be included in YAML format.
Command (commands.py, commands.yaml)
The Command class is responsible for constructing a message to send to the device. The methods .set_val and .set_query return new instances of the command with an argument set.
HTTPApi (http_api.py)
The HTTPApi class should contain methods and commands for interacting with a device using aiohttp
Message (response.py)
The Message class is responsible for interpreting a message from the device. There could be TelnetMessage, UpnpMessage, HTTPMessage, etc.
Receiver (receiver.py)
The Receiver class can be subclassed to add any unique attributes.
TelnetConnection (telnet_connection.py)
The TelnetConnection class must provide a response_handler for receiving telnet messages.
Zone (zone.py)
The Zone class can be subclassed to provide extra unique attributes or add alternative command protocols (HTTP, UPnP, etc.) for wide support.
factory (init.py)
Your new device should be identifiable and added to the factory function in init.py
Metadata
Release files for pyavreceiver 0.0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyavreceiver-0.0.10.tar.gz | 28.9 kB | Without provenance | Details for pyavreceiver-0.0.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyavreceiver-0.0.10-py3-none-any.whl | Python 3 | none | any | Details for pyavreceiver-0.0.10-py3-none-any.whl |
Total release size: 71.3 kB
Release files / pyavreceiver-0.0.10.tar.gz
| Download URL | pyavreceiver-0.0.10.tar.gz |
|---|---|
| Size | 28.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
53347376f82f655cee8e5ef82545704d1fbed50cc1ea71ed6828822989512fd2
|
|
BLAKE2b-256 checksum How to use checksums |
87357988e750fd0e9b839eedc36714daf4f1984bd1339782c3468bc3332d538b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.2
|
Release files / pyavreceiver-0.0.10-py3-none-any.whl
| Download URL | pyavreceiver-0.0.10-py3-none-any.whl |
|---|---|
| Size | 42.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d2a0410ed4e79e5d8c09973cc4b27c8c00c50c6e13bc79771adc46d469909e9b
|
|
BLAKE2b-256 checksum How to use checksums |
fb2f474d3dc483cd32e47d89872ece79d6494a224b8e9b6de3264b2c7d63e67f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.2
|
Security for pyavreceiver 0.0.10
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.