Skip to content

Commit 2d0b00b

Browse files
committed
add on_deck
1 parent 85b39b2 commit 2d0b00b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Read through these two resources before posting issues to GitHub or the forums.
3232
| port | 32400 | yes | The port Plex is running on.
3333
| ssl | false | no | Set to true if you use SSL to access Plex.
3434
| max | 5 | no | Max number of items to show in sensor.
35+
| on_deck | False | no | Set to true to show "on deck" items.
3536
| download_images | true | no | Setting this to false will turn off downloading of images, but will require certain Plex settings to work. See below.
3637
| img_dir | '/upcoming-media-card-images/plex/' | no | This option allows you to choose a custom directory to store images in if you enable download_images. Directory must start and end with a `/`.
3738
| ssl_cert | false | no | If you provide your own SSL certificate in Plex's network settings set this to true.

custom_components/plex_recently_added/sensor.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ async def request(url, self, content=False, ssl=False):
4949
CONF_IMG_CACHE = 'img_dir'
5050
CONF_SECTION_TYPES = 'section_types'
5151
CONF_RESOLUTION = 'image_resolution'
52+
CONF_ON_DECK = 'on_deck'
5253

5354
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
5455
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
@@ -58,6 +59,7 @@ async def request(url, self, content=False, ssl=False):
5859
vol.Optional(CONF_MAX, default=5): cv.string,
5960
vol.Optional(CONF_SERVER): cv.string,
6061
vol.Optional(CONF_DL_IMAGES, default=True): cv.boolean,
62+
vol.Optional(CONF_ON_DECK, default=False): cv.boolean,
6163
vol.Optional(CONF_HOST, default='localhost'): cv.string,
6264
vol.Optional(CONF_PORT, default=32400): cv.port,
6365
vol.Optional(CONF_SECTION_TYPES,
@@ -92,6 +94,7 @@ def __init__(self, hass, conf, name):
9294
self.server_name = conf.get(CONF_SERVER)
9395
self.max_items = int(conf.get(CONF_MAX))
9496
self.dl_images = conf.get(CONF_DL_IMAGES)
97+
self.on_deck = conf.get(CONF_ON_DECK)
9598
self.sections = conf.get(CONF_SECTION_TYPES)
9699
self.resolution = conf.get(CONF_RESOLUTION)
97100
if self.server_name:
@@ -224,6 +227,8 @@ async def async_update(self):
224227
all_libraries = url_base + '/all'
225228
recently_added = (url_base + '/{0}/recentlyAdded?X-Plex-Container-'
226229
'Start=0&X-Plex-Container-Size={1}')
230+
on_deck = (url_base + '/{0}/onDeck?X-Plex-Container-'
231+
'Start=0&X-Plex-Container-Size={1}')
227232

228233
"""Find the ID of all libraries in Plex."""
229234
sections = []
@@ -241,7 +246,8 @@ async def async_update(self):
241246
self._state = 'Online'
242247
"""Get JSON for each library, combine and sort."""
243248
for library in sections:
244-
sub_sec = await request(recently_added.format(
249+
recent_or_deck = on_deck if self.on_deck else recently_added
250+
sub_sec = await request(recent_or_deck.format(
245251
library, self.max_items * 2), self)
246252
sub_sec = json.loads(sub_sec)
247253
try:

0 commit comments

Comments
 (0)