Skip to main content

Last.fm smart home integration, free and open source

Last.fm integration for Gladys Assistant

What you listen to on Last.fm: scrobbles, music scenes and widgets.

This integration brings your Last.fm listening into Gladys: what you are listening to right now, your scrobbles, scenes that react to the music, and three dashboard widgets.

Last.fm records ("scrobbles") every track played on Spotify, Deezer, Apple Music, YouTube Music, Tidal, Plex, Sonos and many more players. Whatever the player: if your listening reaches your Last.fm profile, Gladys sees it.

Community integration, not affiliated with Last.fm.

Setup​

1. Create an API key (free)​

  1. Sign in to Last.fm, then open Create an API account.
  2. Fill in an application name (e.g. "Gladys") and a description. The callback URL can stay empty.
  3. Last.fm shows an API key (32 characters) and a shared secret. Find them again at any time in My API accounts.

2. Fill in the integration​

FieldPurpose
API keyrequired
Shared secretonly to link an account (love tracks from Gladys)
Profiles to followLast.fm usernames separated by commas (10 at most): yours, a relative's…
Refresh interval30 seconds by default (15 to 300): this is how fast the scenes react

Save. The Test the connection button checks the key and reads every profile.

A profile that hides its recent listening (Last.fm privacy settings) cannot be followed: Last.fm refuses to share it.

3. Add the devices​

On the Discovery tab, each followed profile shows up as a "Last.fm – name" device. Add it and put it in a room. Widgets and scenes work without a device too, but picking a profile in their settings goes through the device list.

Only to love or unlove tracks from Gladys (widget button, scene actions):

  1. fill in the shared secret and save;
  2. click Connect: a Last.fm page opens;
  3. click Yes, allow access. Gladys notices within a few seconds: the configuration screen reads "account name linked".

Nothing else is needed: no redirect URL to declare. The page stays valid 15 minutes; past that, click Connect again.

To unlink: the Unlink the account button, and optionally revoke the access in your Last.fm settings (Applications).

The device of a profile​

FeatureValue
Listening1 while a track is playing, 0 otherwise
Current or last track"Artist – Track"; keeps the last track once listening stopped
Scrobbles todaysince midnight, in the Gladys time zone
Total scrobblessince the account was created

History is kept: the dashboard "Chart" box shows your week of listening, and the usual scenes on a device value work ("more than 100 scrobbles today"…).

Scene triggers​

In the scene editor, under Last.fm:

TriggerFires when…Filters
Last.fm: new tracka profile starts playing a trackprofile, artist
Last.fm: listening starteda profile starts listening after a pauseprofile
Last.fm: listening stoppednothing has been playing for two checks in a rowprofile
Last.fm: track loveda profile loves a track (on Last.fm or in a connected player)profile, artist

Passed on to the scene actions: username, artist, track, album, loved, Last.fm link, and a ready-to-send summary; for "listening stopped", the session length (minutes) and the number of tracks played.

Examples:

  • Listening started → dim the living room and power the amplifier on;
  • Listening stopped → power the amplifier off;
  • New track, artist "Daft Punk" → disco lights.

Good to know:

  • The Artist filter compares the name exactly as Last.fm spells it, case included ("Daft Punk", not "daft punk").
  • Last.fm pushes nothing: the integration reads the profiles every 30 seconds by default, so a scene reacts within a few seconds to half a minute.
  • When the integration starts, a session already in progress does not fire "Listening started"; only the next track counts.
  • The same track played twice in a row counts once (Last.fm gives no way to tell the two plays apart).

Scene actions​

ActionResult
Last.fm: what is playinglistening (yes/no), artist, track, album, loved, link, time played, summary
Last.fm: listening statisticsscrobbles today and in total, top artist / album / track over a period, summary
Last.fm: love a trackadds a track to the loved tracks of the linked account
Last.fm: unlove a trackremoves it

To love or unlove: leave artist and track empty to target the track playing now (or the last one played) on the linked account, or fill them in (scene variables accepted). Both actions need a linked account.

Dashboard widgets​

WidgetContent
Last.fm now playingcover, track, artist and album, scrobbles today and in total, status, Love button (linked account), link
Last.fm recent tracksthe latest tracks with their covers; the track playing now and the loved ones are badged
Last.fm top chartstop artists, albums (as a cover grid) or tracks over 7 days, 1, 3, 6 or 12 months, or all time

Each widget is set to a profile (empty = the first followed profile). The "now playing" widget refreshes as soon as a new track starts.

Last.fm has not served artist pictures since 2019: the top artists show without images.

Troubleshooting​

SymptomLikely cause
"Last.fm refuses the API key"key miscopied, or a wrong shared secret when linking
A profile is missing from Discoverythe username does not exist (see the integration logs)
"hides their recent listening"the profile enabled the matching privacy option on Last.fm
Nothing happens while listeningthe player does not scrobble: check that the track shows on your Last.fm profile
The Connect button failsshared secret missing: fill it in and save before clicking

Configuration settings​

These are the settings Last.fm asks for in its configuration screen in Gladys.

SettingTypeRequiredDescription
Last.fm API keysectionNoLast.fm records what you listen to on Spotify, Deezer, Apple Music, YouTube Music, Plex and many more. Reading your listening needs a free API key: create an API account on Last.fm (any application name; the callback URL can stay empty), then copy its API key and shared secret below.
API keysecretYes32 characters.
Shared secretsecretNoOnly needed to link an account (to love tracks).
Profiles to followstringYesLast.fm usernames, separated by commas (10 at most). Each one becomes a device on the Discovery screen.
Refresh interval (s)numberNoHow often the profiles are read, between 15 and 300 seconds. Last.fm has no push: this is the delay of the scenes.
Link your account (optional)sectionNoOnly needed to love or unlove tracks from Gladys (widget button, scene actions). Fill in the shared secret and save first, then click Connect and approve the access on the Last.fm page that opens. Gladys detects the approval within a few seconds.
Last.fm accountaccount_linkNo

How to install Last.fm in Gladys​

  1. In Gladys, open Integrations: Last.fm appears in the catalog, next to the native integrations, with a community badge.
  2. Click Install. Gladys pulls the Docker image (ghcr.io/william-de71/gladys-lastfm:1.0.0), starts it in a sandbox isolated from the core, and generates the integration's interface (devices, discovery and configuration).
  3. Open the Configuration screen of the integration, fill in the settings, and save.
  4. You can also install it directly from its repository URL: https://github.com/William-De71/gladys-lastfm.

Last.fm requires Gladys >=5.1.1. The catalog inside Gladys refreshes every hour, so a new version becomes available at most one hour after its release.

Not running Gladys yet? It is free and open source: follow the installation guide to get started.

About external integrations​

Last.fm is an external integration: a community integration packaged as a Docker container and published on GitHub, that Gladys installs in one click and runs in a sandbox isolated from its core. It is published and maintained by William-De71, not by the Gladys core team.

Subscribe to the Gladys Assistant newsletter

A few emails per month about new releases and project news. Sent by Pierre-Gilles Leymarie, founder of the project. Unsubscribe anytime 🙂