-
Notifications
You must be signed in to change notification settings - Fork 2
Denon AVR get_audio_format from webAPI #196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f9cd69e
f9b969c
a53d5f2
517241f
d94c818
124c9a4
deee4fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,16 @@ | ||
| import asyncio | ||
|
|
||
| import requests | ||
| from defusedxml import DefusedXmlException | ||
| from defusedxml.ElementTree import fromstring | ||
| from denonavr import DenonAVR | ||
| from .base import AudioAmplifier | ||
|
|
||
| class DenonAVRController(AudioAmplifier): | ||
|
|
||
| def __init__(self, host: str): | ||
| def __init__(self, host: str, port: int = 10443): | ||
| self.receiver = DenonAVR(host) | ||
| self.url = f"https://{host}:{port}/" | ||
| self.setup() | ||
|
|
||
| def setup(self): | ||
|
|
@@ -76,3 +81,28 @@ def get_status(self): | |
| "input": self.get_input(), | ||
| "sound_mode": self.get_sound_mode(), | ||
| } | ||
|
|
||
| def get_audio_format(self): | ||
mshameersm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """ | ||
| Web interface was showing input audio format. Could not find an equivalent method from | ||
| denonavr package. We need to get the inputSignal details, Searched whole package to find | ||
| any reference of inputSignal, but could not find. So using the web api itself here. | ||
|
|
||
| Returns: | ||
| str: 'Dolby Atmos', 'PCM' | ||
| Raises: | ||
| ValueError: if could not find or parse the data | ||
| """ | ||
| try: | ||
mshameersm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # The 'type=12' query parameter requests the configuration from the Denon AVR. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is type=12 and what does it correspond to in the denon api?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could not find the corresponding in Denon lib. |
||
| # the certificates in denon avr showed expired even after firmware update. so added verify=False | ||
| response = requests.get(f'{self.url}ajax/general/get_config?type=12', verify=False, timeout=15) | ||
| if response.status_code == 200: | ||
| xml_data = fromstring(response.content) | ||
| element = xml_data.find(".//InputSignal") | ||
| return element.text if element is not None else None | ||
mshameersm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| raise ValueError(f"Failed to fetch Audio format. Status code: {response.status_code}") | ||
| except DefusedXmlException: | ||
| raise ValueError("Failed to parse AVR response.") | ||
| except requests.exceptions.RequestException: | ||
| raise ValueError("Can't reach AVR. Please check configuration") | ||
Uh oh!
There was an error while loading. Please reload this page.