File tree Expand file tree Collapse file tree 4 files changed +39
-0
lines changed
Expand file tree Collapse file tree 4 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -105,3 +105,12 @@ def get_status(self) -> dict:
105105 :return: Dictionary of current amplifier state.
106106 """
107107 pass
108+
109+ @abstractmethod
110+ def get_audio_format (self ) -> dict :
111+ """
112+ Get a string of audio format information.
113+
114+ :return: String of audio format like Dolby Atmos or PCM
115+ """
116+ pass
Original file line number Diff line number Diff line change 11import asyncio
2+
3+ import requests
4+ from defusedxml .cElementTree import fromstring
25from denonavr import DenonAVR
36from .base import AudioAmplifier
47
58class DenonAVRController (AudioAmplifier ):
69
710 def __init__ (self , host : str ):
811 self .receiver = DenonAVR (host )
12+ self .url = f"https://{ host } :10443/"
913 self .setup ()
1014
1115 def setup (self ):
@@ -76,3 +80,17 @@ def get_status(self):
7680 "input" : self .get_input (),
7781 "sound_mode" : self .get_sound_mode (),
7882 }
83+
84+ def get_audio_format (self ):
85+ response = requests .get (f'{ self .url } ajax/general/get_config?type=12' , verify = False )
86+ if response .status_code == 200 :
87+ try :
88+ xml_data = fromstring (response .content )
89+
90+ for element in xml_data .findall (".//InputSignal" ):
91+ return element .text
92+ except Exception as e :
93+ print (e )
94+ raise ValueError ("Failed to parse Audio format XML. Status code" )
95+ else :
96+ raise ValueError (f"Failed to fetch Audio format. Status code: { response .status_code } " )
Original file line number Diff line number Diff line change @@ -96,3 +96,7 @@ def get_sound_mode(self) -> str:
9696 def get_status (self ):
9797 self ._log .info ("Getting audio amplifier status" )
9898 return self .audioAmplifier .get_status ()
99+
100+ def get_audio_format (self ):
101+ self ._log .info ("Getting audio format" )
102+ return self .audioAmplifier .get_audio_format ()
Original file line number Diff line number Diff line change 8484 except :
8585 print (f"FAILED: Sound mode not set correctly. Expected: { sound_mode } , actual: { updated_sound_mode } " )
8686
87+ # Audio format test
88+ try :
89+ audio_format = controller .get_audio_format ()
90+ assert audio_format == "Unknown" # when nothing plays
91+ print (f"PASSED: Audio format: { audio_format } " )
92+ except :
93+ print (f"FAILED: Audio format: { audio_format } " )
94+
8795 # Power OFF test
8896 try :
8997 controller .power_off ()
You can’t perform that action at this time.
0 commit comments