Pioneer AVR integration (supporting config flow and asyncio)

I wanted to share my updated Pioneer AVR integration for AVRs that support the older Pioneer serial API (pre-Onkyo). It supports configuration via both YAML and config flow, and handles the basics to integrate the AVR into Home Assistant: power, volume, source detection/selection and automatic zone detection for receivers supporting multiple zones. It also overcomes a major limitation of the Pioneer component that is included in HA Core: that component opens a new telnet connection for each command sent to the AVR, making it unstable over time (at least in my setup).

Right now it is not completely backwards compatible with the built-in Pioneer integration as the source mappings are queried from the AVR during the initial connection rather than manually specified in the configuration.

To install this integration, clone the GitHub repository, then move pioneer_async into your /config/custom_components directory. Restart Home Assistant, then go to Configuration > Integrations > Add (+). Alternatively, if you want to migrate from the built-in Pioneer AVR integration, change platform to pioneer_async and remove any sources mapping. You may need to update automations/scripts to reflect updated source names retrieved from the AVR.

Installation and updates via HACS is on the roadmap, as is more complete documentation, and potential future submission to HA Core as a replacement for the original Pioneer AVR integration.

I wrote this integration as part of teaching myself a few new shiny things: asyncio coding, enabling config flow, and how to release an integration, so feedback on better ways to do things is most welcome!

6 Likes

Hello @crowbarz
First, sorry for my english. Second, thank you for your integration. It work correctly with my VSX-528. Other version had a long delay when turning on or turning off the receiver. Now i have one problem. I do not see sources and I do not know how to add sources. Sorry about my lack of knowledge, but I am a “fresh user” of home assistant. Could you explain me how to do it, step by step? In which file should I write configuration code? I will be gratefull for that. I`ve tried to type in configuration.yaml something like that:

  - platform: pioneer
    name: Pioneer
    host: "pioneer ip"
    port: 8102
    scan_interval: 60
    timeout: 2.0
    sources: { SAT/CBL: '06', GAME: '49' }

Configuration check is ok but nothing changes after server restart. I can`t change sources.
Thank you…

Hi @prosilence, I configured my test system running HA Core 2020.12.1 and pioneer_async 0.3 with your config (using my own host/port) and it seems to work ok on my VSX-930. I have two questions/comments:

  1. Have you changed the platform to pioneer_async? Otherwise HA will use the built-in component instead of the custom component.
  2. Have you turned on the AVR first before trying to change sources? The sources list only appears when the AVR signals to the integration that the device is on.

If neither of these help, then I would suggest enabling API debugging (and restarting HA) to help understand what is happening:

logger:
  logs:
    aiopioneer: debug

Then check the aiopioneer debug in home-assistant.log in your config directory. There should be info messages for AVR state updates (eg. Power: True when the AVR updates after turning on the power), and debug messages for the commands that are sent to the AVR (eg. PO for power on) and responses received from the AVR (eg. PWR0 to signal the AVR has been turned on).

Hi
Thanks for your comment @crowbarz
My configuration.yaml:

- platform: pioneer_async
name: Pioneer AVR
host: "pioneer ip"
port: 8102
scan_interval: 60
timeout: 2.0
sources: { 'CD': '01', 'Tuner': '02', 'DVD': '04', 'TV': '05', SAT/CBL: '06', 'DVR/BDR': '15', 
'iPod/USB': '17', 'BD': '25', 'Adapter': '33', 'Netradio': '38', 'Media Server': '44', 'Favorites': '45', 'HDMI/MHL': '48', GAME: '49' }

Now i have invalid config:

Invalid config for [media_player.pioneer_async]: expected int for dictionary value @ data[‘scan_interval’]. Got datetime.timedelta(seconds=60). (See ?, line ?).

What HA version and integration version do you have installed? Are they both the latest versions?

Hi
Home Assistant 2020.12.0
pioneer_async version?? I do not know..

Look for VERSION in custom_components/pioneer_async/const.py. If that doesn’t exist then you are running a much older version, look for the aiopioneer dependency in custom_components/pioneer_async/manifest.json

Does the config work if you remove scan_interval ?

Also did you indent the config appropriately. The config you pasted isn’t indented to YAML rules: all the lines apart from the first needs to be indented by two spaces.

This config snippet loads fine on my dev instance of HA 2020.12.1 and pioneer_async integration version 0.3. Note I corrected the indentation and also moved all sources onto a single line. Pretty sure that YAML doesn’t allow you to split the sources line in the way shown in your post.

media_player:
  - platform: pioneer_async
    name: Pioneer AVR
    host: avr
    port: 8102
    scan_interval: 60
    timeout: 2.0
    sources: { 'CD': '01', 'Tuner': '02', 'DVD': '04', 'TV': '05', SAT/CBL: '06', 'DVR/BDR': '15', 'iPod/USB': '17', 'BD': '25', 'Adapter': '33', 'Netradio': '38', 'Media Server': '44', 'Favorites': '45', 'HDMI/MHL': '48', GAME: '49' }

I’m trying to install the integration. When using this config I also get the date-time error. Without it does work.

Do you have an option for the second HDMI output I can use?

scan_interval is defined as an int in the config schema for the platform, but despite that somewhere along the line it looks like it’s getting converted to a timedelta. I will try to change it to a timedelta and see if that’s any better.

Zones are detected by querying the current power settings on the AVR for each zone (ie. HDMI output). If it gets a value back from the AVR, then it assumes that the zone exists and creates a new media_player entity for that zones. Is there a second entity created in your setup? If not, then enable debug level debugging on the aiopioneer package to see what commands it is sending to the AVR and the responses it is getting back.

1 Like

The second hdmi output (sub) is seen as a zone in this integration. In a different pioneer integration i had a service to change output. That caused the confusion on my end.

For now I have no second zone defined and I see no second entity. I’ll try to tinker a bit the upcoming days and follow up if i cannot get it to work. Thanks!

cześć
Mam wersję 0.3, poprawiłem linię sources. Jak usunę scan_interval to wszystko działa?
Co to jest aiopioneer-0.1.3??

pojawiły mi się takie logi:

  • Platform pioneer_async does not generate unique IDs. ID 192.168.0.105:8102/1 already exists - ignoring media_player.pioneer_avr
  • Platform pioneer_async does not generate unique IDs. ID 192.168.0.105:8102/2 already exists - ignoring media_player.pioneer_avr_zone_2

I’m afraid that I don’t speak that language, but from the logs my guess is that you have the AVR defined more than once, either twice in configuration.yaml, or once in configuration.yaml and once through the Configuration > Integrations UI. You should only define each AVR once, even if it has more than one zone - the integration automatically creates additional media_player entities whenever it detects that an AVR supports multiple zones.

BTW I think I have fixed the scan_interval issue. The issue didn’t show up in my dev environment because it does not look like config validation runs when you first start up hass, only when you restart from within HA itself or when you run the config check. The manifest also includes a version now per requirements from 2021.3 onwards.

I have a second zone now:

But I still cannot figure out how to switch the HDMI output to ‘sub’ for my beamer. Can you maybe give me some pointers?

That screenshot looks like it’s from Settings > Devices, but the integration doesn’t support device actions yet. For each AVR device, there is an entity of the same name, and there you can turn the zone on/off and change the source.

To get to the entity, click on one of the zone devices. Then, in the Entities card, click on the entity. On the entity card that pops up, click the icon at the top right. When the zone is on, a Source drop-down list appears. (It does not appear if the zone is off.) All the inputs should appear in that list, select the one you want for that zone.

Is that what you are looking for?

1 Like

Hey there @crowbarz , first of all thanks for your work!
I’ve got a Pioneer VSX-932 and have been having trouble with all integrations to get it to work…some half work, some don’t at all.

This is my config:

media_player:
  - platform: pioneer_async
    host: 192.168.1.29
    port: 8102

(yes the ip is static set from the router, although it does not respond to pings but shows connected on my wifi)

I manually installed the component by unzipping it in custom_components and this is my debug output:

2021-08-24 19:11:14 INFO (MainThread) [aiopioneer.pioneer_avr] Starting aiopioneer 0.1.7
2021-08-24 19:11:14 DEBUG (MainThread) [aiopioneer.pioneer_avr] >> PioneerAVR.__init__(host="192.168.1.29", port=8102, timeout=2.0, params={})
2021-08-24 19:11:14 DEBUG (MainThread) [aiopioneer.pioneer_avr] >> PioneerAVR.set_user_params({})
2021-08-24 19:11:14 DEBUG (MainThread) [aiopioneer.pioneer_avr] >> PioneerAVR.connect() started
2021-08-24 19:11:14 DEBUG (MainThread) [aiopioneer.pioneer_avr] opening AVR connection
2021-08-24 19:11:16 ERROR (MainThread) [custom_components.pioneer_async.media_player] Could not open AVR connection: TimeoutError: 
2021-08-24 19:11:16 WARNING (MainThread) [homeassistant.components.media_player] Platform pioneer_async not ready yet: None; Retrying in background in 30 seconds
2021-08-24 19:11:16 DEBUG (MainThread) [aiopioneer.pioneer_avr] >> PioneerAVR.__del__()
2021-08-24 19:11:18 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.pioneer_async
2021-08-24 19:11:18 INFO (MainThread) [homeassistant.components.zeroconf] Starting Zeroconf broadcast
2021-08-24 19:11:18 ERROR (MainThread) [custom_components.pioneer_async.media_player] AVR "192.168.1.29:8102" is already configured

So it seems it can’t even connect at first but then complains it’s already configured? Didn’t find any entity (even in hidden) with pioneer on it, so i’m pretty stumped.
Any assistance is welcome :slight_smile:

Hi, did you add the integration via the UI (Configuration > Integrations) as well as configure it in configuration.yaml? You only need to configure it in one of those two places.

If you enable debug logging for custom_components.pioneer_async as well, you should see debug logs for async_setup_entry if the integration is set up via the UI, and async_setup_platform if set up via configuration.yaml. If you see both, then it is set up in both places, possibly with the same hostname/IP address and port. Delete one of the configurations and restart, and that log entry complaining about 192.168.1.29:8102 already being configured should go away.

The logs that you included shows that it couldn’t establish a connection to your AVR at 192.168.1.29 port 8102. See if you can manually establish a connection to the AVR (eg. via telnet 192.168.1.29 8102 or nc -vv 192.168.1.29 8102). You can also try port 23, that works for some receivers, or if supported by your model add an extra port on the AVR (via http://avr/1000/port_number.asp) and using that port.

None of the integrations will work at all until you are able to establish a connection to your AVR. I believe some integrations default to using port 23 rather than 8102, so that might be why some half work and some don’t work at all.

I swapped over to this new version and I find that after about a day the receivers become unavailable. I have to turn them on and restart HA for them to comeback. Both receivers have network standby turned on.

I’m setup via config_yaml.

Any thoughts?

Without HA and aiopioneer debug level logs, and at least a description of your setup including AVR model and config, I have absolutely no idea what’s wrong with your setup.

My AVR no longer becomes unavailable since the last version (which fixed an case in the AVR command thread that caused it to throw an exception), though I power cycle my AVR daily. In my experience, the network stack on the Pioneer AVRs themselves become unstable over time, no matter which HA integration is used.