Integrate command line tool to control a receiver

Hello
I’m running home assistant on a raspberry pi 3b+.
I want to control my onkyo receiver next to the raspi. There is this command line tool for raspberry pi which does exactly that.
It’s python code which outputs the data on a GPIO pin that connects to the receiver.

How would I go about running this tool in home assistant?

Maybe this is interesting to other people too, because this tool allows you to control RI (Remote Interactive) compatible devices.

Try the command line switch and use the python command as either command_on or command_off. https://www.home-assistant.io/integrations/switch.command_line/

switch:
  - platform: command_line
    switches:
      my_receiver_command:
        command_on: "python main.py --gpio 25 0x1AE"

You might need to adjust the initial python to /usr/bin/python3 or whatever and wherever python interpreter you are using.

1 Like

Why not just use HA Onkyo integration? Controls both zone volume/power/source/maybe more but I not care beyond that

I think HDMI CEC or other HA integration will do same with less trouble but honestly depend on how you using your system so maybe that will be better for you.

Why not just use HA Onkyo integration? Controls both zone volume/power/source/maybe more but I not care beyond that

I think my Onkyo TX-8050 does not support ‘network standby’ so this wont be able to turn on the receiver. Also the onkyo only connects via LAN and I have no acces close by.

Thanks for the reply!

edit:
Just tried it. Can confirm TX-8050 can not be turned on via network.

Thank you for your help!

I will try to do that

“Network Control” must be set to enable in Onkyo menu

“Network Control” must be set to enable in Onkyo menu

Oh Im stupid, I see now.

Anyway, I tried the command line switch

switch:
  - platform: command_line
    switches:
      my_receiver_command:
        command_on: "python3 /config/onkyo/main.py --gpio 25 0x1AE"

But I get an error:

Command failed: python3 /config/onkyo/main.py --gpio 25 0x1AE

If I try the same thing with a file /test.py instead of /main.py --gpio 25 0x1AE I don’t get any error logs, so I think python3 itself works.

If I don’t get this running I might just get one of those Wifi to LAN thingys and connect to the receiver using the Onkyo component.

Thank you both for your help, really appreciate it.

edit:
I ran the command via ssh terminal and see now, that the error comes from importing ‘pigpio’

ModuleNotFoundError: No module named 'pigpio'

Did you install the pigpio module?

I found a Wifi to LAN thing. So this solves the issue.
Thanks again.

The Onkyo component gives only a few controls. I found that you can use shell commands to do more stuff.

edit:
I found this in the logs

/usr/src/homeassistant/homeassistant/components/onkyo/media_player.py", line 342, in turn_off

But when I try to to do a command like on this site

/usr/src/homeassistant/homeassistant/components/onkyo --discover

I get an error

b'/bin/sh: /usr/src/homeassistant/homeassistant/components/onkyo: Permission denied\n'
2020-02-23 04:52:41 ERROR (MainThread) [homeassistant.components.shell_command] Error running command: `/usr/src/homeassistant/homeassistant/components/onkyo --discover`, return code: 126
NoneType: None

Anyone knows how to use these onkyo commands properly?