I converted "Listen to you favorite radios v2" script to dzVents version.
I a simple radio.lua script. You can select the radio station with a selector switch.
Based on this topic:
viewtopic.php?f=38&t=21419
Dependencies:
Make sure you have a working sound card on domoticz computer.
Make sure you have internet access on domoticz computer
Make sure mplayer is installed :
Code: Select all
sudo apt-get update
sudo apt-get install mplayer
Make a new selector switch with your favorite name, e.g "Radio". Add your radio stations name in "Selector Levels". Then add a new dzVents script. Copy the code and change the radio station addresses, the switch name and the switch selector names. That's about it.
dzVents script:
Code: Select all
-- This script play a streaming radio when the device is changed
-- Start files with "mplayer -noconsolecontrols radiostation.mp3 &> /dev/null"
-- Start playlists with "mplayer -noconsolecontrols -playlist radiostation.m3u &> /dev/null"
return {
on = {
devices = {
'Radio'
}
},
execute = function(domoticz, device)
if device.state == 'Off' then
os.execute ("killall mplayer")
end
if device.state ~= 'Off' then
-- domoticz.helpers.btspeaker(domoticz, 'On') -- BTAudio on
if device.state == 'Mix Megapol' then
os.execute ("killall mplayer")
os.execute ("mplayer -noconsolecontrols http://194.16.21.227/mix_se_aacp -volume 100 &> /dev/null")
end
if device.state == 'NRJ' then
os.execute ("killall mplayer")
os.execute ("mplayer -noconsolecontrols http://ads-e-bauerse-fm-05-gos2.sharp-stream.com/nrj_instreamtest_se_aacp -volume 100 &> /dev/null")
end
if device.state == 'RixFM' then
os.execute ("killall mplayer")
os.execute ("mplayer -noconsolecontrols http://fm01-icecast.mtg-r.net/fm01_mp3 -volume 75 &> /dev/null")
end
if device.state == 'P4 Blekinge' then
os.execute ("killall mplayer")
os.execute ("mplayer -noconsolecontrols http://sverigesradio.se/topsy/direkt/213-hi-mp3 -volume 100 &> /dev/null")
end
end
end
}
I have speak funktion on my domoticz. I made a code snippet to return back to radio after the notification has broadcasts. I use this in my scripts when I'm using speak function.
- Spoiler: show
- Spoiler: show