From 48179d533aeb268241336a2f5164f8de798dc170 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Sat, 9 Sep 2023 16:46:56 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Martin Hjelmare --- homeassistant/components/vlc_telnet/media_player.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/vlc_telnet/media_player.py b/homeassistant/components/vlc_telnet/media_player.py index c148727e22f93b..e2a170afd33cfe 100644 --- a/homeassistant/components/vlc_telnet/media_player.py +++ b/homeassistant/components/vlc_telnet/media_player.py @@ -107,7 +107,7 @@ def __init__( @catch_vlc_errors async def async_update(self) -> None: """Get the latest details from the device.""" - if not self._attr_available: + if not self.available: try: await self._vlc.connect() except ConnectError as err: @@ -145,7 +145,7 @@ async def async_update(self) -> None: vlc_position = time_output.time # Check if current position is stale. - if vlc_position != self._attr_media_position: + if vlc_position != self.media_position: self._attr_media_position_updated_at = dt_util.utcnow() self._attr_media_position = vlc_position @@ -160,11 +160,11 @@ async def async_update(self) -> None: # Many radio streams put artist/title/album in now_playing and title is the station name. if now_playing: - if not self._attr_media_artist: + if not self.media_artist: self._attr_media_artist = self._attr_media_title self._attr_media_title = now_playing - if self._attr_media_title: + if self.media_title: return # Fall back to filename. @@ -173,7 +173,7 @@ async def async_update(self) -> None: # Strip out auth signatures if streaming local media if ( - self._attr_media_title + self.media_title and (pos := self._attr_media_title.find("?authSig=")) != -1 ): self._attr_media_title = self._attr_media_title[:pos] @@ -201,7 +201,7 @@ async def async_set_volume_level(self, volume: float) -> None: await self._vlc.set_volume(round(volume * MAX_VOLUME)) self._attr_volume_level = volume - if self._attr_is_volume_muted and self._attr_volume_level > 0: + if self.is_volume_muted and self.volume_level > 0: # This can happen if we were muted and then see a volume_up. self._attr_is_volume_muted = False