Add action enums to songpal (#192199)

This commit is contained in:
epenet
2026-11-12 10:55:31 +01:00
committed by GitHub
parent 710263f30f
commit cbe50cd2ca
3 changed files with 20 additions and 13 deletions
@@ -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
+16 -6
View File
@@ -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,
)