Package: pyavreceiver
The goal of pyavreceiver is to provide a universal Python interface for Audio Video Receiver devices regardless of brand and supported protocols.InstallationRequires Python >= 3.8pip install pyavreceiverQuickstartpython3 -m asynciofrompyavreceiverimportfactoryd=awaitfactory("IP address to your receiver, string")awaitd.init()awaitd.main.update_all()d.main.power# get stateawaitd.main.set_power(True)# set stated.main.stated.main.commandsawaitd.disconnect()Supported DevicesDenon AVRs (alpha)Marantz AVRs (alpha)Designpyavreceiver is modeled on, and derivitave of, thepyheosproject.Some primary principals:Base classes for AVReceiver, Zone, Command, TelnetConnection, Message, HTTPApi should encapsulate the commonalities between devicesAll IO (other than initial file reads) is asynchronouspyavreceiver should subscribe to state rather than poll when possibleA device can have multiple connections or APIs: telnet, HTTP API, websocket, or UPnPThe connection to the device should heal itself if it is disconnectedTelnet Queue and Quality of ServiceThe telnet protocol is useful for maintaining realtime state of an AVR with low latency.  pyavreceiver usestelnetlib3.  Telnet commands are throttled according to manufacturer specification by means of aPriorityQueue.  ThePriorityQueueand relatedExpectedResponseQueueallow 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 anExpectedResponseto theExpectedResponseQueue.  ThisExpectedResponsewill 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 queueeven 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.ContributionsTesting, 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 usingaiohttpMessage (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 ininit.py