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

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 »

Seems that your Pi cannot find a bluetooth device... Can you check lspci and lsusb.
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 »

status of bluetooth give me this output
did a fresh reinstall BTW
Everything looks working normal

Code: Select all

gianni@xxxxxxx:~ $ systemctl status bluetooth
● bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset
   Active: active (running) since Fri 2018-09-21 09:39:36 CEST; 1h 2min ago
     Docs: man:bluetoothd(8)
 Main PID: 449 (bluetoothd)
   Status: "Running"
   CGroup: /system.slice/bluetooth.service
           └─449 /usr/lib/bluetooth/bluetoothd

sep 21 09:39:36 domotic systemd[1]: Starting Bluetooth service...
sep 21 09:39:36 domotic bluetoothd[449]: Bluetooth daemon 5.43
sep 21 09:39:36 domotic systemd[1]: Started Bluetooth service.
sep 21 09:39:36 domotic bluetoothd[449]: Starting SDP server
sep 21 09:39:36 domotic bluetoothd[449]: Bluetooth management interface 1.14 ini
[color=#FF0000]sep 21 09:39:36 domotic bluetoothd[449]: Failed to obtain handles for "Service C
sep 21 09:39:36 domotic bluetoothd[449]: Sap driver initialization failed.
sep 21 09:39:36 domotic bluetoothd[449]: sap-server: Operation not permitted (1)
sep 21 09:39:37 domotic bluetoothd[449]: Failed to set privacy: Rejected (0x0b)[/color]
lines 1-18/18 (END)
● bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2018-09-21 09:39:36 CEST; 1h 2min ago
     Docs: man:bluetoothd(8)
 Main PID: 449 (bluetoothd)
   Status: "Running"
   CGroup: /system.slice/bluetooth.service
           └─449 /usr/lib/bluetooth/bluetoothd

sep 21 09:39:36 domotic systemd[1]: Starting Bluetooth service...
sep 21 09:39:36 domotic bluetoothd[449]: Bluetooth daemon 5.43
sep 21 09:39:36 domotic systemd[1]: Started Bluetooth service.
sep 21 09:39:36 domotic bluetoothd[449]: Starting SDP server
sep 21 09:39:36 domotic bluetoothd[449]: Bluetooth management interface 1.14 initialized
[color=#FF0000]sep 21 09:39:36 domotic bluetoothd[449]: Failed to obtain handles for "Service Changed" characteristic
sep 21 09:39:36 domotic bluetoothd[449]: Sap driver initialization failed.
sep 21 09:39:36 domotic bluetoothd[449]: sap-server: Operation not permitted (1)
sep 21 09:39:37 domotic bluetoothd[449]: Failed to set privacy: Rejected (0x0b)[/color]
lsusb works lspci not=

Code: Select all

gianni@xxxxxxxx~ $ lsusb
Bus 001 Device 004: ID 0658:0200 Sigma Designs, Inc.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
gianni@xxxxxxx:~ $ lspci
-bash: lspci: opdracht niet gevonden
gianni@xxxxxx:~ $

Code: Select all

gianni@xxxxxx:~ $ rfkill list
0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: no
1: hci0: Bluetooth
        Soft blocked: no
        Hard blocked: no
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, this is interesting:

Code: Select all

Sap driver initialization failed.
Look here:
https://www.raspberrypi.org/forums/view ... p?t=131999
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 first thing solved.
The distance between te bleutooth speaker and the pi was to far.
Put my pi near my speaker and i got music when i exesute the command om my PI
But i still not get it work in Domoticz.
Looks like the os.excecute is not excecute on the pi :-)
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Listen to your favourite radios V2

Post by emme »

have you setted the country in raspi-config or in the wpasupplicant.conf ?
The most dangerous phrase in any language is:
"We always done this way"
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 »

yep my country is set correct

Code: Select all

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=BE
but my bleutooth is working now it's only the os-execute that not work.
When i test to make a dir in my homefolder with os-execute the dir does not come in my home folder.
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 »

still not working
it's drive me mad :-(
Reinstall my domoticz and stretch multiple time's.

so short
if i execute

Code: Select all

mplayer -noconsolecontrols http://uk2.internet-radio.com:8358/ &> /dev/null
direct on my pi manual it's play on my bleutooth speaker.
if i execute this code on domoticz

Code: Select all

    if  device.state == 'Off' then
        os.execute ("killall mplayer")    
    end
it's kill the player i started manual.

But if is start this code from domoticz it's not play

Code: Select all

        if device.state == 'MNM' then
           os.execute ("killall mplayer") 
           os.execute ("mplayer -noconsolecontrols http://uk2.internet-radio.com:8358/ &> /dev/null")
        end
so whats the different between the off and the MNM code?
The only thing i can think off is that is delete the PI user and use my own user account?
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 found the problem now i need to find a solution
I create a simple bash script that excecute

Code: Select all

mplayer -noconsolecontrols http://uk2.internet-radio.com:8358/
if i run mplayer -noconsolecontrols http://uk2.internet-radio.com:8358/ in the console it's works

Code: Select all

Audio only file format detected.
==========================================================================
Opening audio decoder: [mpg123] MPEG 1.0/2.0/2.5 layers I, II, III
AUDIO: 44100 Hz, 2 ch, s16le, 160.0 kbit/11.34% (ratio: 20000->176400)
Selected audio codec: [mpg123] afm: mpg123 (MPEG 1.0/2.0/2.5 layers I, II, III)
==========================================================================
AO: [pulse] 44100Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...

if i run it from the script i get a pulse connection refused

Code: Select all

Audio only file format detected.
==========================================================================
Opening audio decoder: [mpg123] MPEG 1.0/2.0/2.5 layers I, II, III
AUDIO: 44100 Hz, 2 ch, s16le, 160.0 kbit/11.34% (ratio: 20000->176400)
Selected audio codec: [mpg123] afm: mpg123 (MPEG 1.0/2.0/2.5 layers I, II, III)
==========================================================================
AO: [pulse] Init failed: Connection refused
Failed to initialize audio driver 'pulse'
AO: [alsa] 44100Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
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, I'm not sure. But can you try this:

Code: Select all

sudo adduser <username> audio
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 »

gianni@domotic:~ $ sudo adduser gianni audio
De gebruiker `gianni' is reeds lid van `audio'.

:-)

toch bedankt om mee te denken
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 »

Oh great :-).
Gern geschehen. Viel Spaß ;-).
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 »

hheehehe it's not working,i was already a member of audio :-(
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 bad... :(
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 everyone!) Have you tried to switch channels with a radio button from Xiaomi?
that is, you can make the command "next channel" and so on in a circle?
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: Wednesday 21 November 2018 11:32 Hello everyone!) Have you tried to switch channels with a radio button from Xiaomi?
that is, you can make the command "next channel" and so on in a circle?
Hi, oh cool. I will test it.
User avatar
ledfreak3d
Posts: 98
Joined: Sunday 01 November 2015 15:30
Target OS: Linux
Domoticz version: 3.8025
Location: Hoorn
Contact:

Re: Listen to your favourite radios V2

Post by ledfreak3d »

bluetooth audio from domoticz seems to be a bit of an issue and i cant find why

from console all works great
from domotiz it does not but only when using bluetooth when using analog or hdmi out no issue
Unleashe the magic smoke ;)
pesa1234
Posts: 18
Joined: Wednesday 05 December 2018 11:58
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Italy
Contact:

Re: Listen to your favourite radios V2

Post by pesa1234 »

Hi all, after some issue I found this solution...

Use

Code: Select all

io.popen
to don' block the script and

Code: Select all

runuser -l pi -c

Code: Select all

if domoticz.devices('WebRadio').state == 'Subasio' then
        --domoticz.notify('WebRadio','Radio Subasio on air...', domoticz.PRIORITY_NORMAL)
        os.execute ("killall mplayer")
        io.popen ("runuser -l pi -c \'mplayer -noconsolecontrols http://onair18.xdevel.com:8152 -volume 100 &> /dev/null'")
        domoticz.notify('WebRadio','Radio Subasio on air...', domoticz.PRIORITY_NORMAL)
        --os.execute ("runuser -l pi -c \'mplayer -noconsolecontrols http://onair18.xdevel.com:8152 -volume 100 &> /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 »

pesa1234 wrote: Wednesday 15 April 2020 18:40 Hi all, after some issue I found this solution...
Hi, great and thanks for your feedback.
pesa1234
Posts: 18
Joined: Wednesday 05 December 2018 11:58
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Italy
Contact:

Re: Listen to your favourite radios V2

Post by pesa1234 »

Finish!

I add two dummy selector switches "WebRadio" and "Volume"

When you change the volume is not necessary to kill and restart...

Change your device

Code: Select all

"NBY5540 - A2DP"
with your device...

run

Code: Select all

amixer
to know your...

Code: Select all

return {
    
    data = {
            switchwebradio = { initial = "Off" }
        },
    
	on = {
		devices = {
			'WebRadio',
			'Volume'
		}
	},
	execute = function(domoticz, triggeredItem, info)
	    
	local volume = domoticz.devices('Volume').level
	if (domoticz.devices('Volume').state == "Off") then
	    volume = 0
    end
	cmd = 'amixer set "NBY5540 - A2DP" ' ..volume.. '% &> /dev/null'
	os.execute ("runuser -l pi -c \'" ..cmd.. "'")
	
	if (domoticz.devices('WebRadio').state ~= domoticz.data.switchwebradio) then
	
	if (domoticz.devices('WebRadio').state == 'Off') then
        os.execute ("killall mplayer")
        domoticz.notify('WebRadio','WebRadio spenta', domoticz.PRIORITY_NORMAL)
    end
    
    if domoticz.devices('WebRadio').state == 'Subasio' then
        os.execute ("killall mplayer")
        io.popen ("runuser -l pi -c \'mplayer -noconsolecontrols http://onaxr18.xxxxxxxxxxxxxx.com:8152 &> /dev/null'")
        domoticz.notify('WebRadio','Radio Subasio on air...', domoticz.PRIORITY_NORMAL)
    end
    
    if domoticz.devices('WebRadio').state == 'RTL' then
        os.execute ("killall mplayer")
        io.popen ("runuser -l pi -c \'mplayer -noconsolecontrols  https://strex2.xxxxxxxxxx.com/rtl-1025 &> /dev/null'")
        domoticz.notify('WebRadio','RTL 102.5 on air...', domoticz.PRIORITY_NORMAL)
    end
    
    if domoticz.devices('WebRadio').state == '105' then
        os.execute ("killall mplayer")
        io.popen ("runuser -l pi -c \'mplayer -noconsolecontrols  http://icecast.xxxxxxxxxxo.it/Radio105.mp3 &> /dev/null'")
        domoticz.notify('WebRadio','Radio 105 on air...', domoticz.PRIORITY_NORMAL)
    end
    
    if domoticz.devices('WebRadio').state == 'RDS' then
        os.execute ("killall mplayer")
        io.popen ("runuser -l pi -c \'mplayer -noconsolecontrols  http://icstream.rxxxxxxxxxs.radio/rdsmp3 &> /dev/null'")
        domoticz.notify('WebRadio','RDS on air...', domoticz.PRIORITY_NORMAL)
    end
    
    if domoticz.devices('WebRadio').state == 'Deejay' then
        os.execute ("killall mplayer")
        io.popen ("runuser -l pi -c \'mplayer -noconsolecontrols  http://raxxxxxxxxxy-lh.akamaihd.net/i/RadioDeejay_Live_1@189857/master.m3u8 &> /dev/null'")
        domoticz.notify('WebRadio','Radio Deejay on air...', domoticz.PRIORITY_NORMAL)
    end
    
    if domoticz.devices('WebRadio').state == 'RadioItalia' then
        os.execute ("killall mplayer")
        io.popen ("runuser -l pi -c \'mplayer -noconsolecontrols  https://radixxxxxxxxxxxxxi-lh.akamaihxxxxxxnet/i/radioitaliasmi_1@329643/master.m3u8 &> /dev/null'")
        domoticz.notify('WebRadio','Radio Italia on air...', domoticz.PRIORITY_NORMAL)
    end
    
    if domoticz.devices('WebRadio').state == 'RadioUno' then
        os.execute ("killall mplayer")
        io.popen ("runuser -l pi -c \'mplayer -noconsolecontrols  http://icestreamxxxxxxxxx.it/1.mp3 &> /dev/null'")
        domoticz.notify('WebRadio','Rai Radio 1 on air...', domoticz.PRIORITY_NORMAL)
    end
    
    if domoticz.devices('WebRadio').state == 'RadioDue' then
        os.execute ("killall mplayer")
        io.popen ("runuser -l pi -c \'mplayer -noconsolecontrols  http://icestreaxxxxxxxxxx.it/2.mp3 &> /dev/null'")
        domoticz.notify('WebRadio','Rai Radio 2 on air...', domoticz.PRIORITY_NORMAL)
    end
    
    if domoticz.devices('WebRadio').state == 'IsoRadio' then
        os.execute ("killall mplayer")
        io.popen ("runuser -l pi -c \'mplayer -noconsolecontrols  http://icestrexxxxxxxxi.it/6.mp3 &> /dev/null'")
        domoticz.notify('WebRadio','IsoRadio on air...', domoticz.PRIORITY_NORMAL)
    end
    
    if domoticz.devices('WebRadio').state == 'UAO_Kids' then
        os.execute ("killall mplayer")
        io.popen ("runuser -l pi -c \'mplayer -noconsolecontrols  http://nr11.newrxxxxxxxxxxxxxt:9023/stream?1587028574736 &> /dev/null'")
        domoticz.notify('WebRadio','UAO Kids radio on air...', domoticz.PRIORITY_NORMAL)
    end
    end
    
    domoticz.data.switchwebradio = domoticz.devices('WebRadio').state

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 »

Cool... With notification :-)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest