Controlling Spotifyd via Dbus / Mpris?

Well, I've been making some progress on this. The first element was discovering that spotifyd supports this as an option:

—-onevent curl http://192.168.11.97:1880/Spotify

With some help from @Colin I can now trigger a Node-RED flow whenever there's a change in what spotifyd is playing or pausing.

I have also discovered Spotimaster but this seems a very heavy solution to what I'm after, and I wasn't sure I fully understood how to implement it. Looking through the dependencies highlighted dbus-send so I decided to investigate that a bit further.

dbus-send is a standard part of Ubuntu, so if I can figure out how to use it to address the spotifyd daemon, I should be able to make this work without installing anything else. I found an excellent guide which I'm slowly working through. I've already found the spotifyd device on the dbus:

ubuntu@ubuntu:~$ dbus-send --system --print-reply --dest=org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager.ListUnits

method return time=1662102778.773997 sender=:1.3 -> destination=:1.52 serial=2743738 reply_serial=2
...
array [
struct {
string "spotifyd.service"
string "Spotify Daemon"
string "loaded"
string "active"
string "running"
string ""
object path "/org/freedesktop/systemd1/unit/spotifyd_2eservice"
uint32 0
string ""
object path "/"
}
...

Now I just need to work what methods (?) are supported by the spotifyd unit, how to send them from and get the reply into Node-RED and I'll be almost there ...

1 Like