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.

Moderator: leecollings

Post Reply
oliviers
Posts: 73
Joined: Wednesday 16 September 2015 22:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Paris area, France
Contact:

Listen to your favourite radios

Post by oliviers »

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 8008 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 8008 times

6
. Here you go ...
Capture5.PNG
Capture5.PNG (30.04 KiB) Viewed 8008 times
Enjoy!
Oliviers
Last edited by oliviers on Sunday 21 February 2016 19:09, edited 3 times in total.
Paris area
Raspberry Pi 4 - RFXComm 433 - IrTrans - Zwave
User avatar
nayr
Posts: 354
Joined: Tuesday 11 November 2014 18:42
Target OS: Linux
Domoticz version: github
Location: Denver, CO - USA
Contact:

Re: Listen to your favourite radios

Post by nayr »

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: 73
Joined: Wednesday 16 September 2015 22:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Paris area, France
Contact:

Re: Listen to your favourite radios

Post by oliviers »

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 4 - RFXComm 433 - IrTrans - Zwave
HoLeeShiet
Posts: 26
Joined: Tuesday 18 March 2014 21:19
Target OS: -
Domoticz version:
Contact:

Re: Listen to your favourite radios

Post by HoLeeShiet »

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: 354
Joined: Tuesday 11 November 2014 18:42
Target OS: Linux
Domoticz version: github
Location: Denver, CO - USA
Contact:

Re: Listen to your favourite radios

Post by nayr »

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: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Listen to your favourite radios

Post by deennoo »

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 / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: RE: Re: Listen to your favourite radios

Post by deennoo »

HoLeeShiet wrote:Great tutorial! Would it be possible to do this with a Chromecast Audio? Since I have my RPI hidden in the closet Image
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 / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
fergalom
Posts: 74
Joined: Thursday 24 September 2015 11:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Listen to your favourite radios

Post by fergalom »

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 15:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Listen to your favourite radios

Post by llheim »

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. :)
0n370uch
Posts: 50
Joined: Monday 08 January 2018 2:30
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Contact:

Re: Listen to your favourite radios

Post by 0n370uch »

Hi, I build a new radio script without bash scripts. All done with one LUA script. Based on this idea :-).

Look here: https://www.domoticz.com/forum/viewtopi ... 38&t=21419
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest