Closed pantherale0 closed 1 year ago
You need to put back your changes param.py
file.
py .\test_api.py -h 192.168.4.44
Traceback (most recent call last):
File "C:\Users\darre\source\repos\JHiopioneer\test_api.py", line 10, in <module>
from aiopioneer import PioneerAVR
File "C:\Users\darre\source\repos\JHiopioneer\aiopioneer\__init__.py", line 3, in <module>
from .pioneer_avr import PioneerAVR
File "C:\Users\darre\source\repos\JHiopioneer\aiopioneer\pioneer_avr.py", line 16, in <module>
from .param import (
ImportError: cannot import name 'LISTENING_MODES' from 'aiopioneer.param' (C:\Users\darre\source\repos\JHiopioneer\aiopioneer\param.py)
No changes have been made in the param.py file which is interesting.
Checked out the right branch?
Okay, too many versions out there... I got it now. Here are the results.
VST
works, but AST
still had a glitch.
Okay, figured it out. It needs to be just after the Audio: Output Channel Surround-Back-Right:
if self.audio.get("1").get("output_channels").get("SBR") is not bool(int(value[32:33])):
_LOGGER.info("Audio: Output Channel Surround-Back-Right: %s", "active" if bool(int(value[32:33])) else "inactive")
self.audio["1"]["output_channels"]["SBR"] = "active" if bool(int(value[32:33])) else "inactive"
## FY11 AVRs do not have any data bits (VSX-1021)
if len(value) > 33:
if self.audio.get("1").get("output_channels").get("SW") is not bool(int(value[33:34])):
_LOGGER.info("Audio: Output Channel SW: %s", "active" if bool(int(value[33:34])) else "inactive")
self.audio["1"]["output_channels"]["SW"] = "active" if bool(int(value[33:34])) else "inactive"
Then the log looks like this:
2023-03-04 14:04:46 INFO: Audio: Output Channel Surround-Back-Right: inactive
2023-03-04 14:04:46 INFO: Audio: Input Multi-Channel: False
2023-03-04 14:04:46 DEBUG: AVR command ?AST returned response: AST030200000000000000001010000010000
2023-03-04 14:04:46 DEBUG: delaying command for 0.080 s
2023-03-04 14:04:46 DEBUG: sending AVR command: ?VST
2023-03-04 14:04:46 DEBUG: AVR command ?VST returned response: VST10000000000000031111100000000
2023-03-04 14:04:46 DEBUG: delaying command for 0.089 s
2023-03-04 14:04:46 DEBUG: sending AVR command: ?TO
Would you be able to test again, both with some multichannel audio going through the amp and again just stereo... I'm picking up that AST is outputting something else:
2023-03-04 13:42:10 INFO: Audio: Signal Info: PCM (03) 2023-03-04 13:42:10 INFO: Audio: Input Frequency: 48kHz (02) 2023-03-04 13:42:10 INFO: Audio: Input Channel Left: inactive 2023-03-04 13:42:10 INFO: Audio: Input Channel Center: inactive 2023-03-04 13:42:10 INFO: Audio: Input Channel Right: inactive 2023-03-04 13:42:10 INFO: Audio: Input Channel Surround-Left: inactive 2023-03-04 13:42:10 INFO: Audio: Input Channel Surround-Right: inactive 2023-03-04 13:42:10 INFO: Audio: Input Channel Surround-Back-Left: inactive 2023-03-04 13:42:10 INFO: Audio: Input Channel Surround-Back-Center: inactive 2023-03-04 13:42:10 INFO: Audio: Input Channel Surround-Back-Right: inactive 2023-03-04 13:42:10 INFO: Audio: Input Channel LFE: inactive 2023-03-04 13:42:10 INFO: Audio: Input Channel Front-Height-Left: inactive 2023-03-04 13:42:10 INFO: Audio: Input Channel Front-Height-Right: inactive 2023-03-04 13:42:10 INFO: Audio: Input Channel Front-Width-Left: inactive 2023-03-04 13:42:10 INFO: Audio: Input Channel Front-Width-Right: inactive 2023-03-04 13:42:10 INFO: Audio: Input Channel XL: inactive 2023-03-04 13:42:10 INFO: Audio: Input Channel XC: inactive 2023-03-04 13:42:10 INFO: Audio: Input Channel XL: inactive 2023-03-04 13:42:10 INFO: Audio: Output Channel Left: inactive 2023-03-04 13:42:10 INFO: Audio: Output Channel Center: inactive 2023-03-04 13:42:10 INFO: Audio: Output Channel Right: inactive 2023-03-04 13:42:10 INFO: Audio: Output Channel Surround-Left: active 2023-03-04 13:42:10 INFO: Audio: Output Channel Surround-Right: inactive 2023-03-04 13:42:10 INFO: Audio: Output Channel Surround-Back-Left: inactive 2023-03-04 13:42:10 INFO: Audio: Output Channel Surround-Back-Center: inactive 2023-03-04 13:42:10 INFO: Audio: Output Channel Surround-Back-Right: inactive
Output Channel Surround-Left: active
should be inactive for example because apparently a) you don't have any audio input on that channel at the moment (Input Channel Surround-Left: inactive
) and/or b) you don't have any stereo audio input either (shown in input channel left
/ right
)
Okay, figured it out. It needs to be just after the
Audio: Output Channel Surround-Back-Right:
SW is the subwoofer and I would expect a value for that on all models (I'm not aware of a Pioneer AVR that doesn't have a SW channel, but am aware that a number of models don't have 11 odd channels lol).
Then again, it may be that your AVR is returning a different response for the AST command entirely. This is where things start getting tricky because it means we need to build a response parser that can be override by the parameters, but the main pioneer_avr.py
file itself contains a huge amount of code as it is.
len(value) = 33. I have a subwoofer channel. But that next line is for sure what is causing the issue error.
When the overall module is updated, how do I get my HA updated with that code, (without uninstall/re-install of it)?
We need @crowbarz to explain this.
For now, I've put that check before we parse a response for the SW channel... Still something that needs to be looked at though as I'm not sure the attributes will actually be right.
In terms of updating, main branch needs updating, which can then be pushed to pypi, and an update to the HA component to have it install a new version of this library..
I've just spotted that PARAM_ENABLED_FUNCTIONS
needs adjusting because it will still send these commands even if you've disabled them.
HA best practices requires that the Python API to the device be implemented in a separate module to the HA integration. In this case, that module is aiopioneer
. The HA integration pioneer_async
then defines (in manifest.json
) the version of aiopioneer
to download and install from PyPi when the integration is loaded.
You should be able to temporarily modify this version string manually on your installed version of the pioneer_async
integration by specifying a git hash/branch/tag using a direct reference and/or I believe even a PR (eg. aiopioneer==git+https://github.com/crowbarz/aiopioneer/pull/7
, though have not tried this myself.)
I'll review and merge @11harveyj's PRs shortly when I get a chance.
Hey, I've just been working on improving the HA pioneer integration but looks like @crowbarz your work is a few steps further than mine, do you have plans to PR into HA, if not do you mind if I do?
@mikey0000 - The work to put it into HA is already done and it works very well.
ha-pioneer_async I think overtime, this should become native Pioneer component to HA, replacing the module that is there today. There are a number of variations, but this one is the best that I have found across the 4-5 variations with many forks that I found. asyncpioneer is the other one, not nearly as mature or full features.
@crowbarz Maybe you should put a pointer to back to the readme for others who stumble over this project.
to put into context a friend of mine was basically trying to get multi-zone working with his Pioneer AVR, so I ended up writing the config flow and adding the second zone, my PR was declined with a request to use a library for the Pioneer functions, so I figured someone must have written something by now and stumbled upon this.
Has it been added to HACS?
Yes I completely agree this should replace the existing Pioneer integration.
However I think the main missing part for the existing integration is zone support. So if I added zone support to the existing, then at least it will be good enough until this is ready to go in.
@mikey0000 The HA integration and this module already supports multiple zones 1, 2, 3 and Z. The module detects the zones by querying power for each zone, then the integration adds them as separate devices (with a separate media_player
entity) if it receives a non-error response. You can enable info or debug logging on aiopioneer to see the conversation between HA and the AVR.
These days you can add pretty much any repository directly to HACS, without first having it added to the curated list. There's a thread on Discord about this integration too. It probably needs a fair bit of cleaning up of the rough edges before it is ready to replace the existing Pioneer AVR integration in HA.
@D-Jeffrey added backref, thanks for the suggestion.
I was talking about the current one integrated into HA missing zone support, but yes yours does indeed support zones.
Found the documentation for 2011 AVRs, parameters are all the same values. Just doesn't return as much info.. Haven't tested this though for the old AVRs as I don't have one old enough.