mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add Sonos subwoofer and surround on/off controls (#60918)
This commit is contained in:
parent
7d8b3e9de3
commit
b883014ed4
@ -196,6 +196,8 @@ class SonosSpeaker:
|
|||||||
self.cross_fade: bool | None = None
|
self.cross_fade: bool | None = None
|
||||||
self.bass: int | None = None
|
self.bass: int | None = None
|
||||||
self.treble: int | None = None
|
self.treble: int | None = None
|
||||||
|
self.sub_enabled: bool | None = None
|
||||||
|
self.surround_enabled: bool | None = None
|
||||||
|
|
||||||
# Misc features
|
# Misc features
|
||||||
self.buttons_enabled: bool | None = None
|
self.buttons_enabled: bool | None = None
|
||||||
|
@ -38,6 +38,8 @@ ATTR_CROSSFADE = "cross_fade"
|
|||||||
ATTR_NIGHT_SOUND = "night_mode"
|
ATTR_NIGHT_SOUND = "night_mode"
|
||||||
ATTR_SPEECH_ENHANCEMENT = "dialog_mode"
|
ATTR_SPEECH_ENHANCEMENT = "dialog_mode"
|
||||||
ATTR_STATUS_LIGHT = "status_light"
|
ATTR_STATUS_LIGHT = "status_light"
|
||||||
|
ATTR_SUB_ENABLED = "sub_enabled"
|
||||||
|
ATTR_SURROUND_ENABLED = "surround_enabled"
|
||||||
ATTR_TOUCH_CONTROLS = "buttons_enabled"
|
ATTR_TOUCH_CONTROLS = "buttons_enabled"
|
||||||
|
|
||||||
ALL_FEATURES = (
|
ALL_FEATURES = (
|
||||||
@ -45,6 +47,8 @@ ALL_FEATURES = (
|
|||||||
ATTR_CROSSFADE,
|
ATTR_CROSSFADE,
|
||||||
ATTR_NIGHT_SOUND,
|
ATTR_NIGHT_SOUND,
|
||||||
ATTR_SPEECH_ENHANCEMENT,
|
ATTR_SPEECH_ENHANCEMENT,
|
||||||
|
ATTR_SUB_ENABLED,
|
||||||
|
ATTR_SURROUND_ENABLED,
|
||||||
ATTR_STATUS_LIGHT,
|
ATTR_STATUS_LIGHT,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -60,6 +64,8 @@ FRIENDLY_NAMES = {
|
|||||||
ATTR_NIGHT_SOUND: "Night Sound",
|
ATTR_NIGHT_SOUND: "Night Sound",
|
||||||
ATTR_SPEECH_ENHANCEMENT: "Speech Enhancement",
|
ATTR_SPEECH_ENHANCEMENT: "Speech Enhancement",
|
||||||
ATTR_STATUS_LIGHT: "Status Light",
|
ATTR_STATUS_LIGHT: "Status Light",
|
||||||
|
ATTR_SUB_ENABLED: "Subwoofer Enabled",
|
||||||
|
ATTR_SURROUND_ENABLED: "Surround Enabled",
|
||||||
ATTR_TOUCH_CONTROLS: "Touch Controls",
|
ATTR_TOUCH_CONTROLS: "Touch Controls",
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +74,8 @@ FEATURE_ICONS = {
|
|||||||
ATTR_SPEECH_ENHANCEMENT: "mdi:ear-hearing",
|
ATTR_SPEECH_ENHANCEMENT: "mdi:ear-hearing",
|
||||||
ATTR_CROSSFADE: "mdi:swap-horizontal",
|
ATTR_CROSSFADE: "mdi:swap-horizontal",
|
||||||
ATTR_STATUS_LIGHT: "mdi:led-on",
|
ATTR_STATUS_LIGHT: "mdi:led-on",
|
||||||
|
ATTR_SUB_ENABLED: "mdi:dog",
|
||||||
|
ATTR_SURROUND_ENABLED: "mdi:surround-sound",
|
||||||
ATTR_TOUCH_CONTROLS: "mdi:gesture-tap",
|
ATTR_TOUCH_CONTROLS: "mdi:gesture-tap",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +72,8 @@ def soco_fixture(music_library, speaker_info, battery_info, alarm_clock):
|
|||||||
mock_soco.volume = 19
|
mock_soco.volume = 19
|
||||||
mock_soco.bass = 1
|
mock_soco.bass = 1
|
||||||
mock_soco.treble = -1
|
mock_soco.treble = -1
|
||||||
|
mock_soco.sub_enabled = False
|
||||||
|
mock_soco.surround_enabled = True
|
||||||
mock_soco.get_battery_info.return_value = battery_info
|
mock_soco.get_battery_info.return_value = battery_info
|
||||||
mock_soco.all_zones = [mock_soco]
|
mock_soco.all_zones = [mock_soco]
|
||||||
yield mock_soco
|
yield mock_soco
|
||||||
|
@ -14,7 +14,7 @@ from homeassistant.components.sonos.switch import (
|
|||||||
ATTR_VOLUME,
|
ATTR_VOLUME,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import RELOAD_AFTER_UPDATE_DELAY
|
from homeassistant.config_entries import RELOAD_AFTER_UPDATE_DELAY
|
||||||
from homeassistant.const import ATTR_TIME, STATE_ON
|
from homeassistant.const import ATTR_TIME, STATE_OFF, STATE_ON
|
||||||
from homeassistant.helpers.entity_registry import async_get as async_get_entity_registry
|
from homeassistant.helpers.entity_registry import async_get as async_get_entity_registry
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt
|
from homeassistant.util import dt
|
||||||
@ -42,6 +42,8 @@ async def test_entity_registry(hass, config_entry, config):
|
|||||||
assert "switch.sonos_zone_a_status_light" in entity_registry.entities
|
assert "switch.sonos_zone_a_status_light" in entity_registry.entities
|
||||||
assert "switch.sonos_zone_a_night_sound" in entity_registry.entities
|
assert "switch.sonos_zone_a_night_sound" in entity_registry.entities
|
||||||
assert "switch.sonos_zone_a_speech_enhancement" in entity_registry.entities
|
assert "switch.sonos_zone_a_speech_enhancement" in entity_registry.entities
|
||||||
|
assert "switch.sonos_zone_a_subwoofer_enabled" in entity_registry.entities
|
||||||
|
assert "switch.sonos_zone_a_surround_enabled" in entity_registry.entities
|
||||||
assert "switch.sonos_zone_a_touch_controls" in entity_registry.entities
|
assert "switch.sonos_zone_a_touch_controls" in entity_registry.entities
|
||||||
|
|
||||||
|
|
||||||
@ -83,6 +85,14 @@ async def test_switch_attributes(hass, config_entry, config, soco):
|
|||||||
touch_controls = entity_registry.entities["switch.sonos_zone_a_touch_controls"]
|
touch_controls = entity_registry.entities["switch.sonos_zone_a_touch_controls"]
|
||||||
assert hass.states.get(touch_controls.entity_id) is None
|
assert hass.states.get(touch_controls.entity_id) is None
|
||||||
|
|
||||||
|
sub_switch = entity_registry.entities["switch.sonos_zone_a_subwoofer_enabled"]
|
||||||
|
sub_switch_state = hass.states.get(sub_switch.entity_id)
|
||||||
|
assert sub_switch_state.state == STATE_OFF
|
||||||
|
|
||||||
|
surround_switch = entity_registry.entities["switch.sonos_zone_a_surround_enabled"]
|
||||||
|
surround_switch_state = hass.states.get(surround_switch.entity_id)
|
||||||
|
assert surround_switch_state.state == STATE_ON
|
||||||
|
|
||||||
# Enable disabled switches
|
# Enable disabled switches
|
||||||
for entity in (status_light, touch_controls):
|
for entity in (status_light, touch_controls):
|
||||||
entity_registry.async_update_entity(
|
entity_registry.async_update_entity(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user