HomePod Connect: Spotify on HomePods with Spotify Connect

This addon allows you to play Spotify music on your HomePods.

It is based on OwnTone and librespot-java. And can be integrated into Home Assistant with the OwnTone integration.

Please keep in mind that this addon is experimental. I am using it by myself for two weeks without any major issue. But small audio drops (for like 1-10 seconds) are really common. So please do not report them.

Features

  • OwnTone & librespot-java inside one Docker image
  • Ready out of the box with zeroconf & Home Assistant integration
  • Control OwnTone through Home Assistant
  • Metadata support (visible in Home Assistant)
  • Fully customizable through the config files in /config/owntone

Requirements

  • A Spotify Premium account
  • At least one HomePod
  • Correct set up in the Home app
    • Home → Home Settings → Allow Speaker & TV Access → Anyone On the same Network
    • Home → Home Settings → Allow Speaker & TV Access → Require Password: Disabled
  • VSCode addon or any other text editor to edit the configuration

Limitations

  • You cannot control the playback through the HomePods. Only through Spotify. (Volume adjustments are possible, though)
  • Sometimes the addon becomes unresponsive. A restart should fix it.
  • The streams are maybe not in perfect sync. You will notice that if you have multiple HomePods in the same room.
  • Sometimes the playback stops for a few seconds and then continues afterwards. (Without issuing play/pause commands)

Installation

Download the addon: Open your Home Assistant instance and show the dashboard of a Supervisor add-on.

Install the integration: Open your Home Assistant instance and start setting up a new integration.

Configuration

You can use the VSCode add-on to customize the configuration.

You can configure OwnTone through its configuration file. It can be found at /config/owntone/owntone.conf.
Librespot-java is configurable through its configuration file at /config/owntone/librespot-java.toml
After adjusting something, please restart the add-on.

Access OwnTone

You can access OwnTone through [Home Assistant IP]:3689

OwnTone Credentials

Username: admin
Password: owntoneadmin8765

Automation

I also created a blueprint that can automatically start and stop music in different rooms. You just need to provide an occupancy or motion sensor.
Import the blueprint: Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Troubleshooting

I cannot see the Home Assistant speaker through Spotify Connect.

Currently, I am not certain why this is the case. I guess something does not work with the discovery in every setup correctly. But as an alternative, you can provide your Spotify credentials directly to librespot-java.

For that, please edit the librespot-java.toml and set the strategy to USER_PASS additionally, please input your username/email address and password. (Afterwards, please restart the addon) Example:

[auth]
	# Credentials file (JSON)
	credentialsFile = "/config/owntone/credentials.json"
	# Spotify password (USER_PASS only)
	password = "SPOTIFY_PASSWORD_HERE"
	# Spotify authentication blob Base64-encoded (BLOB only)
	blob = ""
	# Whether to store reusable credentials on disk (not a plain password)
	storeCredentials = true
	# Strategy (USER_PASS, ZEROCONF, BLOB, FACEBOOK, STORED)
	strategy = "USER_PASS"
	# Spotify username (BLOB, USER_PASS only)
	username = "SPOTIFY_USERNAME_OR_EMAIL_HERE"

References

4 Likes

Very nice, looking forward to using this addon to move away from my Portainer + linuxserver owntone docker container (about which HA OS is complaining my setup is unsupported).

I tried a-marcels addon earlier but he doesn’t maintain it.

I installed your addon and it runs, but during startup it logs
“Skipping library directory /media/Muziek, could not dereference: No such file or directory”

(since I added that as the music source dir in the owntone.conf file).
What do you suggest I could do?
That directory is owned by root but with 777 rights.
I noticed your owntone.conf also contains uid = “abc”, is that correct?

Hey @GoSpursGoNL,

this addon does not mount the media directory of HA OS. I guess that is the reason the directory is not found.

@GoSpursGoNL

I just updated the addon to mount the /media directory inside the addon. Hope this solves your issue.

It works, many thanks!!! Very happy with this addon.

1 Like

Hi,

Firstly apologies as I have just joined the community and setting it up for the first time.
Just so I don’t start on the wrong path, I am after the option to start a playlist on my dashboard on Spotify and select that to be played on one or multiple homepods/mini’s.

Would this project or for me?

Thanks in advance

I get “This add-on is not compatible with the processor of your device or the operating system you have installed on your device.”

Most likely as I’m using a 32bit Pi 3. Any chance of a compatible version?

Best would be to install the 64-bit OS image of Home Assistant OS.

I guess.

I use it to start music from Spotify directly. It is not possible to select the playlist through home assistant directly. For that, I can recommend the normal Spotify integration. And then you can select the speaker through Spotify Connect. And in home assistant itself, it is possible to select the HomePod’s on which you want to listen to the music.

Hey I just wanted to say that this addon is really awesome. It just works as described.

But I would like to suggest a small change.
Could you add support for home assistants ingress feature? Introducing Hass.io Ingress - Home Assistant

Currently if you click “Open Web UI” it opens a separate tab and does not really work when using home assistant with a reverse proxy.

With ingress OwnTones web interface would open within the Home Assistant tab and credentials can be automatically fed with it.

Hey @alexbabel, this sounds like such a cool add-on! Unfortunately when adding the Integration using the OwnTone credentials you stated, I get the following error message: “Unable to connect. Please check host and port.” while using the port 3689. Any help is much appreciated :slight_smile:

Hey @HenryKleinschmidt,

unfortunately, I cannot add that feature. OwnTone uses more than one port to realize the web interface. The second port is used for a web socket connection. This type of setup is not supported through the ingress feature of Home Assistant.

I also would love to use OwnTone that way. But their web interface needs to be adjusted. (Web socket and Web interface must be accessible through the same port).

1 Like

Hey @badabingbadabong,

this sound like the same issue as @HenryKleinschmidt described (usage of a reverse proxy). Please try to access OwnTone through the IP address of your Home Assistant device. e.g. 192.168.1.23:3689.

Is anyone else experiencing the Owntone cache folder endlessly growing? It gets to the point where it fills up the disk, forcing me to delete it. I’m not sure how to stop that from happening since I don’t see any documentation on this cache.

@maiorania

I would recommend disabling the cache entirely. (adjustable inside the librespot-java.toml)

[cache]
	dir = "/config/owntone/cache/"
	# Cache enabled
	enabled = false
	doCleanUp = true

Ah, thank you! I didn’t even think of looking in that config file.

I think there’s an issue with your container. I am unable to configure the owntone.conf file because every time the container is restarted, the conf file is set back to defaults.

Hello! Great work, thank you so much!
I had issues with discovery too, USER_PASS strategy worked and then it hit me…

I needed to edit: /config/owntone/librespot-java.toml

[zeroconf]
        listenAll = true

It was set to false initially. Now it is discoverable!

That was a bug in the addon that is now fixed: Addon with owntone 28.6 constantly changes owntone.conf · Issue #5 · AlexanderBabel/hassio-addons · GitHub

1 Like

Great addon! Works greatly on my raspberry pi 4 and Home assistant. One question. I would like to generate multiple Spotify connect options, containing more or less speakers in my home. Like home assistant 1 would contain the speakers in the kitchen and living room, home assistant 2 would have others or additional.

Or: is there a similar addon that exposes an HomePod as Sonos service?