From bd1e533409a6651c867725699751bb68bd7a87f8 Mon Sep 17 00:00:00 2001 From: dersger Date: Fri, 14 Jul 2017 05:00:23 +0200 Subject: [PATCH] Fix media_position for cast component (#8452) * Make it available during state paused. * Don't adjust for media_position_updated_at. I.e. do as vlc, sonos etc so that returned position is the position at the time of media_position_updated_at, not now. --- homeassistant/components/media_player/cast.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/media_player/cast.py b/homeassistant/components/media_player/cast.py index 418d3576750..51acf68d819 100644 --- a/homeassistant/components/media_player/cast.py +++ b/homeassistant/components/media_player/cast.py @@ -234,18 +234,13 @@ class CastDevice(MediaPlayerDevice): @property def media_position(self): """Position of current playing media in seconds.""" - if self.media_status is None or self.media_status_received is None or \ + if self.media_status is None or \ not (self.media_status.player_is_playing or + self.media_status.player_is_paused or self.media_status.player_is_idle): return None - position = self.media_status.current_time - - if self.media_status.player_is_playing: - position += (dt_util.utcnow() - - self.media_status_received).total_seconds() - - return position + return self.media_status.current_time @property def media_position_updated_at(self):