mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 02:07:09 +00:00
Use new media player enums [r] (#78062)
This commit is contained in:
parent
52b5e1779f
commit
45d0ec7150
@ -12,30 +12,18 @@ import yarl
|
|||||||
|
|
||||||
from homeassistant.components import media_source
|
from homeassistant.components import media_source
|
||||||
from homeassistant.components.media_player import (
|
from homeassistant.components.media_player import (
|
||||||
|
ATTR_MEDIA_EXTRA,
|
||||||
BrowseMedia,
|
BrowseMedia,
|
||||||
MediaPlayerDeviceClass,
|
MediaPlayerDeviceClass,
|
||||||
MediaPlayerEntity,
|
MediaPlayerEntity,
|
||||||
MediaPlayerEntityFeature,
|
MediaPlayerEntityFeature,
|
||||||
|
MediaPlayerState,
|
||||||
|
MediaType,
|
||||||
async_process_play_media_url,
|
async_process_play_media_url,
|
||||||
)
|
)
|
||||||
from homeassistant.components.media_player.const import (
|
|
||||||
ATTR_MEDIA_EXTRA,
|
|
||||||
MEDIA_TYPE_APP,
|
|
||||||
MEDIA_TYPE_CHANNEL,
|
|
||||||
MEDIA_TYPE_MUSIC,
|
|
||||||
MEDIA_TYPE_URL,
|
|
||||||
MEDIA_TYPE_VIDEO,
|
|
||||||
)
|
|
||||||
from homeassistant.components.stream.const import FORMAT_CONTENT_TYPE, HLS_PROVIDER
|
from homeassistant.components.stream.const import FORMAT_CONTENT_TYPE, HLS_PROVIDER
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import ATTR_NAME
|
||||||
ATTR_NAME,
|
|
||||||
STATE_IDLE,
|
|
||||||
STATE_ON,
|
|
||||||
STATE_PAUSED,
|
|
||||||
STATE_PLAYING,
|
|
||||||
STATE_STANDBY,
|
|
||||||
)
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import entity_platform
|
from homeassistant.helpers import entity_platform
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
@ -59,16 +47,16 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
STREAM_FORMAT_TO_MEDIA_TYPE = {
|
STREAM_FORMAT_TO_MEDIA_TYPE = {
|
||||||
"dash": MEDIA_TYPE_VIDEO,
|
"dash": MediaType.VIDEO,
|
||||||
"hls": MEDIA_TYPE_VIDEO,
|
"hls": MediaType.VIDEO,
|
||||||
"ism": MEDIA_TYPE_VIDEO,
|
"ism": MediaType.VIDEO,
|
||||||
"m4a": MEDIA_TYPE_MUSIC,
|
"m4a": MediaType.MUSIC,
|
||||||
"m4v": MEDIA_TYPE_VIDEO,
|
"m4v": MediaType.VIDEO,
|
||||||
"mka": MEDIA_TYPE_MUSIC,
|
"mka": MediaType.MUSIC,
|
||||||
"mkv": MEDIA_TYPE_VIDEO,
|
"mkv": MediaType.VIDEO,
|
||||||
"mks": MEDIA_TYPE_VIDEO,
|
"mks": MediaType.VIDEO,
|
||||||
"mp3": MEDIA_TYPE_MUSIC,
|
"mp3": MediaType.MUSIC,
|
||||||
"mp4": MEDIA_TYPE_VIDEO,
|
"mp4": MediaType.VIDEO,
|
||||||
}
|
}
|
||||||
|
|
||||||
ATTRS_TO_LAUNCH_PARAMS = {
|
ATTRS_TO_LAUNCH_PARAMS = {
|
||||||
@ -150,10 +138,10 @@ class RokuMediaPlayer(RokuEntity, MediaPlayerEntity):
|
|||||||
return MediaPlayerDeviceClass.RECEIVER
|
return MediaPlayerDeviceClass.RECEIVER
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self) -> str | None:
|
def state(self) -> MediaPlayerState | None:
|
||||||
"""Return the state of the device."""
|
"""Return the state of the device."""
|
||||||
if self.coordinator.data.state.standby:
|
if self.coordinator.data.state.standby:
|
||||||
return STATE_STANDBY
|
return MediaPlayerState.STANDBY
|
||||||
|
|
||||||
if self.coordinator.data.app is None:
|
if self.coordinator.data.app is None:
|
||||||
return None
|
return None
|
||||||
@ -163,28 +151,28 @@ class RokuMediaPlayer(RokuEntity, MediaPlayerEntity):
|
|||||||
or self.coordinator.data.app.name == "Roku"
|
or self.coordinator.data.app.name == "Roku"
|
||||||
or self.coordinator.data.app.screensaver
|
or self.coordinator.data.app.screensaver
|
||||||
):
|
):
|
||||||
return STATE_IDLE
|
return MediaPlayerState.IDLE
|
||||||
|
|
||||||
if self.coordinator.data.media:
|
if self.coordinator.data.media:
|
||||||
if self.coordinator.data.media.paused:
|
if self.coordinator.data.media.paused:
|
||||||
return STATE_PAUSED
|
return MediaPlayerState.PAUSED
|
||||||
return STATE_PLAYING
|
return MediaPlayerState.PLAYING
|
||||||
|
|
||||||
if self.coordinator.data.app.name:
|
if self.coordinator.data.app.name:
|
||||||
return STATE_ON
|
return MediaPlayerState.ON
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_content_type(self) -> str | None:
|
def media_content_type(self) -> MediaType | None:
|
||||||
"""Content type of current playing media."""
|
"""Content type of current playing media."""
|
||||||
if self.app_id is None or self.app_name in ("Power Saver", "Roku"):
|
if self.app_id is None or self.app_name in ("Power Saver", "Roku"):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if self.app_id == "tvinput.dtv" and self.coordinator.data.channel is not None:
|
if self.app_id == "tvinput.dtv" and self.coordinator.data.channel is not None:
|
||||||
return MEDIA_TYPE_CHANNEL
|
return MediaType.CHANNEL
|
||||||
|
|
||||||
return MEDIA_TYPE_APP
|
return MediaType.APP
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_image_url(self) -> str | None:
|
def media_image_url(self) -> str | None:
|
||||||
@ -282,7 +270,7 @@ class RokuMediaPlayer(RokuEntity, MediaPlayerEntity):
|
|||||||
media_image_id: str | None = None,
|
media_image_id: str | None = None,
|
||||||
) -> tuple[bytes | None, str | None]:
|
) -> tuple[bytes | None, str | None]:
|
||||||
"""Fetch media browser image to serve via proxy."""
|
"""Fetch media browser image to serve via proxy."""
|
||||||
if media_content_type == MEDIA_TYPE_APP and media_content_id:
|
if media_content_type == MediaType.APP and media_content_id:
|
||||||
image_url = self.coordinator.roku.app_icon_url(media_content_id)
|
image_url = self.coordinator.roku.app_icon_url(media_content_id)
|
||||||
return await self._async_fetch_image(image_url)
|
return await self._async_fetch_image(image_url)
|
||||||
|
|
||||||
@ -317,21 +305,21 @@ class RokuMediaPlayer(RokuEntity, MediaPlayerEntity):
|
|||||||
@roku_exception_handler()
|
@roku_exception_handler()
|
||||||
async def async_media_pause(self) -> None:
|
async def async_media_pause(self) -> None:
|
||||||
"""Send pause command."""
|
"""Send pause command."""
|
||||||
if self.state not in (STATE_STANDBY, STATE_PAUSED):
|
if self.state not in {MediaPlayerState.STANDBY, MediaPlayerState.PAUSED}:
|
||||||
await self.coordinator.roku.remote("play")
|
await self.coordinator.roku.remote("play")
|
||||||
await self.coordinator.async_request_refresh()
|
await self.coordinator.async_request_refresh()
|
||||||
|
|
||||||
@roku_exception_handler()
|
@roku_exception_handler()
|
||||||
async def async_media_play(self) -> None:
|
async def async_media_play(self) -> None:
|
||||||
"""Send play command."""
|
"""Send play command."""
|
||||||
if self.state not in (STATE_STANDBY, STATE_PLAYING):
|
if self.state not in {MediaPlayerState.STANDBY, MediaPlayerState.PLAYING}:
|
||||||
await self.coordinator.roku.remote("play")
|
await self.coordinator.roku.remote("play")
|
||||||
await self.coordinator.async_request_refresh()
|
await self.coordinator.async_request_refresh()
|
||||||
|
|
||||||
@roku_exception_handler()
|
@roku_exception_handler()
|
||||||
async def async_media_play_pause(self) -> None:
|
async def async_media_play_pause(self) -> None:
|
||||||
"""Send play/pause command."""
|
"""Send play/pause command."""
|
||||||
if self.state != STATE_STANDBY:
|
if self.state != MediaPlayerState.STANDBY:
|
||||||
await self.coordinator.roku.remote("play")
|
await self.coordinator.roku.remote("play")
|
||||||
await self.coordinator.async_request_refresh()
|
await self.coordinator.async_request_refresh()
|
||||||
|
|
||||||
@ -380,19 +368,19 @@ class RokuMediaPlayer(RokuEntity, MediaPlayerEntity):
|
|||||||
sourced_media = await media_source.async_resolve_media(
|
sourced_media = await media_source.async_resolve_media(
|
||||||
self.hass, media_id, self.entity_id
|
self.hass, media_id, self.entity_id
|
||||||
)
|
)
|
||||||
media_type = MEDIA_TYPE_URL
|
media_type = MediaType.URL
|
||||||
media_id = sourced_media.url
|
media_id = sourced_media.url
|
||||||
mime_type = sourced_media.mime_type
|
mime_type = sourced_media.mime_type
|
||||||
stream_name = original_media_id
|
stream_name = original_media_id
|
||||||
stream_format = guess_stream_format(media_id, mime_type)
|
stream_format = guess_stream_format(media_id, mime_type)
|
||||||
|
|
||||||
if media_type == FORMAT_CONTENT_TYPE[HLS_PROVIDER]:
|
if media_type == FORMAT_CONTENT_TYPE[HLS_PROVIDER]:
|
||||||
media_type = MEDIA_TYPE_VIDEO
|
media_type = MediaType.VIDEO
|
||||||
mime_type = FORMAT_CONTENT_TYPE[HLS_PROVIDER]
|
mime_type = FORMAT_CONTENT_TYPE[HLS_PROVIDER]
|
||||||
stream_name = "Camera Stream"
|
stream_name = "Camera Stream"
|
||||||
stream_format = "hls"
|
stream_format = "hls"
|
||||||
|
|
||||||
if media_type in (MEDIA_TYPE_MUSIC, MEDIA_TYPE_URL, MEDIA_TYPE_VIDEO):
|
if media_type in {MediaType.MUSIC, MediaType.URL, MediaType.VIDEO}:
|
||||||
# If media ID is a relative URL, we serve it from HA.
|
# If media ID is a relative URL, we serve it from HA.
|
||||||
media_id = async_process_play_media_url(self.hass, media_id)
|
media_id = async_process_play_media_url(self.hass, media_id)
|
||||||
|
|
||||||
@ -417,12 +405,12 @@ class RokuMediaPlayer(RokuEntity, MediaPlayerEntity):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if (
|
if (
|
||||||
media_type == MEDIA_TYPE_URL
|
media_type == MediaType.URL
|
||||||
and STREAM_FORMAT_TO_MEDIA_TYPE[extra[ATTR_FORMAT]] == MEDIA_TYPE_MUSIC
|
and STREAM_FORMAT_TO_MEDIA_TYPE[extra[ATTR_FORMAT]] == MediaType.MUSIC
|
||||||
):
|
):
|
||||||
media_type = MEDIA_TYPE_MUSIC
|
media_type = MediaType.MUSIC
|
||||||
|
|
||||||
if media_type == MEDIA_TYPE_MUSIC and "tts_proxy" in media_id:
|
if media_type == MediaType.MUSIC and "tts_proxy" in media_id:
|
||||||
stream_name = "Text to Speech"
|
stream_name = "Text to Speech"
|
||||||
elif stream_name is None:
|
elif stream_name is None:
|
||||||
if stream_format == "ism":
|
if stream_format == "ism":
|
||||||
@ -433,7 +421,7 @@ class RokuMediaPlayer(RokuEntity, MediaPlayerEntity):
|
|||||||
if extra.get(ATTR_NAME) is None:
|
if extra.get(ATTR_NAME) is None:
|
||||||
extra[ATTR_NAME] = stream_name
|
extra[ATTR_NAME] = stream_name
|
||||||
|
|
||||||
if media_type == MEDIA_TYPE_APP:
|
if media_type == MediaType.APP:
|
||||||
params = {
|
params = {
|
||||||
param: extra[attr]
|
param: extra[attr]
|
||||||
for attr, param in ATTRS_TO_LAUNCH_PARAMS.items()
|
for attr, param in ATTRS_TO_LAUNCH_PARAMS.items()
|
||||||
@ -441,9 +429,9 @@ class RokuMediaPlayer(RokuEntity, MediaPlayerEntity):
|
|||||||
}
|
}
|
||||||
|
|
||||||
await self.coordinator.roku.launch(media_id, params)
|
await self.coordinator.roku.launch(media_id, params)
|
||||||
elif media_type == MEDIA_TYPE_CHANNEL:
|
elif media_type == MediaType.CHANNEL:
|
||||||
await self.coordinator.roku.tune(media_id)
|
await self.coordinator.roku.tune(media_id)
|
||||||
elif media_type == MEDIA_TYPE_MUSIC:
|
elif media_type == MediaType.MUSIC:
|
||||||
if extra.get(ATTR_ARTIST_NAME) is None:
|
if extra.get(ATTR_ARTIST_NAME) is None:
|
||||||
extra[ATTR_ARTIST_NAME] = "Home Assistant"
|
extra[ATTR_ARTIST_NAME] = "Home Assistant"
|
||||||
|
|
||||||
@ -456,7 +444,7 @@ class RokuMediaPlayer(RokuEntity, MediaPlayerEntity):
|
|||||||
params = {"t": "a", **params}
|
params = {"t": "a", **params}
|
||||||
|
|
||||||
await self.coordinator.roku.play_on_roku(media_id, params)
|
await self.coordinator.roku.play_on_roku(media_id, params)
|
||||||
elif media_type in (MEDIA_TYPE_URL, MEDIA_TYPE_VIDEO):
|
elif media_type in {MediaType.URL, MediaType.VIDEO}:
|
||||||
params = {
|
params = {
|
||||||
param: extra[attr]
|
param: extra[attr]
|
||||||
for (attr, param) in ATTRS_TO_PLAY_ON_ROKU_PARAMS.items()
|
for (attr, param) in ATTRS_TO_PLAY_ON_ROKU_PARAMS.items()
|
||||||
|
@ -8,18 +8,13 @@ from roonapi import split_media_path
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.media_player import (
|
from homeassistant.components.media_player import (
|
||||||
|
BrowseMedia,
|
||||||
MediaPlayerEntity,
|
MediaPlayerEntity,
|
||||||
MediaPlayerEntityFeature,
|
MediaPlayerEntityFeature,
|
||||||
|
MediaPlayerState,
|
||||||
)
|
)
|
||||||
from homeassistant.components.media_player.browse_media import BrowseMedia
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import DEVICE_DEFAULT_NAME
|
||||||
DEVICE_DEFAULT_NAME,
|
|
||||||
STATE_IDLE,
|
|
||||||
STATE_OFF,
|
|
||||||
STATE_PAUSED,
|
|
||||||
STATE_PLAYING,
|
|
||||||
)
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import config_validation as cv, entity_platform
|
from homeassistant.helpers import config_validation as cv, entity_platform
|
||||||
from homeassistant.helpers.dispatcher import (
|
from homeassistant.helpers.dispatcher import (
|
||||||
@ -106,7 +101,7 @@ class RoonDevice(MediaPlayerEntity):
|
|||||||
self._available = True
|
self._available = True
|
||||||
self._last_position_update = None
|
self._last_position_update = None
|
||||||
self._supports_standby = False
|
self._supports_standby = False
|
||||||
self._state = STATE_IDLE
|
self._state = MediaPlayerState.IDLE
|
||||||
self._unique_id = None
|
self._unique_id = None
|
||||||
self._zone_id = None
|
self._zone_id = None
|
||||||
self._output_id = None
|
self._output_id = None
|
||||||
@ -172,12 +167,12 @@ class RoonDevice(MediaPlayerEntity):
|
|||||||
if not self.player_data["is_available"]:
|
if not self.player_data["is_available"]:
|
||||||
# this player was removed
|
# this player was removed
|
||||||
self._available = False
|
self._available = False
|
||||||
self._state = STATE_OFF
|
self._state = MediaPlayerState.OFF
|
||||||
else:
|
else:
|
||||||
self._available = True
|
self._available = True
|
||||||
# determine player state
|
# determine player state
|
||||||
self.update_state()
|
self.update_state()
|
||||||
if self.state == STATE_PLAYING:
|
if self.state == MediaPlayerState.PLAYING:
|
||||||
self._last_position_update = utcnow()
|
self._last_position_update = utcnow()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -254,20 +249,20 @@ class RoonDevice(MediaPlayerEntity):
|
|||||||
if source["supports_standby"] and source["status"] != "indeterminate":
|
if source["supports_standby"] and source["status"] != "indeterminate":
|
||||||
self._supports_standby = True
|
self._supports_standby = True
|
||||||
if source["status"] in ["standby", "deselected"]:
|
if source["status"] in ["standby", "deselected"]:
|
||||||
new_state = STATE_OFF
|
new_state = MediaPlayerState.OFF
|
||||||
break
|
break
|
||||||
# determine player state
|
# determine player state
|
||||||
if not new_state:
|
if not new_state:
|
||||||
if self.player_data["state"] == "playing":
|
if self.player_data["state"] == "playing":
|
||||||
new_state = STATE_PLAYING
|
new_state = MediaPlayerState.PLAYING
|
||||||
elif self.player_data["state"] == "loading":
|
elif self.player_data["state"] == "loading":
|
||||||
new_state = STATE_PLAYING
|
new_state = MediaPlayerState.PLAYING
|
||||||
elif self.player_data["state"] == "stopped":
|
elif self.player_data["state"] == "stopped":
|
||||||
new_state = STATE_IDLE
|
new_state = MediaPlayerState.IDLE
|
||||||
elif self.player_data["state"] == "paused":
|
elif self.player_data["state"] == "paused":
|
||||||
new_state = STATE_PAUSED
|
new_state = MediaPlayerState.PAUSED
|
||||||
else:
|
else:
|
||||||
new_state = STATE_IDLE
|
new_state = MediaPlayerState.IDLE
|
||||||
self._state = new_state
|
self._state = new_state
|
||||||
self._unique_id = self.player_data["dev_id"]
|
self._unique_id = self.player_data["dev_id"]
|
||||||
self._zone_id = self.player_data["zone_id"]
|
self._zone_id = self.player_data["zone_id"]
|
||||||
|
@ -8,15 +8,14 @@ from homeassistant.components.media_player import (
|
|||||||
PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA,
|
||||||
MediaPlayerEntity,
|
MediaPlayerEntity,
|
||||||
MediaPlayerEntityFeature,
|
MediaPlayerEntityFeature,
|
||||||
|
MediaPlayerState,
|
||||||
|
MediaType,
|
||||||
)
|
)
|
||||||
from homeassistant.components.media_player.const import MEDIA_TYPE_MUSIC
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_PORT,
|
CONF_PORT,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
STATE_OFF,
|
|
||||||
STATE_ON,
|
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
@ -70,6 +69,7 @@ async def async_setup_platform(
|
|||||||
class RussoundZoneDevice(MediaPlayerEntity):
|
class RussoundZoneDevice(MediaPlayerEntity):
|
||||||
"""Representation of a Russound Zone."""
|
"""Representation of a Russound Zone."""
|
||||||
|
|
||||||
|
_attr_media_content_type = MediaType.MUSIC
|
||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
_attr_supported_features = (
|
_attr_supported_features = (
|
||||||
MediaPlayerEntityFeature.VOLUME_MUTE
|
MediaPlayerEntityFeature.VOLUME_MUTE
|
||||||
@ -130,9 +130,9 @@ class RussoundZoneDevice(MediaPlayerEntity):
|
|||||||
"""Return the state of the device."""
|
"""Return the state of the device."""
|
||||||
status = self._zone_var("status", "OFF")
|
status = self._zone_var("status", "OFF")
|
||||||
if status == "ON":
|
if status == "ON":
|
||||||
return STATE_ON
|
return MediaPlayerState.ON
|
||||||
if status == "OFF":
|
if status == "OFF":
|
||||||
return STATE_OFF
|
return MediaPlayerState.OFF
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source(self):
|
def source(self):
|
||||||
@ -144,11 +144,6 @@ class RussoundZoneDevice(MediaPlayerEntity):
|
|||||||
"""Return a list of available input sources."""
|
"""Return a list of available input sources."""
|
||||||
return [x[1] for x in self._sources]
|
return [x[1] for x in self._sources]
|
||||||
|
|
||||||
@property
|
|
||||||
def media_content_type(self):
|
|
||||||
"""Content type of current playing media."""
|
|
||||||
return MEDIA_TYPE_MUSIC
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_title(self):
|
def media_title(self):
|
||||||
"""Title of current playing media."""
|
"""Title of current playing media."""
|
||||||
|
@ -10,8 +10,9 @@ from homeassistant.components.media_player import (
|
|||||||
PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA,
|
||||||
MediaPlayerEntity,
|
MediaPlayerEntity,
|
||||||
MediaPlayerEntityFeature,
|
MediaPlayerEntityFeature,
|
||||||
|
MediaPlayerState,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, STATE_OFF, STATE_ON
|
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
@ -100,9 +101,9 @@ class RussoundRNETDevice(MediaPlayerEntity):
|
|||||||
if ret is not None:
|
if ret is not None:
|
||||||
_LOGGER.debug("Updating status for zone %s", self._zone_id)
|
_LOGGER.debug("Updating status for zone %s", self._zone_id)
|
||||||
if ret[0] == 0:
|
if ret[0] == 0:
|
||||||
self._state = STATE_OFF
|
self._state = MediaPlayerState.OFF
|
||||||
else:
|
else:
|
||||||
self._state = STATE_ON
|
self._state = MediaPlayerState.ON
|
||||||
self._volume = ret[2] * 2 / 100.0
|
self._volume = ret[2] * 2 / 100.0
|
||||||
# Returns 0 based index for source.
|
# Returns 0 based index for source.
|
||||||
index = ret[1]
|
index = ret[1]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user