mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Add support for custom media_type in mediaroom (#34625)
* Add support for custom media_type in mediaroom * Clean logging * Fix formatting Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
51eebb3906
commit
df830a50e7
@ -1,7 +1,13 @@
|
||||
"""Support for the Mediaroom Set-up-box."""
|
||||
import logging
|
||||
|
||||
from pymediaroom import PyMediaroomError, Remote, State, install_mediaroom_protocol
|
||||
from pymediaroom import (
|
||||
COMMANDS,
|
||||
PyMediaroomError,
|
||||
Remote,
|
||||
State,
|
||||
install_mediaroom_protocol,
|
||||
)
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity
|
||||
@ -41,6 +47,8 @@ DEFAULT_NAME = "Mediaroom STB"
|
||||
DEFAULT_TIMEOUT = 9
|
||||
DISCOVERY_MEDIAROOM = "mediaroom_discovery_installed"
|
||||
|
||||
MEDIA_TYPE_MEDIAROOM = "mediaroom"
|
||||
|
||||
SIGNAL_STB_NOTIFY = "mediaroom_stb_discovered"
|
||||
SUPPORT_MEDIAROOM = (
|
||||
SUPPORT_PAUSE
|
||||
@ -190,15 +198,21 @@ class MediaroomDevice(MediaPlayerEntity):
|
||||
_LOGGER.debug(
|
||||
"STB(%s) Play media: %s (%s)", self.stb.stb_ip, media_id, media_type
|
||||
)
|
||||
if media_type != MEDIA_TYPE_CHANNEL:
|
||||
_LOGGER.error("invalid media type")
|
||||
return
|
||||
if not media_id.isdigit():
|
||||
_LOGGER.error("media_id must be a channel number")
|
||||
if media_type == MEDIA_TYPE_CHANNEL:
|
||||
if not media_id.isdigit():
|
||||
_LOGGER.error("Invalid media_id %s: Must be a channel number", media_id)
|
||||
return
|
||||
media_id = int(media_id)
|
||||
elif media_type == MEDIA_TYPE_MEDIAROOM:
|
||||
if media_id not in COMMANDS:
|
||||
_LOGGER.error("Invalid media_id %s: Must be a command", media_id)
|
||||
return
|
||||
else:
|
||||
_LOGGER.error("Invalid media type %s", media_type)
|
||||
return
|
||||
|
||||
try:
|
||||
await self.stb.send_cmd(int(media_id))
|
||||
await self.stb.send_cmd(media_id)
|
||||
if self._optimistic:
|
||||
self._state = STATE_PLAYING
|
||||
self._available = True
|
||||
|
Loading…
x
Reference in New Issue
Block a user