From cdcc818bf9360dc6b7fa841949059deea8ccab6c Mon Sep 17 00:00:00 2001 From: ehendrix23 Date: Mon, 19 Nov 2018 03:47:00 -0700 Subject: [PATCH] Remove turn_on and turn_off feature for clients (#18234) * Enhancements for DirecTV media player Following enhancements have been made: 1. Added debug logging 2. Added ability to change channel using select_source service of the remote platform. 3. State will now show paused if a recorded program is paused, for live TV playing will always be returned. 4. Added the following attributes: a. media_position: current position of the media (in seconds) b. media_position_updated_at: timestamp when media_position was updated. c. source: current source (channel). d. media_isbeingrecorded: if current media is being recorded or not. e. media_rating: TV/Movie rating of the media f. media_recorded: if current media is recorded or live TV g. media_starttime: Timestamp media was aired Reordered properties to follow same order as how they are in __init__.py of remote platform. * Fixed error and cleaned up few items Fixed an issue when determining if a program is recorded or not. Cleaned up some coding. * Added available property Added available property * Disable feature TURN_ON and TURN_OFF for DVR clients Disable the feature turn_on and turn_off for DVR clients. * self._is_client and raise NotImplementedError Updated setting self._is_client Raise NotImplementedError if turn_on or turn_off is called for clients. --- .../components/media_player/directv.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/media_player/directv.py b/homeassistant/components/media_player/directv.py index 7ae80172fac..51f5cbc5bb0 100644 --- a/homeassistant/components/media_player/directv.py +++ b/homeassistant/components/media_player/directv.py @@ -36,6 +36,10 @@ SUPPORT_DTV = SUPPORT_PAUSE | SUPPORT_TURN_ON | SUPPORT_TURN_OFF | \ SUPPORT_PLAY_MEDIA | SUPPORT_SELECT_SOURCE | SUPPORT_STOP | \ SUPPORT_NEXT_TRACK | SUPPORT_PREVIOUS_TRACK | SUPPORT_PLAY +SUPPORT_DTV_CLIENT = SUPPORT_PAUSE | \ + SUPPORT_PLAY_MEDIA | SUPPORT_SELECT_SOURCE | SUPPORT_STOP | \ + SUPPORT_NEXT_TRACK | SUPPORT_PREVIOUS_TRACK | SUPPORT_PLAY + DATA_DIRECTV = 'data_directv' PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ @@ -126,10 +130,15 @@ class DirecTvDevice(MediaPlayerDevice): self._paused = None self._last_position = None self._is_recorded = None + self._is_client = device != '0' self._assumed_state = None self._available = False - _LOGGER.debug("Created DirecTV device for %s", self._name) + if self._is_client: + _LOGGER.debug("Created DirecTV client %s for device %s", + self._name, device) + else: + _LOGGER.debug("Created DirecTV device for %s", self._name) def update(self): """Retrieve latest state.""" @@ -290,7 +299,7 @@ class DirecTvDevice(MediaPlayerDevice): @property def supported_features(self): """Flag media player features that are supported.""" - return SUPPORT_DTV + return SUPPORT_DTV_CLIENT if self._is_client else SUPPORT_DTV @property def media_currently_recording(self): @@ -327,11 +336,17 @@ class DirecTvDevice(MediaPlayerDevice): def turn_on(self): """Turn on the receiver.""" + if self._is_client: + raise NotImplementedError() + _LOGGER.debug("Turn on %s", self._name) self.dtv.key_press('poweron') def turn_off(self): """Turn off the receiver.""" + if self._is_client: + raise NotImplementedError() + _LOGGER.debug("Turn off %s", self._name) self.dtv.key_press('poweroff')