mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Adjust type hint in mediaroom (#77817)
This commit is contained in:
parent
8e0b9e1f98
commit
bbf77ed46f
@ -2,6 +2,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from pymediaroom import (
|
from pymediaroom import (
|
||||||
COMMANDS,
|
COMMANDS,
|
||||||
@ -189,27 +190,31 @@ class MediaroomDevice(MediaPlayerEntity):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_play_media(self, media_type, media_id, **kwargs):
|
async def async_play_media(
|
||||||
|
self, media_type: str, media_id: str, **kwargs: Any
|
||||||
|
) -> None:
|
||||||
"""Play media."""
|
"""Play media."""
|
||||||
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"STB(%s) Play media: %s (%s)", self.stb.stb_ip, media_id, media_type
|
"STB(%s) Play media: %s (%s)", self.stb.stb_ip, media_id, media_type
|
||||||
)
|
)
|
||||||
|
command: str | int
|
||||||
if media_type == MEDIA_TYPE_CHANNEL:
|
if media_type == MEDIA_TYPE_CHANNEL:
|
||||||
if not media_id.isdigit():
|
if not media_id.isdigit():
|
||||||
_LOGGER.error("Invalid media_id %s: Must be a channel number", media_id)
|
_LOGGER.error("Invalid media_id %s: Must be a channel number", media_id)
|
||||||
return
|
return
|
||||||
media_id = int(media_id)
|
command = int(media_id)
|
||||||
elif media_type == MEDIA_TYPE_MEDIAROOM:
|
elif media_type == MEDIA_TYPE_MEDIAROOM:
|
||||||
if media_id not in COMMANDS:
|
if media_id not in COMMANDS:
|
||||||
_LOGGER.error("Invalid media_id %s: Must be a command", media_id)
|
_LOGGER.error("Invalid media_id %s: Must be a command", media_id)
|
||||||
return
|
return
|
||||||
|
command = media_id
|
||||||
else:
|
else:
|
||||||
_LOGGER.error("Invalid media type %s", media_type)
|
_LOGGER.error("Invalid media type %s", media_type)
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.stb.send_cmd(media_id)
|
await self.stb.send_cmd(command)
|
||||||
if self._optimistic:
|
if self._optimistic:
|
||||||
self._state = STATE_PLAYING
|
self._state = STATE_PLAYING
|
||||||
self._available = True
|
self._available = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user