Improve type hints in lastfm sensor (#77657)
This commit is contained in:
parent
be07bb7976
commit
23a579d1c9
1 changed files with 6 additions and 5 deletions
|
@ -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,10 +101,11 @@ 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:
|
||||||
self._state = STATE_NOT_SCROBBLING
|
self._state = STATE_NOT_SCROBBLING
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue