Is running HA on Docker such a bad idea? (Raspberry, Spotify, Bluetooth, Media Player)

Well, I installed home assistant with docker via the lscr.io/linuxserver/homeassistant image on my Raspberry Pi 5. Now my goal is an automation, that I wake up to a Spotify playlist playing on my Bluetooth speaker. I am looking for a simple as possible solution!

Bluetooth Speaker: In order to see the devices via the Bluetooth integration, I had to map the D-Bus socket (/run/dbus) and the Bluetooth adapter (/dev/hci0) into the Docker container. Done.

Spotify integration: Added the integration via HA „Settings > add Integration“ using the redirect URI Link to OAuth2 Authorize Callback – My Home Assistant. Worked.

ISSUE: Other than in many tutorials, I do not have a play button, when clicking on the Spotify integration. When trying to setup my automation, I selected Spotify as media player. I could select playlist, however, not any devices. I cannot even play an audio file and I feel that should be super easy.

My guess is that I need some kind of a media player, because I run Home Assistant in a Docker container (which is necessary in my case) and therefore it can not automatically use the Raspberry - if that makes sense …

ChatGPT recommended adding PulseAudio, which I did. It ran successfully in my container. However, home assistant could not configure the media player with platform „pulseaudio“. I tried Media Player Deamon as well, added it in the „configuration.yaml“, but it was unavailable in HA.

That was my last docker-compose.yml:

version: '2'
 
services:
  homeassistant:
    image: lscr.io/linuxserver/homeassistant:latest
    container_name: homeassistant
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Vienna
    volumes:
      - /root/homeassistant/config:/config
      - /run/dbus:/run/dbus  # Expose D-Bus socket
    ports:
      - 8123:8123 #optional
    restart: unless-stopped
    devices:
      - /dev/hci0:/dev/hci0  # Bluetooth device
    privileged: true  # This is necessary to allow access to the Bluetooth device
 
  mpd:
    #image: tobi312/rpi-mpd:debian
    image: tobi312/rpi-mpd:alpine
    container_name: mpd
    restart: unless-stopped
    ports:
      - 6600:6600  # MPD Client
      - 8000:8000  # Stream
    volumes:
      - ./mpd/Music:/var/lib/mpd/music:rw
      - ./mpd/playlists:/var/lib/mpd/playlists:rw
      - ./mpd/data:/var/lib/mpd/data:rw
      #- ./mpd/mpd.conf:/etc/mpd.conf:rw

You might be confused regarding the capabilities of the spotify integration.
It doesn’t allow you to play spotify on your HA server. It allows you to control the playback of spotify on, e.g, your browser, phone, …

1 Like

I would like to achieve something like this OffSetLab | Home Assistant Spotify Radio Alarm. But I somehow need a media player I guess. What’s a best practice therefore?

This might be able to connect to your Bluetooth speaker. It also has a MPD plugin so you can setup HA to send audio other than Spotify to the speaker as well.