mirror of
https://github.com/home-assistant/core
synced 2024-09-03 08:14:07 +02:00
Add support for Sonos loudness switch (#72572)
This commit is contained in:
parent
c10a523055
commit
30e71dd96f
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user