Listen to your favourite radios V2

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

Moderator: leecollings

tukestolo
Posts: 12
Joined: Wednesday 28 February 2018 0:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Listen to your favourite radios V2

Post by tukestolo »

0n370uch wrote: Monday 05 March 2018 13:00 Hi, sounds like a Domoticz global problem. Now I am at the end with my knowledge ...sry. Just one idea, check this:
https://www.domoticz.com/wiki/Linux
Thanks I will search a little more to see if I can find something.
For now to work with it, a start Domoticz with screen command.
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 V2

Post by 0n370uch »

Ok. Good luck with your research...
odelay
Posts: 4
Joined: Monday 08 December 2014 17:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Listen to your favourite radios V2

Post by odelay »

Hi 0n370uch, thanks for your great script!

I have added it to my Domoticz using de build in bluetooth of my RPI 3B and it is working great, there is only one thing I can't figure out.
You have a cronjob to activate the connection but I'm using my soundbar which is also connected to my TV and other stuff.
So I only want a connection when I press a radion button.

Is there a way to implement "/bin/echo -e 'connect 00:11:22:33:44:55 \n' | bluetoothctl &> /dev/null" into the script?

thanks!
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 V2

Post by 0n370uch »

odelay wrote: Saturday 31 March 2018 15:43 Is there a way to implement "/bin/echo -e 'connect 00:11:22:33:44:55 \n' | bluetoothctl &> /dev/null" into the script?
thanks!
Hi, you can add a normal button in Domoticz and link a bash script. Add your own bluetooth connect code into this bash script.

Greetings
Fabi
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 V2

Post by 0n370uch »

Hi, interesting... You have the same problem. For me everything is running fine... Mysterious.
tukestolo
Posts: 12
Joined: Wednesday 28 February 2018 0:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Listen to your favourite radios V2

Post by tukestolo »

For me the problem was that if Domoticz start by ir self on startup or by user root it don’t work, but if I start it from folder manual it work :/
I don’t figure why
User avatar
amplituda
Posts: 24
Joined: Thursday 23 August 2018 14:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Finland
Contact:

Re: Listen to your favourite radios V2

Post by amplituda »

Hello everybody!)
I tuned the radio - it works very well - thank you!
but I do not understand how to set up wireless connection on bluetooth
please give detailed instructions
Thanks!)
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 V2

Post by 0n370uch »

Hi, you need to pair your bluetooth device with the domoticz hardware (in my case the Raspberry Pi). After this step you can add a cronjob to autoconnect the bluetooth device. Look here: viewtopic.php?f=38&t=21419#p166533

I attached two picture. This screenshots show you the blocky element to safe the last used radio station.

Greetings
Fabi
Attachments
Bildschirmfoto von 2018-09-13 14-56-44.png
Bildschirmfoto von 2018-09-13 14-56-44.png (233.82 KiB) Viewed 3347 times
Bildschirmfoto von 2018-09-13 14-56-34.png
Bildschirmfoto von 2018-09-13 14-56-34.png (325.37 KiB) Viewed 3347 times
User avatar
amplituda
Posts: 24
Joined: Thursday 23 August 2018 14:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Finland
Contact:

Re: Listen to your favourite radios V2

Post by amplituda »

Hi Fabi)
Thanks for the quick response)
please tell me how to connect my bluetooth column with raspberry 3?
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 V2

Post by 0n370uch »

Hi, add a new file /etc/asound.conf with this text inside (replace the mac address "00:11:22:33:44:55" with the mac address from your bluetooth device):

Code: Select all

pcm.!default {
        type plug
        slave.pcm {
                type bluealsa
                device "00:11:22:33:44:55"
                profile "a2dp"
        }
}

ctl.!default {
        type bluealsa
}
EXTRA: You can add the file /lib/udev/rules.d/10-bluetooth-autoplay.rules (change the mac) for autoplay function:

Code: Select all

#Start radio with Domoticz (Start Radiosender > Level 10%) after connect to Panasonic bluetooth
SUBSYSTEM=="input", ACTION=="add", ATTRS{name}=="00:11:22:33:44:55", RUN+="/usr/bin/curl --insecure 'https://username:[email protected]:443/json.htm?type=command&param=updateuservariable&vname=Wohnzimmer%20>%20Radio%20StartStop&vtype=0&vvalue=1' &> /dev/null"

#Stop radio with Domoticz after disconnect from Panasonic bluetooth
SUBSYSTEM=="input", ACTION=="remove", ATTRS{name}=="00:11:22:33:44:55", RUN+="/usr/bin/curl --insecure 'https://username:[email protected]:443/json.htm?type=command&param=updateuservariable&vname=Wohnzimmer%20>%20Radio%20StartStop&vtype=0&vvalue=2' &> /dev/null"
After this you can pair your device (replace mac again):

Code: Select all

sudo bluetoothctl
power on
agent on
scan on
connect 00:11:22:33:44:55
trust 00:11:22:33:44:55
scan off
exit
EXTRA: And optional the cronjob (change the mac address one last time):

Code: Select all

sudo crontab -e
*/1 * * * * /bin/echo -e 'connect 00:11:22:33:44:55 \n' | bluetoothctl &> /dev/null
User avatar
amplituda
Posts: 24
Joined: Thursday 23 August 2018 14:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Finland
Contact:

Re: Listen to your favourite radios V2

Post by amplituda »

Code: Select all

pi@raspberrypi:~ $ dir
dev-domoticz  nodejs_4.4.2_armhf.deb  python_games  Изображения    Шаблоны
domoticz      npm_2.14.7_armhf.deb    Видео         Музыка
MagPi         oldconffiles            Документы     Общедоступные
miflora       open-zwave-read-only    Загрузки      Рабочий\ стол
pi@raspberrypi:~ $
sorry, I do not know where the directory "etc"
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 V2

Post by 0n370uch »

Type: cd /etc
Or: cd /
And than: ls

You are here (home dir): cd ~
User avatar
amplituda
Posts: 24
Joined: Thursday 23 August 2018 14:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Finland
Contact:

Re: Listen to your favourite radios V2

Post by amplituda »

Thanks a lot to Fabi for your diligence, but your instructions for advanced users ...
they do not understand me, unfortunately ...
my home directory
pi @ raspberrypi: ~ $
it would be very good if you would show how to add auto-connect bluetooth devices from this directory .....
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 V2

Post by 0n370uch »

Ok, just type:

Code: Select all

sudo nano /etc/asound.conf
And than copy the code:

Code: Select all

pcm.!default {
        type plug
        slave.pcm {
                type bluealsa
                device "00:11:22:33:44:55"
                profile "a2dp"
        }
}

ctl.!default {
        type bluealsa
}
Sry but "cd" / "ls" / "nano" / "vim" and so on, are linux basics :-).
User avatar
amplituda
Posts: 24
Joined: Thursday 23 August 2018 14:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Finland
Contact:

Re: Listen to your favourite radios V2

Post by amplituda »

0n370uch wrote: Thursday 13 September 2018 16:38 Ok, just type:

Code: Select all

sudo nano /etc/asound.conf
And than copy the code:

Code: Select all

pcm.!default {
        type plug
        slave.pcm {
                type bluealsa
                device "00:11:22:33:44:55"
                profile "a2dp"
        }
}

ctl.!default {
        type bluealsa
}
Sry but "cd" / "ls" / "nano" / "vim" and so on, are linux basics :-).
Thank you very much for your patience Fabi! Now I have a column connected to the bluetooth in my house - I'm happy)
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 V2

Post by 0n370uch »

amplituda wrote: Friday 14 September 2018 8:51 Thank you very much for your patience Fabi! Now I have a column connected to the bluetooth in my house - I'm happy)
Hey, great :-). I'm happy too. Have a nice weekend.
Gianni
Posts: 230
Joined: Saturday 21 July 2018 19:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Home@Belgium
Contact:

Re: Listen to your favourite radios V2

Post by Gianni »

i don't know what i'm doing wrong but this will not work for me
I followed your guide but when i switch to a channel nothing happens.

When i put this command in my terminal i get NO sound on my BT speakers.
mplayer -noconsolecontrols http://uk2.internet-radio.com:8358/ &> /dev/null

but when i put this code in my terminal i get the radio stream from my BT speakers
mplayer http://uk2.internet-radio.com:8358

BUT then again when i switch to OFF in domoticz then te player quit.

all i see in my domticz log is
2018-09-17 21:17:46.281 (Radio) Light/Switch (Radio)
2018-09-17 21:17:46.273 Status: User: Admin initiated a switch command (60/Radio/Set Level)
2018-09-17 21:17:57.014 (Radio) Light/Switch (Radio)
2018-09-17 21:17:57.001 Status: User: Admin initiated a switch command (60/Radio/Set Level)
2018-09-17 21:18:06.486 (Radio) Light/Switch (Radio)
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 V2

Post by 0n370uch »

Hello, you need to add a playlist or a file like ".m3u" or ".mp3".
Gianni
Posts: 230
Joined: Saturday 21 July 2018 19:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Home@Belgium
Contact:

Re: Listen to your favourite radios V2

Post by Gianni »

Ok i will try that tonight when i'm home from work.
I just took the first url from your script to test :-)

if (devicechanged['Wohnzimmer > Radio'] == '1FM') then
os.execute ("killall mplayer")
os.execute ("mplayer -noconsolecontrols http://uk2.internet-radio.com:8358/ &> /dev/null")
end
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 V2

Post by 0n370uch »

Ah yeah sry. This isn't working anymore.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest