mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-25 18:16:32 +00:00
Use shorter function for soundcard (#1535)
This commit is contained in:
parent
6721b8f265
commit
8a6ea7ab50
2
API.md
2
API.md
@ -866,7 +866,7 @@ return:
|
|||||||
"card": [
|
"card": [
|
||||||
{
|
{
|
||||||
"name": "...",
|
"name": "...",
|
||||||
"description": "...",
|
"driver": "...",
|
||||||
"profiles": [
|
"profiles": [
|
||||||
{
|
{
|
||||||
"name": "...",
|
"name": "...",
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 6b1e5a525f7dac6867af8dd937100ce402aedac9
|
Subproject commit 8518f774d44d4b9cd7e9b824dc9e9372e665347d
|
@ -10,7 +10,7 @@ gitpython==3.1.0
|
|||||||
jinja2==2.11.1
|
jinja2==2.11.1
|
||||||
packaging==20.1
|
packaging==20.1
|
||||||
ptvsd==4.3.2
|
ptvsd==4.3.2
|
||||||
pulsectl==20.2.2
|
pulsectl==20.2.4
|
||||||
pytz==2019.3
|
pytz==2019.3
|
||||||
pyudev==0.22.0
|
pyudev==0.22.0
|
||||||
ruamel.yaml==0.15.100
|
ruamel.yaml==0.15.100
|
||||||
|
@ -45,7 +45,7 @@ class SoundCard:
|
|||||||
"""Represent a Sound Card."""
|
"""Represent a Sound Card."""
|
||||||
|
|
||||||
name: str = attr.ib()
|
name: str = attr.ib()
|
||||||
description: str = attr.ib()
|
driver: str = attr.ib()
|
||||||
profiles: List[SoundProfile] = attr.ib()
|
profiles: List[SoundProfile] = attr.ib()
|
||||||
|
|
||||||
|
|
||||||
@ -122,20 +122,8 @@ class SoundControl(CoreSysAttributes):
|
|||||||
"""Set a profile to volume input/output."""
|
"""Set a profile to volume input/output."""
|
||||||
try:
|
try:
|
||||||
with Pulse(PULSE_NAME) as pulse:
|
with Pulse(PULSE_NAME) as pulse:
|
||||||
|
card = pulse.get_sink_by_name(card_name)
|
||||||
# Get card
|
pulse.card_profile_set(card, profile_name)
|
||||||
select_card = None
|
|
||||||
for card in pulse.card_list():
|
|
||||||
if card.name != card_name:
|
|
||||||
continue
|
|
||||||
select_card = card
|
|
||||||
break
|
|
||||||
|
|
||||||
if not select_card:
|
|
||||||
raise PulseIndexError()
|
|
||||||
|
|
||||||
# set profile
|
|
||||||
pulse.card_profile_set(select_card, profile_name)
|
|
||||||
|
|
||||||
except PulseIndexError:
|
except PulseIndexError:
|
||||||
_LOGGER.error("Can't find %s profile %s", card_name, profile_name)
|
_LOGGER.error("Can't find %s profile %s", card_name, profile_name)
|
||||||
@ -201,7 +189,7 @@ class SoundControl(CoreSysAttributes):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self._cards.append(
|
self._cards.append(
|
||||||
SoundCard(card.name, card.description, sound_profiles)
|
SoundCard(card.name, card.driver, sound_profiles)
|
||||||
)
|
)
|
||||||
|
|
||||||
except PulseOperationFailed as err:
|
except PulseOperationFailed as err:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user