Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions framework/core/audioAmplifier/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,12 @@ def get_status(self) -> dict:
:return: Dictionary of current amplifier state.
"""
pass

@abstractmethod
def get_audio_format(self) -> str:
"""
Get a string of audio format information.

:return: String of audio format like Dolby Atmos or PCM
"""
pass
32 changes: 31 additions & 1 deletion framework/core/audioAmplifier/denon_controller.py
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):
Expand Down Expand Up @@ -76,3 +81,28 @@ def get_status(self):
"input": self.get_input(),
"sound_mode": self.get_sound_mode(),
}

def get_audio_format(self):
"""
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:
# The 'type=12' query parameter requests the configuration from the Denon AVR.
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

@mshameersm mshameersm Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could not find the corresponding in Denon lib. type=12 in URL returns an xml of configurations from AVR.

# 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
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")
4 changes: 4 additions & 0 deletions framework/core/audioAmplifierController.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,7 @@ def get_sound_mode(self) -> str:
def get_status(self):
self._log.info("Getting audio amplifier status")
return self.audioAmplifier.get_status()

def get_audio_format(self) -> str:
self._log.info("Getting audio format")
return self.audioAmplifier.get_audio_format()
8 changes: 8 additions & 0 deletions tests/audioAmp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@
except:
print(f"FAILED: Sound mode not set correctly. Expected: {sound_mode}, actual: {updated_sound_mode}")

# Audio format test
try:
audio_format = controller.get_audio_format()
assert audio_format == "Unknown" # when nothing plays
print(f"PASSED: Audio format: {audio_format}")
except Exception as e:
print(f"FAILED: Audio format - {audio_format} - {e}")

# Power OFF test
try:
controller.power_off()
Expand Down
Loading