Onkyo / Pioneer network remote control (eISCP protocol)

Remote control Onkyo/Pioneer from CLI and other

Main task - automatically turn on TuneIn radio from CLI and Home Assistant.

By default Home Assistant can change Onkyo source to TV, Aux, some other sources and Network.
But TuneIn is a Service inside network source. And Home Assistant can't go so deep.
Also python-eiscp don't work properly with receiving some control codes.
I receive "ValueError: Timeout waiting for response" or "AssertionError" if I try to send command NSV0E0. But command successful sends and receiver react on this. I was configuring it remotely and can't saw real feedback from AVR. Error was confused me and I was suggest that python-eiscp don't work with some ISCP codes.

For research I need tool with raw debug answers from receiver.
I download nodeJS node-eiscp and write CLI util:

$ cat /home/user/node_modules/eiscp/examples/onkyo.js

'use strict';
var util = require('util'),
    eiscp = require('../eiscp');
var args = process.argv.slice(2);
eiscp.connect({reconnect: false, verify_commands: false});
eiscp.on("data", console.log);
eiscp.on("error", util.log);
eiscp.on('connect', function () {
        eiscp.raw(args);
});

Usage: $ node onkyo.js COMMAND

node-eiscp automatically discover Onkyo AVR and work with it.
If discover don't work or you have more than one AVR you may specify IP address:
eiscp.connect({reconnect: false, host: "IPADDRESS", verify_commands: false});

I find eISCP protocol code list:
https://www.capitolsales.com/UserFiles/Documents/Technical%20Tips/Onkyo%20Serial%20Communication%20Protocol%202016.xlsx

First of all we need change source to Network: command SLI2B

Interesting excel-tab is "CMND(NET USB)"
(green cells for query/set, yellow cells - readonly)

We can see that NSV is a command for set service and 0E is a TuneIn. Last zero for account info. I don't test it.

Ok, we can start TuneIn service and can check it by command NLTQSTN:
$ node onkyo.js NSV0E0
$ node onkyo.js NLTQSTN

NLT is a NET/USB List Title Info
QSTN is a query command (QueSTioN)

Response must contain smth like that:
{ iscp_command: 'NLT0E01000000090100FF0E00TuneIn Radio',
  host: '192.168.XX.XX',
  port: '60128',
  model: 'TX-NR686' }

Actually my AVR send NLT automatically every connection.

We can use NTCUP/NTCDOWN/NTCSELECT Key commands for navigate menu.
Also we can set explicitly needed menu item by NLS

Select 7th menu line
node onkyo.js NLSL7

Select 16th index
node onkyo.js NLSI00016

Ok. For enable AVR and internet radio station we need these commands:
PWR01
SLI2B
NSV0E0
NLSI00001
NLSI00016

UPD June 2022:
Now we need use NTCSELECT after select network source and inside source.
Example for TuneIn -> My Presets -> Radio01:
PWR01
SLI2B
NSV0E0
NTCSELECT
NLSI00001
NLSI00001
NTCSELECT

This script enable AVR, set source to Network/TuneIn, select My Presets and select my preset station #16.

Don't forget wait some seconds between commands.

For integration with Home assistant add shell_command to configuration.yaml
onkyo_command: /srv/homeassistant/bin/onkyo --host {{ ip }} {{ cmd }}
/srv/homeassistant/bin/onkyo is a python-eiscp

Home assistant script:

onkyo_rp:

  alias: "Radio Paradise"

  sequence:

  - service: shell_command.onkyo_command

    data:

      ip: "192.168.XX.XX"

      cmd: "PWR01"

# wait until state is not "off"

  - wait_template: "{{ not is_state('media_player.onkyo_nr686', 'off') }}"

    timeout: '00:00:10'

    continue_on_timeout: 'false'

  - service: shell_command.onkyo_command

    data:

      ip: "192.168.XX.XX"

      cmd: "SLI2B"

  - delay: 1

  - service: shell_command.onkyo_command

    data:

      ip: "192.168.XX.XX"

      cmd: "NSV0E0"

  - delay: 1

  - service: shell_command.onkyo_command

    data:

      ip: "192.168.XX.XX"

      cmd: "NLSI00001"

  - delay: 1

  - service: shell_command.onkyo_command

    data:

      ip: "192.168.XX.XX"

      cmd: "NLSI00011"

Комментарии