mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Add action enums to songpal (#192199)
This commit is contained in:
@@ -34,9 +34,6 @@ from .const import CONF_ENDPOINT, DOMAIN, ERROR_REQUEST_RETRY
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PARAM_NAME = "name"
|
||||
PARAM_VALUE = "value"
|
||||
|
||||
INITIAL_RETRY_DELAY = 10
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
"""Support for Songpal-enabled (Sony) media devices."""
|
||||
|
||||
from enum import StrEnum
|
||||
|
||||
import probatio
|
||||
|
||||
from homeassistant.components.media_player import DOMAIN as MEDIA_PLAYER_DOMAIN
|
||||
@@ -8,10 +10,18 @@ from homeassistant.helpers import config_validation as cv, service
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
PARAM_NAME = "name"
|
||||
PARAM_VALUE = "value"
|
||||
|
||||
SET_SOUND_SETTING = "set_sound_setting"
|
||||
class SongpalService(StrEnum):
|
||||
"""Store keys for Songpal services."""
|
||||
|
||||
SET_SOUND_SETTING = "set_sound_setting"
|
||||
|
||||
|
||||
class SongpalServiceArgument(StrEnum):
|
||||
"""Store keys for Songpal service arguments."""
|
||||
|
||||
NAME = "name"
|
||||
VALUE = "value"
|
||||
|
||||
|
||||
@callback
|
||||
@@ -20,11 +30,11 @@ def async_setup_services(hass: HomeAssistant) -> None:
|
||||
service.async_register_platform_entity_service(
|
||||
hass,
|
||||
DOMAIN,
|
||||
SET_SOUND_SETTING,
|
||||
SongpalService.SET_SOUND_SETTING,
|
||||
entity_domain=MEDIA_PLAYER_DOMAIN,
|
||||
schema={
|
||||
probatio.Required(PARAM_NAME): cv.string,
|
||||
probatio.Required(PARAM_VALUE): cv.string,
|
||||
probatio.Required(SongpalServiceArgument.NAME): cv.string,
|
||||
probatio.Required(SongpalServiceArgument.VALUE): cv.string,
|
||||
},
|
||||
func="async_set_sound_setting",
|
||||
)
|
||||
|
||||
@@ -19,7 +19,7 @@ from songpal.notification import SettingChange
|
||||
from homeassistant.components import media_player, songpal
|
||||
from homeassistant.components.media_player import MediaPlayerEntityFeature
|
||||
from homeassistant.components.songpal.const import ERROR_REQUEST_RETRY
|
||||
from homeassistant.components.songpal.services import SET_SOUND_SETTING
|
||||
from homeassistant.components.songpal.services import SongpalService
|
||||
from homeassistant.const import (
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
STATE_OFF,
|
||||
@@ -317,7 +317,7 @@ async def test_services(hass: HomeAssistant) -> None:
|
||||
|
||||
await hass.services.async_call(
|
||||
songpal.DOMAIN,
|
||||
SET_SOUND_SETTING,
|
||||
SongpalService.SET_SOUND_SETTING,
|
||||
{"entity_id": ENTITY_ID, "name": "name", "value": "value"},
|
||||
blocking=True,
|
||||
)
|
||||
@@ -335,7 +335,7 @@ async def test_services(hass: HomeAssistant) -> None:
|
||||
|
||||
await hass.services.async_call(
|
||||
songpal.DOMAIN,
|
||||
SET_SOUND_SETTING,
|
||||
SongpalService.SET_SOUND_SETTING,
|
||||
{"entity_id": "all", "name": "name", "value": "value"},
|
||||
blocking=True,
|
||||
)
|
||||
@@ -355,7 +355,7 @@ async def test_services(hass: HomeAssistant) -> None:
|
||||
|
||||
await hass.services.async_call(
|
||||
songpal.DOMAIN,
|
||||
SET_SOUND_SETTING,
|
||||
SongpalService.SET_SOUND_SETTING,
|
||||
{"entity_id": "all", "name": "name", "value": "value"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user