RASPBERRY PI ZERO AND THE MOPIDY AUDIO SERVER

I had a redundant Raspberry Pi Zero + Raspbian Lite on hand, so I decided to have a crack at setting it up as a Mopidy Audio Server. I documented what I discovered in this page (mostly for my own future benefit), but maybe it'll help someone else get started with this great tool...

Preamble

$> sudo raspi-config - Advanced - Memory Split - GPU to minimum (16). I'm running my Zero headless, so the GPU memory can be reclaimed.

$> sudo apt-get -y install python-pip (for Moped web client, see below). NB: not python3 / pip3, as the resulting install does not appear as a Mopidy 'head unit' for some reason.

Install

Installation instructions for Debian / Ubuntu (and thus Raspbian)

$> wget -q -O - https://apt.mopidy.com/mopidy.gpg | sudo apt-key add -

$> sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/stretch.list

$> sudo apt-get update

$> sudo apt-get install mopidy

Configure

As a system service (where 'XXXXXXXXXX' = your value here)

$> sudo mopidyctl config

[core]
cache_dir = /var/cache/mopidy
config_dir = /etc/mopidy
data_dir = /var/lib/mopidy

[logging]
config_file = /etc/mopidy/logging.conf
debug_file = /var/log/mopidy/mopidy-debug.log

[audio]
mixer_volume = 2

[local]
enabled = false

[file]
enabled = true
media_dirs =
XXXXXXXXXX
show_dotfiles = false
excluded_file_extensions =
.jpg
.jpeg
metadata_timeout = 1000

[m3u]
enabled = true
playlists_dir = XXXXXXXXXX

[http]
enabled = true
hostname = 0.0.0.0
port = 6680
static_dir =
zeroconf = Mopidy HTTP server on $hostname

[mpd]
enabled = false

[podcast]
enabled = true
browse_root = Podcasts.opml
browse_order = desc
lookup_order = asc
cache_size = 64
cache_ttl = 86400
timeout = 10

NB: I've set my initial 'mixer_volume' really low (2 / 100) to match my system - you might want to go higher.

NB: You may have your own opinion regarding the services I've disabled above ([local] and [mpd]) - in which case refer to the docs to configure them.

NB: I did nothing with either [stream] or [softwaremixer], as I wasn't sure what I wanted / needed - they are both enabled by default, and I left them as is, unconfigured.

$> sudo systemctl enable mopidy

Extend

Moped Browser Client

$> sudo pip install Mopidy-Moped

Mopidy is 'just' a server - you'll need an MPD (e.g. MPDroid) or browser client (e.g. Moped or Iris) to control it - I use the latter, and the former is disabled in my config, above.

Mopidy-Podcast

$> sudo apt-get install mopidy-podcast

As per 'mopidyctl config [podcast] browse_root', drop your list of podcasts here: /etc/mopidy/podcast/Podcasts.opml

Mopidy Alarm Clock

One of the joys of Mopidy is the RPC interface, called via curl. Here's a bash script that you can call via cron:

#!/bin/bash
curl -X POST -H Content-Type:application/json -d '{"method": "core.tracklist.clear", "jsonrpc": "2.0", "params": {}, "id": 1}' http://localhost:6680/mopidy/rpc
curl -X POST -H Content-Type:application/json -d '{"method": "core.tracklist.add", "jsonrpc": "2.0", "params": {"uri": "file:///XXXXXXXXXX/wake_tf_up_chris.ogg"}, "id": 1}' http://localhost:6680/mopidy/rpc
curl -X POST -H Content-Type:application/json -d '{"method": "core.playback.play", "jsonrpc": "2.0", "params": {}, "id": 1}' http://localhost:6680/mopidy/rpc

for ii in {1..11}
do
curl -X POST -H Content-Type:application/json -d '{"method": "core.mixer.set_volume", "jsonrpc": "2.0", "params": {"volume": '$ii'}, "id": 1}' http://localhost:6680/mopidy/rpc
sleep 10
done

NB: The above script walks the volume up from 1 to 11 on a 10-second beat - only Spinal Tap fans need to go to 11 - others can choose their own max volume...