mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Move configuration details to docs
This commit is contained in:
parent
a8a172c8b7
commit
47f994b867
@ -1,34 +1,11 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.media_player.plex
|
homeassistant.components.media_player.plex
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
Provides an interface to the Plex API.
|
||||||
|
|
||||||
Provides an interface to the Plex API
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/media_player.plex.html
|
||||||
Configuration:
|
|
||||||
|
|
||||||
To use Plex add something like this to your configuration:
|
|
||||||
|
|
||||||
media_player:
|
|
||||||
platform: plex
|
|
||||||
name: plex_server
|
|
||||||
user: plex
|
|
||||||
password: my_secure_password
|
|
||||||
|
|
||||||
Variables:
|
|
||||||
|
|
||||||
name
|
|
||||||
*Required
|
|
||||||
The name of the backend device (Under Plex Media Server > settings > server).
|
|
||||||
|
|
||||||
user
|
|
||||||
*Required
|
|
||||||
The Plex username
|
|
||||||
|
|
||||||
password
|
|
||||||
*Required
|
|
||||||
The Plex password
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
@ -49,10 +26,8 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
SUPPORT_PLEX = SUPPORT_PAUSE | SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK
|
SUPPORT_PLEX = SUPPORT_PAUSE | SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK
|
||||||
|
|
||||||
# pylint: disable=abstract-method
|
|
||||||
# pylint: disable=unused-argument
|
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=abstract-method, unused-argument
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Sets up the plex platform. """
|
""" Sets up the plex platform. """
|
||||||
from plexapi.myplex import MyPlexUser
|
from plexapi.myplex import MyPlexUser
|
||||||
@ -68,7 +43,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
|
|
||||||
@util.Throttle(MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS)
|
@util.Throttle(MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS)
|
||||||
def update_devices():
|
def update_devices():
|
||||||
""" Updates the devices objects """
|
""" Updates the devices objects. """
|
||||||
try:
|
try:
|
||||||
devices = plexuser.devices()
|
devices = plexuser.devices()
|
||||||
except BadRequest:
|
except BadRequest:
|
||||||
@ -94,7 +69,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
|
|
||||||
@util.Throttle(MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS)
|
@util.Throttle(MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS)
|
||||||
def update_sessions():
|
def update_sessions():
|
||||||
""" Updates the sessions objects """
|
""" Updates the sessions objects. """
|
||||||
try:
|
try:
|
||||||
sessions = plexserver.sessions()
|
sessions = plexserver.sessions()
|
||||||
except BadRequest:
|
except BadRequest:
|
||||||
@ -113,7 +88,6 @@ class PlexClient(MediaPlayerDevice):
|
|||||||
""" Represents a Plex device. """
|
""" Represents a Plex device. """
|
||||||
|
|
||||||
# pylint: disable=too-many-public-methods
|
# pylint: disable=too-many-public-methods
|
||||||
|
|
||||||
def __init__(self, device, plex_sessions, update_devices, update_sessions):
|
def __init__(self, device, plex_sessions, update_devices, update_sessions):
|
||||||
self.plex_sessions = plex_sessions
|
self.plex_sessions = plex_sessions
|
||||||
self.update_devices = update_devices
|
self.update_devices = update_devices
|
||||||
@ -121,12 +95,12 @@ class PlexClient(MediaPlayerDevice):
|
|||||||
self.set_device(device)
|
self.set_device(device)
|
||||||
|
|
||||||
def set_device(self, device):
|
def set_device(self, device):
|
||||||
""" Sets the device property """
|
""" Sets the device property. """
|
||||||
self.device = device
|
self.device = device
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def session(self):
|
def session(self):
|
||||||
""" Returns the session, if any """
|
""" Returns the session, if any. """
|
||||||
if self.device.clientIdentifier not in self.plex_sessions:
|
if self.device.clientIdentifier not in self.plex_sessions:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -196,21 +170,21 @@ class PlexClient(MediaPlayerDevice):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def media_season(self):
|
def media_season(self):
|
||||||
""" Season of curent playing media. (TV Show only) """
|
""" Season of curent playing media (TV Show only). """
|
||||||
from plexapi.video import Show
|
from plexapi.video import Show
|
||||||
if isinstance(self.session, Show):
|
if isinstance(self.session, Show):
|
||||||
return self.session.seasons()[0].index
|
return self.session.seasons()[0].index
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_series_title(self):
|
def media_series_title(self):
|
||||||
""" Series title of current playing media. (TV Show only)"""
|
""" Series title of current playing media (TV Show only). """
|
||||||
from plexapi.video import Show
|
from plexapi.video import Show
|
||||||
if isinstance(self.session, Show):
|
if isinstance(self.session, Show):
|
||||||
return self.session.grandparentTitle
|
return self.session.grandparentTitle
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_episode(self):
|
def media_episode(self):
|
||||||
""" Episode of current playing media. (TV Show only) """
|
""" Episode of current playing media (TV Show only). """
|
||||||
from plexapi.video import Show
|
from plexapi.video import Show
|
||||||
if isinstance(self.session, Show):
|
if isinstance(self.session, Show):
|
||||||
return self.session.index
|
return self.session.index
|
||||||
|
Loading…
x
Reference in New Issue
Block a user