diff --git a/homeassistant/components/sonos/speaker.py b/homeassistant/components/sonos/speaker.py index 5d4199ec905..bd217cc9029 100644 --- a/homeassistant/components/sonos/speaker.py +++ b/homeassistant/components/sonos/speaker.py @@ -137,6 +137,7 @@ class SonosSpeaker: self.cross_fade: bool | None = None self.bass: int | None = None self.treble: int | None = None + self.loudness: bool | None = None # Home theater self.audio_delay: int | None = None @@ -506,6 +507,9 @@ class SonosSpeaker: if "mute" in variables: self.muted = variables["mute"]["Master"] == "1" + if loudness := variables.get("loudness"): + self.loudness = loudness["Master"] == "1" + for bool_var in ( "dialog_level", "night_mode", diff --git a/homeassistant/components/sonos/switch.py b/homeassistant/components/sonos/switch.py index b5fea08e418..29abb097df7 100644 --- a/homeassistant/components/sonos/switch.py +++ b/homeassistant/components/sonos/switch.py @@ -38,6 +38,7 @@ ATTR_VOLUME = "volume" ATTR_INCLUDE_LINKED_ZONES = "include_linked_zones" ATTR_CROSSFADE = "cross_fade" +ATTR_LOUDNESS = "loudness" ATTR_NIGHT_SOUND = "night_mode" ATTR_SPEECH_ENHANCEMENT = "dialog_level" ATTR_STATUS_LIGHT = "status_light" @@ -48,6 +49,7 @@ ATTR_TOUCH_CONTROLS = "buttons_enabled" ALL_FEATURES = ( ATTR_TOUCH_CONTROLS, ATTR_CROSSFADE, + ATTR_LOUDNESS, ATTR_NIGHT_SOUND, ATTR_SPEECH_ENHANCEMENT, ATTR_SUB_ENABLED, @@ -64,6 +66,7 @@ POLL_REQUIRED = ( FRIENDLY_NAMES = { ATTR_CROSSFADE: "Crossfade", + ATTR_LOUDNESS: "Loudness", ATTR_NIGHT_SOUND: "Night Sound", ATTR_SPEECH_ENHANCEMENT: "Speech Enhancement", ATTR_STATUS_LIGHT: "Status Light", @@ -73,6 +76,7 @@ FRIENDLY_NAMES = { } FEATURE_ICONS = { + ATTR_LOUDNESS: "mdi:bullhorn-variant", ATTR_NIGHT_SOUND: "mdi:chat-sleep", ATTR_SPEECH_ENHANCEMENT: "mdi:ear-hearing", ATTR_CROSSFADE: "mdi:swap-horizontal", diff --git a/tests/components/sonos/conftest.py b/tests/components/sonos/conftest.py index 8c804f466d4..d493c9d50c9 100644 --- a/tests/components/sonos/conftest.py +++ b/tests/components/sonos/conftest.py @@ -108,6 +108,7 @@ def soco_fixture( mock_soco.mute = False mock_soco.night_mode = True mock_soco.dialog_level = True + mock_soco.loudness = True mock_soco.volume = 19 mock_soco.audio_delay = 2 mock_soco.bass = 1 diff --git a/tests/components/sonos/test_switch.py b/tests/components/sonos/test_switch.py index 586ccf213b8..f224a1e187e 100644 --- a/tests/components/sonos/test_switch.py +++ b/tests/components/sonos/test_switch.py @@ -29,6 +29,7 @@ async def test_entity_registry(hass, async_autosetup_sonos): assert "media_player.zone_a" in entity_registry.entities assert "switch.sonos_alarm_14" in entity_registry.entities assert "switch.zone_a_status_light" in entity_registry.entities + assert "switch.zone_a_loudness" in entity_registry.entities assert "switch.zone_a_night_sound" in entity_registry.entities assert "switch.zone_a_speech_enhancement" in entity_registry.entities assert "switch.zone_a_subwoofer_enabled" in entity_registry.entities @@ -55,6 +56,10 @@ async def test_switch_attributes(hass, async_autosetup_sonos, soco): night_sound_state = hass.states.get(night_sound.entity_id) assert night_sound_state.state == STATE_ON + loudness = entity_registry.entities["switch.zone_a_loudness"] + loudness_state = hass.states.get(loudness.entity_id) + assert loudness_state.state == STATE_ON + speech_enhancement = entity_registry.entities["switch.zone_a_speech_enhancement"] speech_enhancement_state = hass.states.get(speech_enhancement.entity_id) assert speech_enhancement_state.state == STATE_ON