Add control of hardware buttons to Sonos (#49977)

This commit is contained in:
mountainsandcode 2021-05-17 11:12:01 +02:00 committed by GitHub
parent 4357d2dc84
commit 2d29959a52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -119,6 +119,7 @@ ATTR_ENABLED = "enabled"
ATTR_INCLUDE_LINKED_ZONES = "include_linked_zones"
ATTR_MASTER = "master"
ATTR_WITH_GROUP = "with_group"
ATTR_BUTTONS_ENABLED = "buttons_enabled"
ATTR_NIGHT_SOUND = "night_sound"
ATTR_SPEECH_ENHANCE = "speech_enhance"
ATTR_QUEUE_POSITION = "queue_position"
@ -229,6 +230,7 @@ async def async_setup_entry(
platform.async_register_entity_service( # type: ignore
SERVICE_SET_OPTION,
{
vol.Optional(ATTR_BUTTONS_ENABLED): cv.boolean,
vol.Optional(ATTR_NIGHT_SOUND): cv.boolean,
vol.Optional(ATTR_SPEECH_ENHANCE): cv.boolean,
vol.Optional(ATTR_STATUS_LIGHT): cv.boolean,
@ -605,11 +607,15 @@ class SonosMediaPlayerEntity(SonosEntity, MediaPlayerEntity):
@soco_error()
def set_option(
self,
buttons_enabled: bool | None = None,
night_sound: bool | None = None,
speech_enhance: bool | None = None,
status_light: bool | None = None,
) -> None:
"""Modify playback options."""
if buttons_enabled is not None:
self.soco.buttons_enabled = buttons_enabled
if night_sound is not None and self.speaker.night_mode is not None:
self.soco.night_mode = night_sound

View File

@ -103,6 +103,12 @@ set_option:
device:
integration: sonos
fields:
buttons_enabled:
name: Buttons enabled
description: Enable control buttons on the device
example: "true"
selector:
boolean:
night_sound:
name: Night sound
description: Enable Night Sound mode