Skip to content
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

Add SoCo method to determine HDMI/Optical input audio format #832

Merged
merged 8 commits into from
Oct 11, 2021
36 changes: 36 additions & 0 deletions soco/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,42 @@ def trueplay(self, trueplay):
]
)

def soundbar_audio_input_format(self) -> Optional[str]:
rytilahti marked this conversation as resolved.
Show resolved Hide resolved
"""Return string presentation of the audio input format.

Returns None when the device is not a soundbar.
While the variable is available on non-soundbar devices,
it is likely always 0 as as there is no audio inputs.

TODO: move to a separate PR?
rytilahti marked this conversation as resolved.
Show resolved Hide resolved
"""
if self.is_soundbar:
return None

value_map = {
0: "No input connected",
2: "Stereo",
7: "Dolby 2.0",
18: "Dolby 5.1",
21: "No input",
22: "No audio",
# TODO: I didn't receive the above values (besides 0, 21 and 22),
# but the following instead based on some testing.
33554434: "PCM 2.0",
33554454: "PCM 2.0 no audio",
33554488: "Dolby 2.0",
84934713: "Dolby 5.1",
}

response = self.deviceProperties.GetZoneInfo()
format = int(response["HTAudioIn"])
if format not in value_map:
logging.warning("Unknown audio input format: %s", format)

format_str = value_map.get(format, f"Unknown format: {format}")
rytilahti marked this conversation as resolved.
Show resolved Hide resolved

return format_str

@property
def supports_fixed_volume(self):
"""bool: Whether the device supports fixed volume output."""
Expand Down