mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 02:37:08 +00:00
Use new media player enums in snapcast (#78109)
This commit is contained in:
parent
d0605d3a59
commit
9e1cb914b1
@ -12,16 +12,9 @@ from homeassistant.components.media_player import (
|
|||||||
PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA,
|
||||||
MediaPlayerEntity,
|
MediaPlayerEntity,
|
||||||
MediaPlayerEntityFeature,
|
MediaPlayerEntityFeature,
|
||||||
|
MediaPlayerState,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||||
CONF_HOST,
|
|
||||||
CONF_PORT,
|
|
||||||
STATE_IDLE,
|
|
||||||
STATE_OFF,
|
|
||||||
STATE_ON,
|
|
||||||
STATE_PLAYING,
|
|
||||||
STATE_UNKNOWN,
|
|
||||||
)
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import config_validation as cv, entity_platform
|
from homeassistant.helpers import config_validation as cv, entity_platform
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
@ -137,13 +130,13 @@ class SnapcastGroupDevice(MediaPlayerEntity):
|
|||||||
self._group.set_callback(None)
|
self._group.set_callback(None)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self) -> MediaPlayerState | None:
|
||||||
"""Return the state of the player."""
|
"""Return the state of the player."""
|
||||||
return {
|
return {
|
||||||
"idle": STATE_IDLE,
|
"idle": MediaPlayerState.IDLE,
|
||||||
"playing": STATE_PLAYING,
|
"playing": MediaPlayerState.PLAYING,
|
||||||
"unknown": STATE_UNKNOWN,
|
"unknown": None,
|
||||||
}.get(self._group.stream_status, STATE_UNKNOWN)
|
}.get(self._group.stream_status)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
@ -271,11 +264,11 @@ class SnapcastClientDevice(MediaPlayerEntity):
|
|||||||
return list(self._client.group.streams_by_name().keys())
|
return list(self._client.group.streams_by_name().keys())
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self) -> MediaPlayerState:
|
||||||
"""Return the state of the player."""
|
"""Return the state of the player."""
|
||||||
if self._client.connected:
|
if self._client.connected:
|
||||||
return STATE_ON
|
return MediaPlayerState.ON
|
||||||
return STATE_OFF
|
return MediaPlayerState.OFF
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user