New node available: Control Mopidy (mp3/spotify/streams/etc) from Node-RED

1,371 views
Skip to first unread message

Emil Oberg

unread,
Nov 12, 2015, 9:33:01 AM11/12/15
to Node-RED
Hi!

Just wanted to say that I just released node-red-contrib-mopidy. It's a node which gives you full capabilities to control a Mopidy server.

Mopidy is a music player server (easily installable, I've a Mopidy Server running on a Raspberry Pi in each room). With this module you can do stuff like "Play Spotify Playlist 'Lounge' in the Bedroom", "Set volume to 50%" or "Play this online stream".

Me, I've combined it with the tellstick node. Every morning I wake up to a slowly increasing light and a Spotify playlist where the volume increases over 20 minutes.

Feedback is - as usual - very welcome!

Emil

Julian Knight

unread,
Nov 12, 2015, 11:43:28 AM11/12/15
to Node-RED
Hi Emil, I like it! I've been meaning to make my own Internet connected alarm clock for a while & I already have a daylight alarm which I love so I was planning to include a bright LED on the alarm.

Which Pi version are you using? I have a Pi 1 model b spare so I could repurpose that. It would be great to see an instructable :)

Endre Szabo

unread,
Nov 12, 2015, 11:49:18 AM11/12/15
to node...@googlegroups.com
Owwwwwww, I've been working on the very same yesterday :)
> --
> http://nodered.org
> ---
> You received this message because you are subscribed to the Google Groups
> "Node-RED" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to node-red+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
end.re

PGP: http://end.re/endre.gpg
PGP FP: 090B 77BC 2055 8306 5B3A C635 00DB 7F46 4AAB 7A78

Walter Kraembring

unread,
Nov 12, 2015, 11:53:36 AM11/12/15
to Node-RED
Emil, very nice!
I am already since long running Mopidy in a separate Pi 1 model B and it is working fine.
Most tricky was to tell Mopidy to use the HDMI port but it is working also now
Best regards, Walter

Giovanni Angoli

unread,
Nov 12, 2015, 12:17:39 PM11/12/15
to node...@googlegroups.com
I've played a bit with the new version of this node (I had the old 0.0.9 installed).
my setup is this:
- node-red on host A
- mopidy on host B (with mpd and httpd extension configured)

I normally control modipy via MPD commands, the only disadvantage is that node-red-contrib-mpd doesn't handle reconnection to MPD once it gets disconnected. 

Anyway, playing with the new node, so far I managed to get the mopidy-in node to work but mopidy-out have some problems.

host A is 10.0.1.10 and when I try to configure the mopidy-out node (using the same config as the mopidy-in already deployed and connected) I just get a div (


in the developer console this is what I can see that the request are 404ing to:


that in my case is:



because I have this in settings.js: httpAdminRoot: '/admin',

I think the mopidy-out should use httpNodeRoot instead (that should default to / if it's not set) 


Apart from this, the node is very promising, I may migrate all my logic to this node and ditch the old plain mpd node ;)

Thanks Emil for your work!

Giovanni



--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Giovanni Angoli

Nicholas O'Leary

unread,
Nov 12, 2015, 12:21:11 PM11/12/15
to node...@googlegroups.com

On a broken down train, so can't reply fully, but any endpoints that are for the editors use should be on httpAdmin. The fix will be whether the node puts a slash at the start of the URL when it makes the request - it shouldnt, so the request is relative to wherever the editor is mounted.

Nick

Emil Oberg

unread,
Nov 12, 2015, 12:22:15 PM11/12/15
to Node-RED
@Julian

I've a mix of Model B+ 1 and Model B 2+, they both work equally well (but the version 2 is heck of a lot faster)

As for an instruction, the good folks at Mopidy has made an excellent one: https://docs.mopidy.com/en/latest/installation/raspberrypi/

I've done two things which isn't in the tutorial:
First, I've an external audio card (as the built in one gives hissing sounds). Installing that is described here: http://computers.tutsplus.com/articles/using-a-usb-audio-device-with-a-raspberry-pi--mac-55876 I've a bunch of these USB Audio Cards which cost $10 USD at my local computer store or $1 USD a pop when bought from China: http://www.dx.com/p/usb-virtual-7-1-channel-external-sound-adapter-card-w-2-3-5mm-audio-black-5-pcs-399440#.VkTI_q4veLI

Second, I've installed the ALSAMixer ( https://github.com/mopidy/mopidy-alsamixer ) plugin. This Mopidy use the hardware mixer. This way if I set the audio level to 50% from Mopidy (or Node-RED) is stays at 50% even if stop playing music form Mopidy and start playing music stream from my iPhone. All my Speaker-Raspberries have the same config. They've a USB out card and they're running a Mopidy Server and a Shairport ( https://github.com/mikebrady/shairport-sync ) server each. Shairport makes it possible to AirPlay from an Apple Device to a Raspberry.

@Endre

Stop working! Or let's work together, or tell me, if there's something my module is missing ;)

@Walter

Sweet! I though HDMI out was the default setting?

E

Giovanni Angoli

unread,
Nov 12, 2015, 12:27:37 PM11/12/15
to node...@googlegroups.com
Thanks Nick for clarifying the issue and the fix.


Giovanni

Emil Oberg

unread,
Nov 12, 2015, 12:30:08 PM11/12/15
to Node-RED
I'm not sure if I'm following you completely. Currently I've it on the httpAdmin like this

RED.httpAdmin.get('/mopidy/:nodeId/methods', (req, res) => { /* ... */ });

That should be correct, right?

E

Emil Oberg

unread,
Nov 12, 2015, 12:32:41 PM11/12/15
to Node-RED
Fault on my part!

I'll take a look at it and get back with a fix!

E

Nicholas O'Leary

unread,
Nov 12, 2015, 12:37:37 PM11/12/15
to Node-RED

That bit is fine... It'll be how to specify the url where you send the request to that endpoint in your HTML file.


--

Emil Oberg

unread,
Nov 12, 2015, 1:12:27 PM11/12/15
to Node-RED
@Giovanni 

Just pushed version 2.0.1 to NPM. Re-install it and it should all work! 

Please let me know how it goes.

E

Giovanni Angoli

unread,
Nov 12, 2015, 2:21:34 PM11/12/15
to node...@googlegroups.com

It's working as intended now, thanks!

G.

Julian Knight

unread,
Nov 12, 2015, 5:12:26 PM11/12/15
to Node-RED
Cool, thanks for the Info Emil, I'll have a go whenever I get time next!!

Giovanni Angoli

unread,
Nov 13, 2015, 2:51:54 AM11/13/15
to node...@googlegroups.com
Played a bit more, this node is really nice!

Emil, I can't wrap my head around on how to obtain a mopidy-out node that does "Run Spotify Playlist XXY" in a single instance like il the github docs:

Inline image 1

What I'm currently doing is this: 

Inline image 2

Which is what you are doing in the docs to play a single stream.

Am i being thick? Could you please enlighten me? 

Thanks!

Giovanni.


--
Giovanni Angoli

Emil Oberg

unread,
Nov 13, 2015, 3:16:24 AM11/13/15
to Node-RED
You're doing it right by clearing/setting playlist/playing. The image top is deceitful. I'll change it!

E

Mark Setrem

unread,
Nov 15, 2015, 8:18:24 AM11/15/15
to Node-RED
Thanks for the writing the node.

I'm getting a few niggles with it:
such as the node stating "not connected" when it is
and duplicate messages when the playing track changes (e.g. for event": "event:trackPlaybackStarted" )

I'm connecting to a PiMusicbox installation, I have the mopedy-In set to "Listen to: Mopidy"

All on a brand new install of NodeRed on a Pi2
15 Nov 12:52:53 - [info] Node-RED version: v0.12.1
15 Nov 12:52:53 - [info] Node.js version: v0.10.29

any ideas?

Mark Setrem

unread,
Nov 15, 2015, 8:46:51 AM11/15/15
to Node-RED
I've worked out whats causing them.

It doesn't appear to be closing down running processes correct when redeploying.

In "modipy-in node" the server is set to "Test (192.168.0.111)" but when Modipy triggers an event I'm getting responses back which contain:
the "serverName": "a", "host": "192.168.0.111",
as well as "serverName": "Test", "host": "192.168.0.111",

The config "serverName": "a" had already been deleted so there is only one configuration displayed in the modipy-in node config screen.

If I then stop and restart the Node-red instance the I only then get 1 copy of each message which has the correct server name.

Emil Oberg

unread,
Nov 17, 2015, 10:33:33 AM11/17/15
to Node-RED
Let's continue this question on Github!

E
Reply all
Reply to author
Forward
0 new messages