mirror of
https://github.com/home-assistant/core.git
synced 2025-07-11 07:17:12 +00:00
Improve type hints in lastfm sensor (#77657)
This commit is contained in:
parent
be07bb7976
commit
23a579d1c9
@ -91,7 +91,7 @@ class LastfmSensor(SensorEntity):
|
|||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Update device state."""
|
"""Update device state."""
|
||||||
self._cover = self._user.get_image()
|
self._cover = self._user.get_image()
|
||||||
self._playcount = self._user.get_playcount()
|
self._playcount = self._user.get_playcount()
|
||||||
@ -101,9 +101,10 @@ class LastfmSensor(SensorEntity):
|
|||||||
self._lastplayed = f"{last.track.artist} - {last.track.title}"
|
self._lastplayed = f"{last.track.artist} - {last.track.title}"
|
||||||
|
|
||||||
if top_tracks := self._user.get_top_tracks(limit=1):
|
if top_tracks := self._user.get_top_tracks(limit=1):
|
||||||
top = top_tracks[0]
|
top = str(top_tracks[0])
|
||||||
toptitle = re.search("', '(.+?)',", str(top))
|
if (toptitle := re.search("', '(.+?)',", top)) and (
|
||||||
topartist = re.search("'(.+?)',", str(top))
|
topartist := re.search("'(.+?)',", top)
|
||||||
|
):
|
||||||
self._topplayed = f"{topartist.group(1)} - {toptitle.group(1)}"
|
self._topplayed = f"{topartist.group(1)} - {toptitle.group(1)}"
|
||||||
|
|
||||||
if (now_playing := self._user.get_now_playing()) is None:
|
if (now_playing := self._user.get_now_playing()) is None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user