mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
* addresses @MartinHjelmare on #11864 * as requested by @MartinHjelmare
This commit is contained in:
parent
b33d89326f
commit
c209c10887
@ -5,6 +5,7 @@ For more details about this platform, please refer to the documentation at
|
|||||||
https://home-assistant.io/components/media_player.mediaroom/
|
https://home-assistant.io/components/media_player.mediaroom/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.media_player import (
|
from homeassistant.components.media_player import (
|
||||||
@ -26,8 +27,7 @@ NOTIFICATION_TITLE = 'Mediaroom Media Player Setup'
|
|||||||
NOTIFICATION_ID = 'mediaroom_notification'
|
NOTIFICATION_ID = 'mediaroom_notification'
|
||||||
DEFAULT_NAME = 'Mediaroom STB'
|
DEFAULT_NAME = 'Mediaroom STB'
|
||||||
DEFAULT_TIMEOUT = 9
|
DEFAULT_TIMEOUT = 9
|
||||||
|
DATA_MEDIAROOM = "mediaroom_known_stb"
|
||||||
KNOWN_HOSTS = []
|
|
||||||
|
|
||||||
SUPPORT_MEDIAROOM = SUPPORT_PAUSE | SUPPORT_TURN_ON | SUPPORT_TURN_OFF | \
|
SUPPORT_MEDIAROOM = SUPPORT_PAUSE | SUPPORT_TURN_ON | SUPPORT_TURN_OFF | \
|
||||||
SUPPORT_VOLUME_STEP | SUPPORT_VOLUME_MUTE | \
|
SUPPORT_VOLUME_STEP | SUPPORT_VOLUME_MUTE | \
|
||||||
@ -46,18 +46,22 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
"""Set up the Mediaroom platform."""
|
"""Set up the Mediaroom platform."""
|
||||||
hosts = []
|
hosts = []
|
||||||
|
|
||||||
|
known_hosts = hass.data.get(DATA_MEDIAROOM)
|
||||||
|
if known_hosts is None:
|
||||||
|
known_hosts = hass.data[DATA_MEDIAROOM] = []
|
||||||
|
|
||||||
host = config.get(CONF_HOST, None)
|
host = config.get(CONF_HOST, None)
|
||||||
if host is None:
|
if host is None:
|
||||||
_LOGGER.info("Trying to discover Mediaroom STB")
|
_LOGGER.info("Trying to discover Mediaroom STB")
|
||||||
|
|
||||||
from pymediaroom import Remote
|
from pymediaroom import Remote
|
||||||
|
|
||||||
host = Remote.discover(KNOWN_HOSTS)
|
host = Remote.discover(known_hosts)
|
||||||
if host is None:
|
if host is None:
|
||||||
# Can't find any STB
|
_LOGGER.warning("Can't find any STB")
|
||||||
return False
|
return
|
||||||
hosts.append(host)
|
hosts.append(host)
|
||||||
KNOWN_HOSTS.append(host)
|
known_hosts.append(host)
|
||||||
|
|
||||||
stbs = []
|
stbs = []
|
||||||
|
|
||||||
@ -82,8 +86,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
|
|
||||||
add_devices(stbs)
|
add_devices(stbs)
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class MediaroomDevice(MediaPlayerDevice):
|
class MediaroomDevice(MediaPlayerDevice):
|
||||||
"""Representation of a Mediaroom set-up-box on the network."""
|
"""Representation of a Mediaroom set-up-box on the network."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user