Music in the bathroom

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

matthijs
Posts: 17
Joined: Friday 29 May 2015 12:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Music in the bathroom

Post by matthijs »

I always wanted music in the bathroom when I'm showering. The normal solution of a lowered ceiling with speakers wasn't an option for me because I rent the apartment I live in. The next option was a Sonos but that's a bit expensive for just in the bathroom. So i thought why can't I connect a bluetooth speaker to domoticz and when I touch a switch the music from a spotify playlist is playing?

I ordered a bluetooth speaker and tried to get it working with my domoticz raspberry pi. That was a fail but then I used another empty Raspberry Pi and after 15 minutes I had a working bluetooth speaker with PimusicBox (a program that uses Mopidy, MPD and MPC).

I think it can be done with only installing mopidy and maybe even on the same Raspberry Pi as Domoticz but I couldn't get it working correct and after a while mopidy crashed and I couldn't get it working again so thats why I used another Pi.

A How to:

Hardware list:
-Working Domoticz
-another Raspberry Pi (I used an old 256mb version, but every version works)
-Earson - ER151 (cheap bluetooth speaker with good sound and can stand high humidity levels)
-bluetooth dongle ( I bought this one http://eu.banggood.com/Wholesale-Wareho ... 55088.html)


How to install:

Download PiMusicbox from http://www.pimusicbox.com and flash it to the SD card

Open the sd card on the computer and open settings.ini
You can add your wifi credentials here and also your spotify login. Don't forget to enable ssh login here.

Log in with root to Musicbox and do this:

Code: Select all

$ sudo apt-get install bluetooth bluez bluez-utils bluez-alsa
$ hcitool scan ## switch your bluetooth dongle to scan ##
$ bluetooth-agent --adapter hci0 0000 11:22:33:44:55:66 ## <--device you find with the scan and will connect ##
$ bluez-test-device trusted 11:22:33:44:55:66 yes
$ bluez-test-device trusted 11:22:33:44:55:66 ## If trusted, this will confirmed with a 1 ##
$ sudo /etc/init.d/bluetooth restart
Then open settings.ini again:

Code: Select all

sudo nano /boot/config/settings.ini
and change:

Code: Select all

output = alsasink into output = alsasink device=bluetooth
Put the lines (only) into the file asound.conf (/etc);

Code: Select all

sudo nano /etc/asound.conf

Code: Select all

pcm.bluetooth {
type bluetooth
device 11:22:33:44:55:66 ##your device##
profile "auto"
}

Remove the file setsound.sh (/opt/musicbox)

Code: Select all

sudo rm /opt/musicbox/setsound.sh
Put some lines into the file audio.conf (/etc/bluetooth);

Code: Select all

sudo nano /etc/bluetooth/audio.conf

Code: Select all

[General]
Enable=Source,Sink,Socket

Disable=Media
Reboot your Pi and the music must play to your bluetooth speaker.

Then the Raspberry Pi must be connected to Domoticz.
I installed mpc from the wiki: https://www.domoticz.com/wiki/MPD_%26_D ... stallation
then i wrote a simple bash script to load a spotify playlist and play it.

Change it to the Ip address of your Raspberry Pi with Musicbox Image and to the port (default 6600) with lsplaylists you load the known spotify playlists and then you can load it into music box. With random on I shuffle the list and I change the volume to 20 (loud enough). Then I play and again put the volume at 20%, because sometimes the first one would not work.

music.sh

Code: Select all

#!/bin/sh
mpc -h YOUR_IP -p 6600
mpc -h YOUR_IP -p 6600 lsplaylists
mpc -h YOUR_IP -p 6600 load YOUR PLAYLIST
mpc -h YOUR_IP -p 6600 random on
mpc -h YOUR_IP -p 6600 volume 20
mpc -h YOUR_IP -p 6600 play
mpc -h YOUR_IP -p 6600 volume 20
To stop the playlist from playing I made another simple script:

musicstop.sh

Code: Select all

#!/bin/sh
mpc -h YOUR_IP -p 6600 
mpc -h YOUR_IP -p 6600 stop
mpc -h YOUR_IP -p 6600 clear


Copy the scripts to the scripts folder from Domoticz and make both scripts executable.

I connected a 433mhz remote controller from kaku to domoticz and put the scripts into the on and off action. I've made two buttons, one for my girlfriend and one for me so we both can listen to our own playlist.

I think the scripts can be much better but it works for now.
roblom
Posts: 402
Joined: Wednesday 26 February 2014 15:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: the Netherlands
Contact:

Re: Music in the bathroom

Post by roblom »

You can also install Kodi on the raspberry pi, then you can stream music to it from any network connected device. I use Yatse on my mobile phone to play music from my NAS.
There are also already some connections available between Kodi and Domoticz
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Music in the bathroom

Post by Derik »

Love you if you where a girll..
Thanks..
Make my family happy with this...


xx

mmm edit...
i thought it was in domticz-with the same rpi...
buy a other pi... for this.
or can they work together, Domoticz and this pimusicbox, or a alternative?
Last edited by Derik on Thursday 30 July 2015 7:52, edited 1 time in total.
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Music in the bathroom

Post by pvm »

It should be possible to run a Bluetooth speaker from the same pi. I'm working in this too, got the audio connection running play mp3 file. Google translate audio not yet (My goal). Somehow it requests captcha authentication, but that's off topic. I've written down steps taken, but do not know if things keep working when speaker is disconnected and stuff like that. Too early to share. What helped me was http://www.correderajorge.es/bluetooth- ... streaming/ (without the sudo on the .asound file)
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
matthijs
Posts: 17
Joined: Friday 29 May 2015 12:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Music in the bathroom

Post by matthijs »

It's possible to run a bluetooth speaker from the same Pi. I had this working, but I couldn't get it working with spotify and I messed up the audio configuration. I tried several how to's to connect my bluetooth speaker to Kodi but none of them would work. It was indeed my first try because the simple integration with domoticz. I found PiMusicbox which uses Mopidy as core (That's the application you have to install when you want spotify running on the same Pi as Domoticz) and for playing streaming music it's a very nice program.
I have to clean my Raspberry pi with domoticz running first to try again, so before you try make a current backup of the image.
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Music in the bathroom

Post by Derik »

Perhaps this version is "alfa" :-)
And when the Stable version there is, every streamingservice will work :-)

I have to wait for my pi..


And i'm happy with this as alternative for the sonos...
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
Heisenberg
Posts: 135
Joined: Monday 27 January 2014 14:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Music in the bathroom

Post by Heisenberg »

Interesting!
Is it possible to pair with multiple bluetooth speakers too? i.e. bathroom, toilet, study room to play same music stream at the same time?
Raspberry Pi Type B
Raspberry Pi Type B2
RFXCOMtrx433e
Heisenberg
Posts: 135
Joined: Monday 27 January 2014 14:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Music in the bathroom

Post by Heisenberg »

pvm wrote:It should be possible to run a Bluetooth speaker from the same pi. I'm working in this too, got the audio connection running play mp3 file. Google translate audio not yet (My goal). Somehow it requests captcha authentication, but that's off topic. I've written down steps taken, but do not know if things keep working when speaker is disconnected and stuff like that. Too early to share. What helped me was http://www.correderajorge.es/bluetooth- ... streaming/ (without the sudo on the .asound file)

The URL is not active anymore?
Raspberry Pi Type B
Raspberry Pi Type B2
RFXCOMtrx433e
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Music in the bathroom

Post by pvm »

I've made some quick notes during my test last week. I will install it on my 'production' Domoticz install coming week and write wiki page for it. I don't have the possibility to test with multiple speakers
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
Heisenberg
Posts: 135
Joined: Monday 27 January 2014 14:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Music in the bathroom

Post by Heisenberg »

Great! Can't wait to read your wiki page. I hope streaming with multiple speakers can be achieved soon. Then it will be a cheap alternative for SONOS
Raspberry Pi Type B
Raspberry Pi Type B2
RFXCOMtrx433e
User avatar
capman
Posts: 153
Joined: Friday 12 July 2013 20:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Belgium
Contact:

Re: Music in the bathroom

Post by capman »

I have a PI in my bathroom with musicbox installed on it. http://www.pimusicbox.com/
It's also connected with a sound board from hifiberry , the amp+. So my
speakers are direct connected to my pi , with great sound output.
https://www.hifiberry.com/ampplus/
Now a would also control al of this with my domoticz. But this is installed on my synology DS414 (more stable then on my first pi).
Is it possible with my configuration to control all of this ? Control happens now with MPD install on my phone and tablet.
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Music in the bathroom

Post by Derik »

mmm
Can not wait until i get my Pi from China..
And try your great work..
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
matthijs
Posts: 17
Joined: Friday 29 May 2015 12:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Music in the bathroom

Post by matthijs »

capman wrote:I have a PI in my bathroom with musicbox installed on it. http://www.pimusicbox.com/
It's also connected with a sound board from hifiberry , the amp+. So my
speakers are direct connected to my pi , with great sound output.
https://www.hifiberry.com/ampplus/
Now a would also control al of this with my domoticz. But this is installed on my synology DS414 (more stable then on my first pi).
Is it possible with my configuration to control all of this ? Control happens now with MPD install on my phone and tablet.
The easiest way to remote control PiMusicbox is mpc. This is what I use in my bash scripts to remotely control the Pi with musicbox. There is only one problem. For what I know you have to bootstrap your NAS to install mpc but maybe I'm wrong.
pvm wrote:I've made some quick notes during my test last week. I will install it on my 'production' Domoticz install coming week and write wiki page for it. I don't have the possibility to test with multiple speakers
I'm interested to see how you got it working.
Heisenberg wrote:Interesting!
Is it possible to pair with multiple bluetooth speakers too? i.e. bathroom, toilet, study room to play same music stream at the same time?
I can't test it because I have only one bluetooth speaker, but I'm afraid it won't work, at least not 'out of the box'. There is not enough bandwidth available in the bluetooth specification to connect two speakers at the same time. That's why it is only possible to connect to one device at the time (at least for most bluetooth devices). There are solutions for this, but then you won't use bluetooth. For example: http://www.amazon.co.uk/dp/B0049CUO56/r ... _M3T1_dp_1 and http://www.amazon.co.uk/Creative-D220W- ... ransmitter as speaker. But I don't know if that can be controlled with a script to implement it into domoticz.
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Music in the bathroom

Post by pvm »

Heisenberg wrote:Great! Can't wait to read your wiki page. I hope streaming with multiple speakers can be achieved soon. Then it will be a cheap alternative for SONOS
I created a wiki page: http://domoticz.com/wiki/BTAudio
(i do not want to steal this topic, please use http://www.domoticz.com/forum/viewtopic.php?f=28&t=7563 for further discussion on this description )
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
thebeetleuk
Posts: 115
Joined: Saturday 21 December 2013 23:50
Target OS: Linux
Domoticz version:
Location: Scotland
Contact:

Re: Music in the bathroom

Post by thebeetleuk »

How did you get on with this? All working?
My Setup: Pi, RFXtrx433, HomeEasy: 13 Dimmers & 4 Sockets, 2 motion-sensors, 3 magnetic switches, 1 OWL Electricity Sensor, 3 Oregon Temp Sensor.
jarvis
Posts: 3
Joined: Tuesday 22 December 2015 17:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Music in the bathroom

Post by jarvis »

What's going on about your solution?

An other point: Did somebody find a waterproof switch with a dimmer ? :idea:
matthijs
Posts: 17
Joined: Friday 29 May 2015 12:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Music in the bathroom

Post by matthijs »

It's still working every day. I haven't changed a thing since I installed it, except for one reinstall because of a corrupt sd card (power failure). I thought I wanted more (multi room audio etc.) but that's not the case. The only thing that I maybe want to implement in the future is a morning function. So when I push the play button for the music I get the weather forecast and traffic information for that day before it plays my spotify playlist, but I time is limited and I'm not the best programmer.
BarryT
Posts: 358
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Music in the bathroom

Post by BarryT »

I think this can be really easy done by making a "Shoutcast" client on the pi.
Just give in a url (playlist/stream/etc) and there you go.
It is also possible to recieve title names, play stop etc on remote, and so on.

I had made this a while ago in a private sauna, at a friend.
When the pi gets powered, the shoutcast was picked up a (local private) stream from the synology nas and get played trough the speakers (line out on the pi).
I used a switch (with rfxcom) to power on and off the musicpi, and from remote site it was possible to turn it on or off / bundled with the lights of the room in domoticz.
It isnt possible to do something with volume, or choose another stream but that was no problem since they only want to hear "relaxing" music (that was downloaded on the nas), and for volume they had a exernal volumeknob on the amplifier.
I also did my sd-card locked, because of its on / off state (sd-cards doesnt like that the pi suddenly poweroff)
Also spotify and another service isnt possible with shoutcast/icecast, but maybe this is at least something to think about!

*1 Another option is to use a wifi radio (with a private "shoutcast" stream, or else) and power it on and off with a switch.
*1 The expensive ones does have support for spotify, etc.

*2 Again another option is really simple, if you are a little bit handy, you can make a RPI fm transmitter (check google how to do) so you have multiroom audio, for free ;-)

Grtz
Last edited by BarryT on Saturday 16 January 2016 22:30, edited 1 time in total.
Raspberry / ESP Boards / Relais / Milight / Hue / OTGW / P1 / Xiaomi / RFXCom / RFLink / ZWave / Conbee II / Z2M / MQTT / A lot of scripts and many more..
Software: Linux, Android and Windows
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Music in the bathroom

Post by Derik »

BarryT wrote:I think this can be really easy done by making a "Shoutcast" client on the pi.
Just give in a url (playlist/stream/etc) and there you go.
It is also possible to recieve title names, play stop etc on remote, and so on.

I had made this a while ago in a private sauna, at a friend.
When the pi gets powered, the shoutcast was picked up a (local private) stream from the synology nas and get played trough the speakers (line out on the pi).
I used a switch (with rfxcom) to power on and off the musicpi, and from remote site it was possible to turn it on or off / bundled with the lights of the room in domoticz.
It isnt possible to do something with volume, or choose another stream but that was no problem since they only want to hear "relaxing" music (that was downloaded on the nas), and for volume they had a exernal volumeknob on the amplifier.
I also did my sd-card locked, because of its on / off state (sd-cards doesnt like that the pi suddenly poweroff)
Also spotify and another service isnt possible with shoutcast/icecast, but maybe this is at least something to think about!

*1 Another option is to use a wifi radio (with a private "shoutcast" stream, or else) and power it on and off with a switch.
*1 The expensive ones does have support for spotify, etc.

*2 Again another option is really simple, if you are a little bit handy, you can make a fm transmitter so you have multiroom audio, for free ;-)

Grtz

What speakers do you use???
With Bluetooth or WiFi?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Music in the bathroom

Post by Derik »

BarryT wrote:I think this can be really easy done by making a "Shoutcast" client on the pi.
Just give in a url (playlist/stream/etc) and there you go.
It is also possible to recieve title names, play stop etc on remote, and so on.

I had made this a while ago in a private sauna, at a friend.
When the pi gets powered, the shoutcast was picked up a (local private) stream from the synology nas and get played trough the speakers (line out on the pi).
I used a switch (with rfxcom) to power on and off the musicpi, and from remote site it was possible to turn it on or off / bundled with the lights of the room in domoticz.
It isnt possible to do something with volume, or choose another stream but that was no problem since they only want to hear "relaxing" music (that was downloaded on the nas), and for volume they had a exernal volumeknob on the amplifier.
I also did my sd-card locked, because of its on / off state (sd-cards doesnt like that the pi suddenly poweroff)
Also spotify and another service isnt possible with shoutcast/icecast, but maybe this is at least something to think about!

*1 Another option is to use a wifi radio (with a private "shoutcast" stream, or else) and power it on and off with a switch.
*1 The expensive ones does have support for spotify, etc.

*2 Again another option is really simple, if you are a little bit handy, you can make a fm transmitter so you have multiroom audio, for free ;-)

Grtz

What speakers do you use???
With Bluetooth or WiFi?

And how do you set this in Domoticz?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest