Listen to your favourite radios

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.
Post Reply
oliviers
Posts: 78
Joined: Wednesday 16 September 2015 22:10
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Paris area, France
Contact:

Listen to your favourite radios

Post by oliviers » Sunday 21 February 2016 16:50

Hi,
I would like to share with the community what I did to listen to my favourite radios via Domoticz...
Today, most radio stations can be "received" from the Internet via a live audio stream.
Here's what I did to receive these streams in my Domoticz ecosystem (Raspberry Pi 2B) :

1. Install MPLAYER : In a console window, enter:

Code: Select all

sudo apt-get update
sudo  apt-get install mplayer
2. Plug amplified speakers in the audio plug of the Raspberry. Connect the power cord to a 433Mhz or Zwave outlet, and create a physical switch in Domoticz to turn the speakers On and Off. It doesn't even need to be visible in the switch panel, but it's up to you.
Capture6.PNG
Capture6.PNG (2.29 KiB) Viewed 2564 times
3. For each radio that you want to listen, create a shell script such as next one, and save it in /home/pi/domoticz/scripts

Code: Select all

#!/bin/bash
# echo RTL2
wget "http://127.0.0.1:8080/json.htm?type=command&param=switchlight&idx=161&switchcmd=On" > /dev/null
sudo killall mplayer
mplayer -noconsolecontrols http://streaming.radio.rtl2.fr:80/rtl2-1-44-96 &
First line will turn the speakers on (put in the right idx, the one of your speakers).
Second line will stop any running instance of mplayer. This is necessary to zap between stations.
Third line will activate the audio stream. Make sure you don't forget the & to launch the player in background. For each radio, edit the script and put the right URL. (Here's a list of URLs for French radios: https://doc.ubuntu-fr.org/liste_radio_france )

4. Create a script to stop listening:

Code: Select all

#!/bin/bash
wget "http://127.0.0.1:8080/json.htm?type=command&param=switchlight&idx=161&switchcmd=Off" > /dev/null &
sudo killall mplayer > /dev/null &
5. Create a virtual selector switch in Domoticz, and create as many levels as you have radios you want to listen.
Assign the scripts created at step 3 to each level, and the "stop" script (step 4) to the "Off" level
Capture4.PNG
Capture4.PNG (139.08 KiB) Viewed 2564 times

6
. Here you go ...
Capture5.PNG
Capture5.PNG (30.04 KiB) Viewed 2564 times
Enjoy!
Oliviers
Last edited by oliviers on Sunday 21 February 2016 20:09, edited 3 times in total.
Paris area
Raspberry Pi 2B - RFXComm 433 - IrTrans - Zwave

User avatar
nayr
Posts: 430
Joined: Tuesday 11 November 2014 19:42
Target OS: Linux
Domoticz version: github
Location: Denver, CO - USA
Contact:

Re: Listen to your favourite radios

Post by nayr » Sunday 21 February 2016 16:56

very cool, arent the selector switches awesome?

have you looked into MusicPlayerDaemon aka MPD? it was designed for this. https://www.domoticz.com/wiki/MPD_%26_Domoticz

I did something similar with a real radio:
Image
Debian Jessie: CuBox-i4 (Primary) w/Static Routed IP and x509 / BeagleBone with OpenSprinkler / BeagleBone Planted Aquarium / 3x Raspbery Pi2b GPIO Slaves
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth

oliviers
Posts: 78
Joined: Wednesday 16 September 2015 22:10
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Paris area, France
Contact:

Re: Listen to your favourite radios

Post by oliviers » Sunday 21 February 2016 17:11

Hello Nayr,
Thanks for pointing me at MPD.
Yes, selector switches are terrific.... In a previous version, I had one switch per radio station... Now I have a more compact swith panel.
Oliviers
Paris area
Raspberry Pi 2B - RFXComm 433 - IrTrans - Zwave

HoLeeShiet
Posts: 64
Joined: Tuesday 18 March 2014 22:19
Target OS: -
Domoticz version:
Contact:

Re: Listen to your favourite radios

Post by HoLeeShiet » Wednesday 24 February 2016 3:02

Great tutorial! Would it be possible to do this with a Chromecast Audio? Since I have my RPI hidden in the closet
Using Tapatalk

User avatar
nayr
Posts: 430
Joined: Tuesday 11 November 2014 19:42
Target OS: Linux
Domoticz version: github
Location: Denver, CO - USA
Contact:

Re: Listen to your favourite radios

Post by nayr » Wednesday 24 February 2016 4:13

no his solution requires local audio output.
Debian Jessie: CuBox-i4 (Primary) w/Static Routed IP and x509 / BeagleBone with OpenSprinkler / BeagleBone Planted Aquarium / 3x Raspbery Pi2b GPIO Slaves
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth

deennoo
Posts: 914
Joined: Wednesday 10 December 2014 14:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Listen to your favourite radios

Post by deennoo » Wednesday 24 February 2016 10:10

Same thing can be done to drive lms server on various player.

Thanks for the idea ! And thanx for selector !
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / ESP8266 / MQTT / BLE
http://domo-attitude.fr

deennoo
Posts: 914
Joined: Wednesday 10 December 2014 14:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: RE: Re: Listen to your favourite radios

Post by deennoo » Wednesday 24 February 2016 10:12

HoLeeShiet wrote:Great tutorial! Would it be possible to do this with a Chromecast Audio? Since I have my RPI hidden in the closet
Just set up an lms server, add you tunein radio account, and set up chromecast bridge lms plugin.

Then create a same kind of script but with lms API, and rock n roll
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / ESP8266 / MQTT / BLE
http://domo-attitude.fr

fergalom
Posts: 73
Joined: Thursday 24 September 2015 11:44
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Listen to your favourite radios

Post by fergalom » Wednesday 24 February 2016 12:32

I have something similar in place using forked-daapd and mpc on the RPi - can play to my airplay speakers :-)
Radio and tunes.

Good idea on the selector switch for radio stations!

llheim
Posts: 8
Joined: Sunday 12 March 2017 16:48
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Listen to your favourite radios

Post by llheim » Sunday 05 November 2017 17:50

Thank you for sharing this. Only thing I changed (maybe of interest for people with a rpi3 and a bluetooth speaker) is to add some lines to your script to switch users. Domoticz runs as root on rpi3 and so do scripts called by it. By switching to a normal user mplayer can play my favorite morning radio show. :)

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests