If you’ve been looking for a way to integrate Ampache with Home Assistant, here’s a solid workaround using Last.FM.
I’m currently using Ampache 6.5.0. I can’t say for sure if the Last.FM plugin works in earlier versions, but this is the version I’ve confirmed it with.
- Create a Last.FM account** (if you don’t already have one). It’s free!
- Locate your
ampache.cfg.php
file**, usually found at:
/var/www/html/ampache/config/
- Open the file with a text editor:
nano ampache.cfg.php
Then locate thelastfm_api_key
andlastfm_api_secret
fields, and update them with your Last.FM API key and secret. - Generate your Last.FM API key and secret by visiting: https://www.last.fm/api/account/create
- In Ampache, go to Preferences (gear icon) → Plugins, then click the plug icon next to Last.FM to activate the integration.
- Once Last.FM is connected to Ampache, go to Home Assistant, add the Last.FM integration, and enter the same API key and your Last.FM username.
If everything is set up correctly, you should see sensor.lastfm
and its state attributes in Home Assistant’s Developer Tools.
Note: the scrobbling sensor did not work for me. Not certain if this is a bug, i haven’t dug deeper. I was more interested in the attributes that came with the lastfm sensor.
- Now we can fetch those attributes and use them however you’d like. In this example, I’ll use a template by editing my
configuration.yaml
.
template:
- sensor:
- name: "LastFM Play Count"
state: "{{ state_attr('sensor.lastfm_suflylatinoguy', 'play_count') }}"
- name: "LastFM Last Played"
state: "{{ state_attr('sensor.lastfm_suflylatinoguy', 'last_played') }}"
- name: "LastFM Top Played"
state: "{{ state_attr('sensor.lastfm_suflylatinoguy', 'top_played') }}"
- Go ahead and add an Entity Card in your dashboard—it should look something like this:
Now, anything that you play in Ampache will be displayed in Home Assistant