Skip to content
Merged
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
50 changes: 49 additions & 1 deletion denonavr/denonavr.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ def __init__(self, host, name=None, show_all_inputs=False, timeout=2.0,
self._input_func_list_rev = {}
self._sound_mode_raw = None
self._sound_mode_dict = SOUND_MODE_MAPPING
self._support_sound_mode = None
self._sm_match_dict = self.construct_sm_match_dict()
self._netaudio_func_list = []
self._playing_func_list = []
Expand All @@ -264,6 +265,8 @@ def __init__(self, host, name=None, show_all_inputs=False, timeout=2.0,
self._get_zone_name()
else:
self._get_receiver_name()
# Determine if sound mode is supported
self._get_support_sound_mode()
# Get initial setting of values
self.update()
# Create instances of additional zones if requested
Expand Down Expand Up @@ -399,7 +402,7 @@ def _update_avr(self):
"MasterVolume": None}

# Sound mode information only available in main zone
if self._zone == "Main":
if (self._zone == "Main" and self._support_sound_mode):
relevant_tags["selectSurround"] = None
relevant_tags["SurrMode"] = None

Expand Down Expand Up @@ -682,6 +685,46 @@ def _get_zone_name(self):
else:
self._name = name.strip()

def _get_support_sound_mode(self):
"""
Get if sound mode is supported from device.

Method queries device via HTTP.
Returns "True" if sound mode supported and "False" if not.
This method is for pre 2016 AVR(-X) devices
"""
# Set sound mode tags to be checked if available
relevant_tags = {"selectSurround": None, "SurrMode": None}

# Get status XML from Denon receiver via HTTP
try:
root = self.get_status_xml(self._urls.status)
except (ValueError, requests.exceptions.RequestException):
pass
else:
# Process the tags from this XML
relevant_tags = self._get_status_from_xml_tags(root, relevant_tags)

# Second option to update variables from different source
if relevant_tags:
try:
root = self.get_status_xml(self._urls.mainzone)
except (ValueError,
requests.exceptions.RequestException):
pass
else:
# Get the tags from this XML
relevant_tags = self._get_status_from_xml_tags(root,
relevant_tags)

# if sound mode not found in the status XML, return False
if relevant_tags:
self._support_sound_mode = False
return False
# if sound mode found, the relevant_tags are empty: return True.
self._support_sound_mode = True
return True

def _get_renamed_deleted_sources(self):
"""
Get renamed and deleted sources lists from receiver .
Expand Down Expand Up @@ -1172,6 +1215,11 @@ def input_func_list(self):
"""Return a list of available input sources as string."""
return sorted(self._input_func_list.keys())

@property
def support_sound_mode(self):
"""Return Boolean if sound mode supported."""
return self._get_support_sound_mode()

@property
def sound_mode(self):
"""Return the matched current sound mode as a string."""
Expand Down