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
1 change: 1 addition & 0 deletions homeassistant/components/sonos/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"audio_delay": (0, 5),
"bass": (-10, 10),
"treble": (-10, 10),
"sub_gain": (-15, 15),
}

_LOGGER = logging.getLogger(__name__)
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/sonos/speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def __init__(
self.dialog_level: bool | None = None
self.night_mode: bool | None = None
self.sub_enabled: bool | None = None
self.sub_gain: int | None = None
self.surround_enabled: bool | None = None

# Misc features
Expand Down Expand Up @@ -490,7 +491,7 @@ def async_update_volume(self, event: SonosEvent) -> None:
if bool_var in variables:
setattr(self, bool_var, variables[bool_var] == "1")

for int_var in ("audio_delay", "bass", "treble"):
for int_var in ("audio_delay", "bass", "treble", "sub_gain"):
if int_var in variables:
setattr(self, int_var, variables[int_var])

Expand Down
1 change: 1 addition & 0 deletions tests/components/sonos/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def soco_fixture(
mock_soco.treble = -1
mock_soco.mic_enabled = False
mock_soco.sub_enabled = False
mock_soco.sub_gain = 5
mock_soco.surround_enabled = True
mock_soco.soundbar_audio_input_format = "Dolby 5.1"
mock_soco.get_battery_info.return_value = battery_info
Expand Down
17 changes: 15 additions & 2 deletions tests/components/sonos/test_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from homeassistant.helpers import entity_registry as ent_reg


async def test_audio_input_sensor(hass, async_autosetup_sonos, soco):
"""Test audio input sensor."""
async def test_number_entities(hass, async_autosetup_sonos, soco):
"""Test number entities."""
entity_registry = ent_reg.async_get(hass)

bass_number = entity_registry.entities["number.zone_a_bass"]
Expand All @@ -30,3 +30,16 @@ async def test_audio_input_sensor(hass, async_autosetup_sonos, soco):
blocking=True,
)
assert mock_audio_delay.called_with(3)

sub_gain_number = entity_registry.entities["number.zone_a_sub_gain"]
sub_gain_state = hass.states.get(sub_gain_number.entity_id)
assert sub_gain_state.state == "5"

with patch("soco.SoCo.sub_gain") as mock_sub_gain:
await hass.services.async_call(
NUMBER_DOMAIN,
SERVICE_SET_VALUE,
{ATTR_ENTITY_ID: sub_gain_number.entity_id, "value": -8},
blocking=True,
)
assert mock_sub_gain.called_with(-8)