LastFM Scrobbler Integration

Hello Home Assistant Community!

I am thrilled to introduce my LastFM Scrobbler Integration for Home Assistant. This integration enables you to scrobble tracks played on selected media players directly to your Last.fm account seamlessly. This project marks my first significant venture into development, and I’m excited to share it with this community.

Key Features:

  • Automatic scrobbling of tracks from whitelisted media players in Home Assistant.
  • Configurable scrobble time.
  • Easy setup with detailed instructions.

Installation:
The installation is simple, especially if you have HACS (Home Assistant Community Store) installed:

  1. Add the custom repository: https://github.com/valentin-gosselin/lastfm-scrobbler-ha-integration.
  2. Install the LastFM Scrobbler Integration from HACS.
  3. Follow the README on GitHub for configuration steps: GitHub - LastFM Scrobbler Integration.

Configuration:
You’ll need to obtain your Last.fm API credentials and update your configuration.yaml and secrets.yaml files accordingly. I’ve provided a step-by-step guide on GitHub to walk you through the process, including obtaining the session key.

Usage:
Once set up, simply play music on any of the whitelisted media players in Home Assistant, and tracks will be automatically scrobbled to your Last.fm account.

Troubleshooting:
I’ve included a troubleshooting section in the README to help resolve common issues. You can also post your questions or issues here, and I’ll be happy to assist!

I am eagerly looking forward to hearing your feedback, experiences, and possibly contributions to improve this integration further. It’s a journey of learning and improving, and I’m thrilled to embark on it with the support of this amazing community.

Happy Scrobbling!

Best regards,
Valentin Gosselin

4 Likes

Fabulous! Works a treat, and centralises scrobbling across the house from various media players. Last.fm isn’t dead yet. :slight_smile:

Once set up, simply play music on any of the whitelisted media players in Home Assistant

What do you mean by “whitelisted”? I’m not seeming to get any errors after running through the setup, but my scrobbles aren’t making it to Last.fm. So I’m wondering if there’s something I’m missing to “whitelist” my media player…

EDIT:
Sorry, I’m very new to HA. I got it working. I think it was that I needed to add the entity ID to my config.

I was tinkering with my config yaml and ended up with a number of issues I had to address, but when I had resolved them all the LastFM integration started working. Hopefully this is of some help to others.

How did you do this dwkra? cant get it to work grrrrr

Nice job, thanks!
I’d like to scrobble tracks I listen to on radio station via the HEOS integration, but I assume the following applies to other radio-with-metadata situations as well.
There is no duration/position information in this case, which causes calculate_current_position to throw an exception:

Logger: custom_components.lastfm_scrobbler.media_player
Source: custom_components/lastfm_scrobbler/media_player.py:81
Integration: LastFM Scrobbler (Dokumentation)
Erstmals aufgetreten: 20:52:04 (47 Vorkommnisse)
Zuletzt protokolliert: 20:59:44
Unexpected type for last_updated_at: <class 'NoneType'>

Here are the status attributes for my media player (removed irrelevant entries):

volume_level: 0.23
is_volume_muted: false
media_content_id: ...
media_content_type: music
media_title: <Title>
media_artist: <Artist>
media_album_name: ""
source: <Name of the radio station>
media_album_id: <Album>
media_queue_id: 1
media_source_id: 3
media_station: <Name of the radio station>
media_type: station
media_duration: 0

media_duration remains 0 all the time while listening to a radio station.
There is no media_position or media_position_updated_at
I guess media_type: station would be a good condition to check if we’re in radio mode.
Is there a chance you could add support for scrobbling radio station titles as well?
If you think this is a good idea, but don’t have the time/means to , I could try to get it working and make a PR.

Edit: Looks like someone might have already worked on that: Comparing valentin-gosselin:master...SpiralP:master · valentin-gosselin/lastfm-scrobbler-ha-integration · GitHub