Skip to main content

An async python library for controlling Audio Video Receiver devices

Project description

AV Receiver Logo

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.

QoS Diagram

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyavreceiver-0.0.10.tar.gz (28.9 kB view details)

Uploaded Source

Built Distribution

pyavreceiver-0.0.10-py3-none-any.whl (42.4 kB view details)

Uploaded Python 3

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

Hashes for pyavreceiver-0.0.10.tar.gz
Algorithm Hash digest
SHA256 53347376f82f655cee8e5ef82545704d1fbed50cc1ea71ed6828822989512fd2
MD5 ec5a84bcdb206f584bc625218ae7ff01
BLAKE2b-256 87357988e750fd0e9b839eedc36714daf4f1984bd1339782c3468bc3332d538b

See more details on using hashes here.

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

Hashes for pyavreceiver-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 d2a0410ed4e79e5d8c09973cc4b27c8c00c50c6e13bc79771adc46d469909e9b
MD5 e57a6d3ec18a4542237febbbc9a2fb20
BLAKE2b-256 fb2f474d3dc483cd32e47d89872ece79d6494a224b8e9b6de3264b2c7d63e67f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page