• Stars
    star
    442
  • Rank 95,190 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 12 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Control Onkyo A/V receivers over the network; usuable as a script, or as a Python library.

Onkyo eISCP Control

This is a Python library to control and interact with Onkyo receivers over the network. It is also a ready-made command line script you can use without knowing how to program.

Finally, this repository contains a YAML file containing all the commands defined by the Onkyo protocol, automatically generated by parsing the official documentation. Even if you are not using Python, you may find this file useful when implementing your own interface. See further down below for more information.

Installation

Most recent released version:

$ easy_install onkyo-eiscp

Usage

The package installs a script called onkyo, that can be used from the command line:

$ onkyo system-power=off

This will turn your receiver off. You may notice that you haven't given any information as to where in the network your receiver is. The script should in fact be able to find your Onkyo device by itself.

To see which receivers the script is able to find, you can use:

$ onkyo --discover

If you have multiple receivers on your network, then by default, it will simply connect to the first device found (which may be a different one every time).

You can select a specific one by filtering by name:

$ onkyo --discover
TX-NR709 192.168.178.200:60128 0009B0D34163
TX-NR609 192.168.178.169:60128 0009B0D24B75

$ onkyo -n 709 system-power=on

This will only turn on the TX-NR709 device.

Or using the unique identifier:

$ onkyo -i 0009B0D24B75 system-power=on

This will turn on the TX-NR609 device.

There is also an --all flag, to send you commands to all devices at once.

Finally, you are of course able to manually specify the device to connect to:

$ onkyo --host 172.20.0.144 volume=55
$ onkyo --host 172.20.0.144 --port 42424 volume=55

To find out which commands are available, use the --help-commands option.

Commands

A command consists of three parts: The zone, the command, and the arguments. Here are some examples:

system-power=on
zone2.power=on
main.balance=3

As you can see, the basic format is:

zone.command=argument

If you do not specify a zone, then main is assumed.

There are some variations on this syntax that are possible, for example the following are all equivalent:

power on
power:on
main.power on
main power on

In other words, instead of the . and = separators, whitespace may be used, and the colon : is an alternative to =. However, it's best to use the suggested syntax above.

The names of these commands are defined by this project, and are rewritten to actual low-level eISCP commands Onkyo uses. If you know them, you can also send such low-level commands directly:

$ onkyo SLI26     # Selects the "Tuner" source.

Notes on Power On

For the power on command to work while the device is in standby, make sure you turn on the obtusely named Setup -> Hardware -> Network -> Network Control option.

Without it, you can only connect to your receiver while it is already turned on.

Python module

In a simple case, this might look like this:

import eiscp

# Create a receiver object, connecting to the host
receiver = eiscp.eISCP('192.168.1.125')

# Turn the receiver on, select PC input
receiver.command('power on')
receiver.command('source pc')

receiver.disconnect()

Don't forget to call disconnect() to close the socket. You can also use a with statement:

with eiscp.eISCP('192.168.1.125') as receiver:
    receiver.command('source all-ch-stereo')

The command language is explained above. You can also be more explict with the structure:

receiver.command('power', 'on', zone='main')

If you prefer to send low-level ISCP commands directly, you can use the raw method:

receiver.raw('MVLUP')

The function command_to_iscp will allow you to convert a high-level command to a low-level ISCP message for use with eISCP.raw.

Receiving messages

The Onkyo receiver will send messages to you as well. Specifically, it returns a response to every command you send, either by repeating the command you have sent back to you, or, in case you sent a query message, reporting the answer to you query. It will also send unsolicited status updates to you whenver the state of the receiver changes.

API-wise, the eISCP.raw and eISCP.command return the response received from the Onkyo device. They are blocking.

To receive other messages, there is eISCP.get, which will either return a message or None. You may specify a custom timeout value.

Warning

At least for now, there is no queue. If you call eISCP.raw or eISCP.command, any messages not picked up via eISCP.get are lost.

A problem with the Onkyo protocol is that there is no fool-proof way to differentiate a response from unsolicited status updates. Generally, this won't be an issue, though in theory the response that is given to you after sending SLI05 may be a SLI06 update from another controller.

It is thus preferable to approach the protocol in a different way. Instead of using eISCP.raw or eISCP.command, which try to serialize the exchange into a request-response scheme, you may also use eISCP.send, which dispatches a message without waiting for a response. You would then use get to process all incoming messages in the same way, regardless of why they were sent. This works well, since a response to either a command or a query is no different than a status update.

Async API

There is also an experimental eiscp.Receiver, which has the same api as eiscp.eISCP, but uses a background thread for network communication. This allows you to handle incoming messages via a callback:

def message_received(message):
    print message

receiver = Receiver('...')
receiver.on_message = message_received

Note that the on_message handler is executed on the background thread, so you may want to use a queue.

For consistancy, eISCP.raw and eISCP.command are still designed to artificially block, while eISCP.send is non-blocking.

Device discovery

You can have it find the receivers on your local network:

for receiver in eiscp.eISCP.discover(timeout=5):
    receiver.command('power off')

This will turn off all the Onkyo receivers on your network.

A discovered device has an info attribute that gives you some data:

{'iscp_port': '60128', 'identifier': '0009B04448E0',
 'area_code': 'XX', 'model_name': 'TX-NR709', 'device_category': '1'}

Limitations

  • Some commands require a more complex argument structure, like variable-length strings, and those are not yet supported (you can send them in raw mode of course).

The YAML file

This repository contains a YAML file containing all the commands defined by the Onkyo protocol, automatically generated by parsing the official Excel documentation, and then further adjusted manually.

The idea is to have a computer-readable definition of the Onkyo protocol, where Onkyo's internal low-level commands are mapped to identifiers that can be understood by humans, and which include descriptions.

Parsing the Onkyo Excel document gets you astonishingly far, but there's a limit. The YAML file requires manual edits and fixes where the parser fails, including a lot of cosmetic corrections. Some of those have been made, but there's significant room for improving the YAML description of the protocol.

The process and the specific YAML formatting have been chosen to allow future changes to the Onkyo master document to be merged with the manual adjustments made as painlessly as possible.

To summarize, if you are implementing your own interface to Onkyo, even if it's in a language other than Python, I encourage you to consider using this YAML file as a basis for the command interface you provide to users. You'll have a complete list of available commands, values, and even supported devices.

Related Links

Documents from Onkyo describing the protocol, including lists of supported commands:
The repository on which this was originally based on:
https://github.com/compbrain/Onkyo-TX-NR708-Control
An implementation in Perl:
https://github.com/beanz/device-onkyo-perl
An implementation in C#:
http://code.google.com/p/onkyo-eiscp-remote-windows/
An implementation in Object-C:
https://github.com/janten/onkyo-eiscp-remote-mac
MQTT connectivity for onkyo-eiscp, adhering to the mqtt-smarthome specification:
https://github.com/owagner/onkyo2mqtt
Some Java code that deserves credit for providing the original Onkyo protocol documentation linked above:
https://sites.google.com/a/webarts.ca/toms-blog/Blog/new-blog-items/javaeiscp-integraserialcontrolprotocol

More Repositories

1

webassets

Asset management for Python web development.
Python
917
star
2

flask-assets

Flask webassets integration.
Python
443
star
3

k8s-snapshots

Automatic Volume Snapshots on Kubernetes.
Python
348
star
4

tarsnapper

tarsnap wrapper which expires backups using a gfs-scheme.
Python
220
star
5

android-autostarts

Tool to manage autostarts (broadcast receivers) on an Android device.
Java
195
star
6

android2po

Convert Android string resources to gettext, and back.
Python
125
star
7

python-glob2

Version of the glob module that supports recursion via **, and can capture patterns.
Python
123
star
8

django-assets

Django webassets integration.
Python
89
star
9

android-platform_sdk

To keep the deprecated apkbuilder tool alive should it break.
Java
64
star
10

gitolite-simple-mirror

post-receive hook to do make mirroring with gitolite easy.
Shell
54
star
11

ripple-python

Ripple-related routines in Python. Might become a proper client library later.
Python
49
star
12

py-androidbuild

Routines to build an Android app in Python and to get rid of Ant.
Python
46
star
13

sendtokindle

Grahical Send to Kindle Utility for Ubuntu
Python
45
star
14

dockerfiles

Some of my dockerfiles.
Dockerfile
43
star
15

ntfslink

A set of Windows Shell Extensions, providing extended functionality for creating and using hard links and junction points on NTFS file systems.
Pascal
42
star
16

linuxutils

Stuff I use on Linux.
Python
30
star
17

react-arrow

React component that renders a SVG arrow. Can point in any direction, different styles.
JavaScript
19
star
18

wasmbind

Nicer Python interface to Webassembly modules.
Python
17
star
19

elrc-maker

Tool to create Enhanced LRC files.
JavaScript
15
star
20

android-remote-stacktrace

Fork of android-remote-stacktrace to fit my personal needs.
Java
13
star
21

mfcobol-export

Exporter for Microfocus COBOL databases.
Python
13
star
22

python-closure

Closure compiler packaged for Python
Python
12
star
23

sonosweb

Import of purple.org/sonos
Perl
12
star
24

ripple-sepa-bridge

Python
12
star
25

emma

Import of "emma - extendable MySQL managing assistant"
Python
12
star
26

feedplatform

FeedPlatform implements the core functionality of a feed aggregator. It is supposed to be reusable and extremely flexible, mainly intended for integration with other applications.
Python
10
star
27

janos

Java-based Sonos Controller (SVN import from http://sourceforge.net/projects/janos/)
Java
10
star
28

django-tables

Deprecated in favor of django-tables2. This exists to keep old urls working.
Python
9
star
29

sorl-thumbnail

Python
9
star
30

xappy

Python
8
star
31

trio-asgi-server

Python
8
star
32

python-akismet

The voidspace.org.uk Akismet Python library with some fixes.
Python
8
star
33

python-multiprocessing

With patch for #18, to make it usable with celery.
7
star
34

synology-sipgate-sms

Send SMS notifications on Synology NAS via Sipgate.
Python
7
star
35

trio-protocol

Run asyncio protocols on top of trio
Python
7
star
36

docker-gitolite

Shell
7
star
37

jmap-python

A JMAP library in Python.
Python
6
star
38

influx-sansio

Python
6
star
39

ripple2go

Compiled version of the ripple client that runs on Github Pages. Fork the repository to get your own.
JavaScript
6
star
40

gevent-erlang-mode

Ad hoc, informally-specified, bug-ridden, slow implementations of some Erlang-style concepts in gevent.
Python
6
star
41

pysieved

The original branch seems to be broken with the git client in etch stable
Python
6
star
42

rsnapgraph

git import of rsnapgraph; Make it work with gnuplot 4.4
Perl
5
star
43

ripple-wcg-badges

HTML
5
star
44

openinghours.js

Query schema.org OpeningHoursSpecification in JavaScript.
TypeScript
5
star
45

allthekeeps

Explorer for the Keep and TBTC networks.
TypeScript
5
star
46

wifilock

Android App, ensures that the Wi-Fi radio will stay awake when the Phone goes to sleep.
Java
5
star
47

onkyo-eiscp-dotnet

Control Onkyo A/V receivers over the network; in C#, or on the command line. C# port of onkyo-eiscp for Python.
C#
4
star
48

python-smartinspect

A SmartInspect client library for Python (http://www.gurock.com/products/smartinspect/).
Python
4
star
49

ripple-federation-python

ripple/federation-php for Python.
Python
4
star
50

keepscore-android

Keep track of player scores during a card game.
Java
4
star
51

ripple-id

Webservice to identify ripple addresses
Python
4
star
52

ituneslp-tools

Tools to work with iTunes LP / iTunes Extras projects.
JavaScript
4
star
53

SynologyDownloadAssistant

Download directly to your synology diskstation
JavaScript
3
star
54

fretsonfire

Python
3
star
55

stgit

3
star
56

my-logcheck-db

My personal collection of custom logcheck rules, and a small script to apply them.
Python
3
star
57

reposync

Automate mirroring repositories, for example to github.
Python
3
star
58

php-languid

A statistical language guesser in PHP. Port of Maciej Ceglowski's Language::Guess.
PHP
3
star
59

corporeal

Clean, simple Windows Password Manager
Pascal
3
star
60

django-filebrowser

Fork of django-filebrowser that does not require django-grappelli
ActionScript
3
star
61

babel

Git import of python-babel
Python
3
star
62

jinja2utils

My personal collection of Jinja2 utilities.
Python
2
star
63

wsconfig

A tiny utility to automatize setting up a new workstation; linking config files and installing packages.
Python
2
star
64

protobuf

Google Protocol Buffers
C++
2
star
65

consul2vulcan

Go
2
star
66

islamic-patterns

TypeScript
2
star
67

track0

A web spider that makes sense (to me)
Python
2
star
68

gandi-python

Gandi CLI client.
Python
2
star
69

pyparsing

Another git import of pyparsing that won't be kept up to date.
Python
2
star
70

feedparser

Tracks feedparser SVN repository, plus some patches of mine.
Python
2
star
71

wormtail

Pascal
2
star
72

vandelay

A build tool.
Python
2
star
73

django-xappy

Bridges the Xappy Xapian interface with Django.
Python
2
star
74

dvd-vr

Git import. Allow [label] to fallback to timestamp.
C
1
star
75

qdump

Very basic pastebin, Rails test app.
Ruby
1
star
76

import-all-ppa-keys

Copy of http://dev.firefly-it.de/repositories/show/lki
1
star
77

remember

remember, remember...
JavaScript
1
star
78

metadatad

Python
1
star
79

winutils

Stuff I use on Windows.
1
star
80

docker-deploy

Very much hacked together, and a work in progress for now.
Python
1
star
81

gajim-messaging-menu

Integrates Gajim with the Ubuntu Messaging Menu
Python
1
star
82

genericapi

Python
1
star
83

whatisripple.info

One-page explanation of the Ripple payment network, with images.
HTML
1
star
84

yyafl

Clone of git://git.stackfoundry.com/yyafl.git
Python
1
star
85

moneymoney-truelayer

TrueLayer extension for MoneyMoney.app
Lua
1
star
86

gwmap

Mapping Guild Wars with Google Maps.
JavaScript
1
star
87

descarty

A self-hostable Web History.
Python
1
star
88

textgrid-ui

TypeScript
1
star
89

jix

Port of the py.test fixture system to JavaScript
JavaScript
1
star
90

confcollect

Configuration loader for 12factor Python apps, framework-agnostic.
Python
1
star
91

rippletxt

Python parser for ripple.txt
Python
1
star
92

py-snaptests

Python
1
star
93

worldofphoto-i18n

A World of Photo i18n files
Shell
1
star
94

mp3diags

SVN import of Mp3Diags trunk. Does not contain the full history, since /trunk did not always exist.
C++
1
star
95

localtodo

.gitignore local todo files, but sync them through Dropbox.
Python
1
star
96

react-navigation-views

Import of the npm package by the same name, which itself is an extract of the code from React-Native
JavaScript
1
star
97

hibiscus-cvsimport

There is a real git mirror now, see willuhn/hibiscus // git cvsimport for Hibiscus Jameica plugin from www.willuhn.de; to build, you still need a Jameica CVS checkout (see also http://blog.elsdoerfer.name/2011/07/14/building-hibiscus/).
Java
1
star