dannytrigo-onkyo-eiscp


Namedannytrigo-onkyo-eiscp JSON
Version 1.2.14 PyPI version JSON
download
home_pagehttps://github.com/dannytrigo/onkyo-eiscp
SummaryControl Onkyo receivers over ethernet. (dannytrigo fork for bugfix)
upload_time2024-04-12 16:36:12
maintainerNone
docs_urlNone
authorMichael Elsdörfer
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements netifaces xmltodict
Travis-CI
coveralls test coverage No coveralls.
            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:

.. code:: python

    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:

.. code:: python

    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:

.. code:: python

    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:

.. code:: python

    {'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:
    - http://michael.elsdoerfer.name/onkyo/ISCP_AVR_134.xlsx
    - http://michael.elsdoerfer.name/onkyo/ISCP_AVR_2014.Models.xlsx
    - http://michael.elsdoerfer.name/onkyo/ISCP-V1.26_2013.xlsx
    - http://michael.elsdoerfer.name/onkyo/ISCP-V1.21_2011.xls

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dannytrigo/onkyo-eiscp",
    "name": "dannytrigo-onkyo-eiscp",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Michael Elsd\u00f6rfer",
    "author_email": "michael@elsdoerfer.com",
    "download_url": "https://files.pythonhosted.org/packages/9b/b4/16201202b77d6d159c4086555759ad52f63eac028022e86271c095aa7424/dannytrigo_onkyo_eiscp-1.2.14.tar.gz",
    "platform": "any",
    "description": "Onkyo eISCP Control\r\n===================\r\n\r\nThis is a Python library to control and interact with Onkyo receivers\r\nover the network. It is also a ready-made command line script you\r\ncan use without knowing how to program.\r\n\r\nFinally, this repository contains a YAML file containing all the\r\ncommands defined by the Onkyo protocol, automatically generated by\r\nparsing the official documentation. Even if you are not using\r\nPython, you may find this file useful when implementing your own\r\ninterface. See further down below for more information.\r\n\r\n\r\nInstallation\r\n------------\r\n\r\nMost recent released version::\r\n\r\n    $ easy_install onkyo-eiscp\r\n\r\n\r\nUsage\r\n-----\r\n\r\nThe package installs a script called ``onkyo``, that can be used from the\r\ncommand line::\r\n\r\n    $ onkyo system-power=off\r\n\r\nThis will turn your receiver off. You may notice that you haven't given any\r\ninformation as to where in the network your receiver is. The script should\r\nin fact be able to find your Onkyo device by itself.\r\n\r\nTo see which receivers the script is able to find, you can use::\r\n\r\n    $ onkyo --discover\r\n\r\nIf you have multiple receivers on your network, then by default, it will\r\nsimply connect to the first device found (which may be a different one\r\nevery time).\r\n\r\nYou can select a specific one by filtering by name::\r\n\r\n    $ onkyo --discover\r\n    TX-NR709 192.168.178.200:60128 0009B0D34163\r\n    TX-NR609 192.168.178.169:60128 0009B0D24B75\r\n   \r\n    $ onkyo -n 709 system-power=on\r\n\r\nThis will only turn on the TX-NR709 device.\r\n\r\nOr using the unique identifier::\r\n\r\n    $ onkyo -i 0009B0D24B75 system-power=on\r\n\r\nThis will turn on the TX-NR609 device.\r\n\r\nThere is also an ``--all`` flag, to send you commands to all devices at once.\r\n\r\nFinally, you are of course able to manually specify the device to connect to::\r\n\r\n    $ onkyo --host 172.20.0.144 volume=55\r\n    $ onkyo --host 172.20.0.144 --port 42424 volume=55\r\n\r\nTo find out which commands are available, use the ``--help-commands`` option.\r\n\r\n\r\nCommands\r\n--------\r\n\r\nA command consists of three parts: The zone, the command, and the arguments.\r\nHere are some examples::\r\n\r\n    system-power=on\r\n    zone2.power=on\r\n    main.balance=3\r\n\r\nAs you can see, the basic format is::\r\n\r\n    zone.command=argument\r\n\r\nIf you do not specify a zone, then ``main`` is assumed.\r\n\r\nThere are some variations on this syntax that are possible, for example the\r\nfollowing are all equivalent::\r\n\r\n    power on\r\n    power:on\r\n    main.power on\r\n    main power on\r\n\r\nIn other words, instead of the ``.`` and ``=`` separators, whitespace may\r\nbe used, and the colon ``:`` is an alternative to ``=``. However, it's best\r\nto use the suggested syntax above.\r\n\r\nThe names of these commands are defined by this project, and are rewritten\r\nto actual low-level eISCP commands Onkyo uses. If you know them, you can\r\nalso send such low-level commands directly::\r\n\r\n    $ onkyo SLI26     # Selects the \"Tuner\" source.\r\n\r\n\r\nNotes on Power On\r\n~~~~~~~~~~~~~~~~~\r\n\r\nFor the ``power on`` command to work while the device is in standby, make\r\nsure you turn on the obtusely named\r\n``Setup -> Hardware -> Network -> Network Control`` option.\r\n\r\nWithout it, you can only connect to your receiver while it is already\r\nturned on.\r\n\r\n\r\nPython module\r\n-------------\r\n\r\nIn a simple case, this might look like this:\r\n\r\n.. code:: python\r\n\r\n    import eiscp\r\n\r\n    # Create a receiver object, connecting to the host\r\n    receiver = eiscp.eISCP('192.168.1.125')\r\n\r\n    # Turn the receiver on, select PC input\r\n    receiver.command('power on')\r\n    receiver.command('source pc')\r\n\r\n    receiver.disconnect()\r\n\r\nDon't forget to call ``disconnect()`` to close the socket. You can also use\r\na ``with`` statement:\r\n\r\n.. code:: python\r\n\r\n    with eiscp.eISCP('192.168.1.125') as receiver:\r\n        receiver.command('source all-ch-stereo')\r\n\r\n\r\nThe command language is explained above. You can also be more explict with\r\nthe structure::\r\n\r\n    receiver.command('power', 'on', zone='main')\r\n\r\nIf you prefer to send low-level ISCP commands directly, you can use the\r\n`raw` method::\r\n\r\n    receiver.raw('MVLUP')\r\n\r\nThe function `command_to_iscp` will allow you to convert a high-level\r\ncommand to a low-level ISCP message for use with `eISCP.raw`.\r\n\r\n\r\nReceiving messages\r\n~~~~~~~~~~~~~~~~~~\r\n\r\nThe Onkyo receiver will send messages to you as well. Specifically, it\r\nreturns a response to every command you send, either by repeating the\r\ncommand you have sent back to you, or, in case you sent a query\r\nmessage, reporting the answer to you query. It will also send unsolicited\r\nstatus updates to you whenver the state of the receiver changes.\r\n\r\nAPI-wise, the `eISCP.raw` and `eISCP.command` return the\r\nresponse received from the Onkyo device. They are blocking.\r\n\r\nTo receive other messages, there is `eISCP.get`, which will\r\neither return a message or ``None``. You may specify a custom timeout\r\nvalue.\r\n\r\n.. warning::\r\n    At least for now, there is no queue. If you call\r\n    `eISCP.raw` or `eISCP.command`, any messages not picked\r\n    up via `eISCP.get` are lost.\r\n\r\nA problem with the Onkyo protocol is that there is no fool-proof way to\r\ndifferentiate a response from unsolicited status updates. Generally, this\r\nwon't be an issue, though in theory the response that is given to you\r\nafter sending ``SLI05`` may be a ``SLI06`` update from another controller.\r\n\r\nIt is thus preferable to approach the protocol in a different way. Instead\r\nof using `eISCP.raw` or `eISCP.command`, which try to serialize\r\nthe exchange into a request-response scheme, you may also use\r\n`eISCP.send`, which dispatches a message without waiting for a response.\r\nYou would then use `get` to process all incoming messages in the same\r\nway, regardless of why they were sent. This works well, since a response to\r\neither a command or a query is no different than a status update.\r\n\r\n\r\nAsync API\r\n~~~~~~~~~\r\n\r\nThere is also an experimental `eiscp.Receiver`, which has the\r\nsame api as `eiscp.eISCP`, but uses a background thread for\r\nnetwork communication. This allows you to handle incoming messages\r\nvia a callback::\r\n\r\n    def message_received(message):\r\n        print message\r\n\r\n    receiver = Receiver('...')\r\n    receiver.on_message = message_received\r\n\r\nNote that the ``on_message`` handler is executed on the background\r\nthread, so you may want to use a queue.\r\n\r\nFor consistancy, `eISCP.raw` and `eISCP.command` are still\r\ndesigned to artificially block, while `eISCP.send` is non-blocking.\r\n\r\n\r\nDevice discovery\r\n~~~~~~~~~~~~~~~~\r\n\r\nYou can have it find the receivers on your local network:\r\n\r\n.. code:: python\r\n\r\n    for receiver in eiscp.eISCP.discover(timeout=5):\r\n        receiver.command('power off')\r\n\r\nThis will turn off all the Onkyo receivers on your network.\r\n\r\nA discovered device has an ``info`` attribute that gives you some data:\r\n\r\n.. code:: python\r\n\r\n    {'iscp_port': '60128', 'identifier': '0009B04448E0',\r\n     'area_code': 'XX', 'model_name': 'TX-NR709', 'device_category': '1'}\r\n\r\n\r\nLimitations\r\n-----------\r\n\r\n- Some commands require a more complex argument structure, like\r\n  variable-length strings, and those are not yet supported (you can\r\n  send them in raw mode of course).\r\n\r\n\r\nThe YAML file\r\n-------------\r\n\r\nThis repository contains a YAML file containing all the commands\r\ndefined by the Onkyo protocol, automatically generated by\r\nparsing the official Excel documentation, and then further adjusted\r\nmanually.\r\n\r\nThe idea is to have a computer-readable definition of the Onkyo\r\nprotocol, where Onkyo's internal low-level commands are mapped to\r\nidentifiers that can be understood by humans, and which include\r\ndescriptions.\r\n\r\nParsing the Onkyo Excel document gets you astonishingly far, but\r\nthere's a limit. The YAML file requires manual edits and fixes where\r\nthe parser fails, including a lot of cosmetic corrections. Some of\r\nthose have been made, but there's significant room for improving\r\nthe YAML description of the protocol.\r\n\r\nThe process and the specific YAML formatting have been chosen to\r\nallow future changes to the Onkyo master document to be merged with\r\nthe manual adjustments made as painlessly as possible.\r\n\r\nTo summarize, if you are implementing your own interface to Onkyo,\r\neven if it's in a language other than Python, I encourage you to\r\nconsider using this YAML file as a basis for the command interface\r\nyou provide to users. You'll have a complete list of available\r\ncommands, values, and even supported devices.\r\n\r\n\r\nRelated Links\r\n-------------\r\n\r\nDocuments from Onkyo describing the protocol, including lists of supported commands:\r\n    - http://michael.elsdoerfer.name/onkyo/ISCP_AVR_134.xlsx\r\n    - http://michael.elsdoerfer.name/onkyo/ISCP_AVR_2014.Models.xlsx\r\n    - http://michael.elsdoerfer.name/onkyo/ISCP-V1.26_2013.xlsx\r\n    - http://michael.elsdoerfer.name/onkyo/ISCP-V1.21_2011.xls\r\n\r\nThe repository on which this was originally based on:\r\n    https://github.com/compbrain/Onkyo-TX-NR708-Control\r\n\r\nAn implementation in Perl:\r\n    https://github.com/beanz/device-onkyo-perl\r\n\r\nAn implementation in C#:\r\n    http://code.google.com/p/onkyo-eiscp-remote-windows/\r\n\r\nAn implementation in Object-C:\r\n    https://github.com/janten/onkyo-eiscp-remote-mac\r\n\r\nMQTT connectivity for onkyo-eiscp, adhering to the mqtt-smarthome specification:\r\n    https://github.com/owagner/onkyo2mqtt\r\n\r\nSome Java code that deserves credit for providing the original Onkyo protocol documentation linked above:\r\n    https://sites.google.com/a/webarts.ca/toms-blog/Blog/new-blog-items/javaeiscp-integraserialcontrolprotocol\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Control Onkyo receivers over ethernet. (dannytrigo fork for bugfix)",
    "version": "1.2.14",
    "project_urls": {
        "Homepage": "https://github.com/dannytrigo/onkyo-eiscp"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "72c0cbc311678aeaa9416c22e7ee5cf716863796e3ea3197096a44a398ecbfef",
                "md5": "627791e918bd70a936db50f50404903c",
                "sha256": "831cfafb8c7f694efcf0c15ac492ec4188966fff2ac5fa8b384738798d113f21"
            },
            "downloads": -1,
            "filename": "dannytrigo_onkyo_eiscp-1.2.14-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "627791e918bd70a936db50f50404903c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 48944,
            "upload_time": "2024-04-12T16:36:11",
            "upload_time_iso_8601": "2024-04-12T16:36:11.012658Z",
            "url": "https://files.pythonhosted.org/packages/72/c0/cbc311678aeaa9416c22e7ee5cf716863796e3ea3197096a44a398ecbfef/dannytrigo_onkyo_eiscp-1.2.14-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9bb416201202b77d6d159c4086555759ad52f63eac028022e86271c095aa7424",
                "md5": "cc1ea32b65f64dfa2bd167f71e7f0110",
                "sha256": "057b006b27fcd4f62b380e09f65861198169f5b6401bc6a3310b7e1f814c110c"
            },
            "downloads": -1,
            "filename": "dannytrigo_onkyo_eiscp-1.2.14.tar.gz",
            "has_sig": false,
            "md5_digest": "cc1ea32b65f64dfa2bd167f71e7f0110",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 48022,
            "upload_time": "2024-04-12T16:36:12",
            "upload_time_iso_8601": "2024-04-12T16:36:12.648923Z",
            "url": "https://files.pythonhosted.org/packages/9b/b4/16201202b77d6d159c4086555759ad52f63eac028022e86271c095aa7424/dannytrigo_onkyo_eiscp-1.2.14.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-12 16:36:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dannytrigo",
    "github_project": "onkyo-eiscp",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "netifaces",
            "specs": [
                [
                    "==",
                    "0.11.0"
                ]
            ]
        },
        {
            "name": "xmltodict",
            "specs": [
                [
                    "==",
                    "0.13.0"
                ]
            ]
        }
    ],
    "lcname": "dannytrigo-onkyo-eiscp"
}
        
Elapsed time: 0.22615s