Zum Hauptinhalt springen

Last.fm Smart-Home-Integration, kostenlos und Open Source

Last.fm-Integration für Gladys Assistant

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

Info

Die Dokumentation dieser Integration wird von ihrem Autor geschrieben und ist bisher nur auf Englisch verfügbar.

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

Konfigurationseinstellungen​

Diese Einstellungen fragt Last.fm in seinem Konfigurationsbildschirm in Gladys ab.

EinstellungTypPflichtfeldBeschreibung
Last.fm API keysectionNeinLast.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 keysecretJa32 characters.
Shared secretsecretNeinOnly needed to link an account (to love tracks).
Profiles to followstringJaLast.fm usernames, separated by commas (10 at most). Each one becomes a device on the Discovery screen.
Refresh interval (s)numberNeinHow 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)sectionNeinOnly 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_linkNein

So installierst du Last.fm in Gladys​

  1. Öffne in Gladys Integrationen: Last.fm erscheint im Katalog neben den nativen Integrationen, mit einem Community-Badge.
  2. Klicke auf Installieren. Gladys lädt das Docker-Image (ghcr.io/william-de71/gladys-lastfm:1.0.0) herunter, startet es in einer vom Kern isolierten Sandbox und erzeugt die Oberfläche der Integration (Geräte, Erkennung und Konfiguration).
  3. Öffne den Bildschirm Konfiguration der Integration, fülle die Einstellungen aus und speichere.
  4. Du kannst sie auch direkt über die URL ihres Repositorys installieren: https://github.com/William-De71/gladys-lastfm.

Last.fm benötigt Gladys >=5.1.1. Der Katalog in Gladys wird stündlich aktualisiert, eine neue Version ist also spätestens eine Stunde nach ihrer Veröffentlichung verfügbar.

Du nutzt Gladys noch nicht? Es ist kostenlos und Open Source: folge der Installationsanleitung, um loszulegen.

Über externe Integrationen​

Last.fm ist eine externe Integration: eine Community-Integration, die als Docker-Container verpackt und auf GitHub veröffentlicht wird. Gladys installiert sie mit einem Klick und führt sie in einer vom Kern isolierten Sandbox aus. Sie wird von William-De71 veröffentlicht und gepflegt, nicht vom Gladys-Kernteam.

Abonniere den Newsletter von Gladys Assistant

Ein paar E-Mails im Monat zu neuen Releases und Neuigkeiten aus dem Projekt. Verschickt von Pierre-Gilles Leymarie, dem Gründer des Projekts. Jederzeit abbestellbar 🙂