Check mpd time type before splitting it (#40139)

pull/40179/head
Chris Talkington 2020-09-17 09:01:28 -05:00 committed by Franck Nijhof
parent a9e220c96b
commit 99a57f5a4e
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
1 changed files with 4 additions and 3 deletions

View File

@ -138,12 +138,12 @@ class MpdDevice(MediaPlayerEntity):
if position is None:
position = self._status.get("time")
if position is not None and ":" in position:
if isinstance(position, str) and ":" in position:
position = position.split(":")[0]
if position is not None and self._media_position != position:
self._media_position_updated_at = dt_util.utcnow()
self._media_position = int(position)
self._media_position = int(float(position))
self._update_playlists()
@ -159,8 +159,9 @@ class MpdDevice(MediaPlayerEntity):
self._connect()
self._fetch_status()
except (mpd.ConnectionError, OSError, BrokenPipeError, ValueError):
except (mpd.ConnectionError, OSError, BrokenPipeError, ValueError) as error:
# Cleanly disconnect in case connection is not in valid state
_LOGGER.debug("Error updating status: %s", error)
self._disconnect()
@property