An async python library for controlling Audio Video Receiver devices
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyavreceiver-0.0.10.tar.gz
.
File metadata
- Download URL: pyavreceiver-0.0.10.tar.gz
- Upload date:
- Size: 28.9 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53347376f82f655cee8e5ef82545704d1fbed50cc1ea71ed6828822989512fd2 |
|
MD5 | ec5a84bcdb206f584bc625218ae7ff01 |
|
BLAKE2b-256 | 87357988e750fd0e9b839eedc36714daf4f1984bd1339782c3468bc3332d538b |
File details
Details for the file pyavreceiver-0.0.10-py3-none-any.whl
.
File metadata
- Download URL: pyavreceiver-0.0.10-py3-none-any.whl
- Upload date:
- Size: 42.4 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2a0410ed4e79e5d8c09973cc4b27c8c00c50c6e13bc79771adc46d469909e9b |
|
MD5 | e57a6d3ec18a4542237febbbc9a2fb20 |
|
BLAKE2b-256 | fb2f474d3dc483cd32e47d89872ece79d6494a224b8e9b6de3264b2c7d63e67f |