Re: Webradio
Publié : 21 oct. 2017, 11:05
j'ai un interrupteur par webradio. chacun lance le même script device lua. dans ce script je mets à jour la variable radio avec l'adresse internet du flux de la radio.
Reprenez le contrôle de votre domotique
https://easydomoticz.com/forum/
Code : Tout sélectionner
#!/bin/bash
#echo virginradio
sudo killall mplayer
mplayer -noconsolecontrols http://mp3lg4.tdf-cdn.com/9243/lag_164753.mp3 &Code : Tout sélectionner
--[[
script qui gère la sélection de la radio
pour gérer le son avec un slider -> amixer cset numid=3 10% - amixer cset numid=3 20% etc ...
pour monter le son par palier de 5% -> amixer sset Master 5%+
pour baisser le son par palier de 5% -> amixer sset Master 5%-
--]]
commandArray = {}
----------------------------------------------------------------------------------------------
--Action si l'une des radios est allumée
-------------------------------------------------------------------------------------------------
if (devicechanged['France Bleue la Rochelle']== 'On') then
radio = 'http://direct.francebleu.fr/live/fblarochelle-midfi.mp3'
--print ('radio: '..radio)
os.execute('bash /home/pi/domoticz/scripts/sh/radio.sh "'..radio..'" &')
commandArray[#commandArray + 1]={['UpdateDevice'] = '982|1|France Bleue La Rochelle'} -- renseigne le virtuel text avec la radio en cours d'écoute
elseif (devicechanged['France Info']== 'On') then
radio = 'http://direct.franceinfo.fr/live/franceinfo-midfi.mp3'
--print ('radio: '..radio)
os.execute('bash /home/pi/domoticz/scripts/sh/radio.sh "'..radio..'" &')
commandArray[#commandArray + 1]={['UpdateDevice'] = '982|1|France Info'} -- renseigne le virtuel text avec la radio en cours d'écoute
elseif (devicechanged['Rmc']== 'On') then
radio = 'http://chai5she.cdn.dvmr.fr/rmcinfo'
--print ('radio: '..radio)
os.execute('bash /home/pi/domoticz/scripts/sh/radio.sh "'..radio..'" &')
commandArray[#commandArray + 1]={['UpdateDevice'] = '982|1|RMC'} -- renseigne le virtuel text avec la radio en cours d'écoute
elseif (devicechanged['France Inter']== 'On') then
radio = 'http://direct.franceinter.fr/live/franceinter-midfi.mp3'
--print ('radio: '..radio)
os.execute('bash /home/pi/domoticz/scripts/sh/radio.sh "'..radio..'" &')
commandArray[#commandArray + 1]={['UpdateDevice'] = '982|1|France Inter'} -- renseigne le virtuel text avec la radio en cours d'écoute
elseif (devicechanged['Rtl 2']== 'On') then
radio = 'http://streaming.radio.rtl2.fr:80/rtl2-1-44-128'
--print ('radio: '..radio)
os.execute('bash /home/pi/domoticz/scripts/sh/radio.sh "'..radio..'" &')
commandArray[#commandArray + 1]={['UpdateDevice'] = '982|1|RTL 2'} -- renseigne le virtuel text avec la radio en cours d'écoute
elseif (devicechanged['Rires et Chansons']== 'On') then
radio = 'http://cdn.nrjaudio.fm/audio1/fr/30401/mp3_128.mp3?origine=fluxradios'
--print ('radio: '..radio)
os.execute('bash /home/pi/domoticz/scripts/sh/radio.sh "'..radio..'" &')
commandArray[#commandArray + 1]={['UpdateDevice'] = '982|1|Rire et Chansons'} -- renseigne le virtuel text avec la radio en cours d'écoute
elseif (devicechanged['Virgin']== 'On') then
radio = 'http://mp3lg4.tdf-cdn.com/9243/lag_164753.mp3'
--print ('radio: '..radio)
os.execute('bash /home/pi/domoticz/scripts/sh/radio.sh "'..radio..'" &')
commandArray[#commandArray + 1]={['UpdateDevice'] = '982|1|virgin Radio'} -- renseigne le virtuel text avec la radio en cours d'écoute
elseif (devicechanged['Nostalgie']== 'On') then
radio = 'http://cdn.nrjaudio.fm/audio1/fr/30601/mp3_128.mp3?origine=fluxradios'
--print ('radio: '..radio)
os.execute('bash /home/pi/domoticz/scripts/sh/radio.sh "'..radio..'" &')
commandArray[#commandArray + 1]={['UpdateDevice'] = '982|1|Nostalgie'} -- renseigne le virtuel text avec la radio en cours d'écoute
end
----------------------------------------------------------------------------------------------
--Action si l'une des radios est éteinte
-------------------------------------------------------------------------------------------------
--if (devicechanged['Arret radio']== 'On' or (( devicechanged['France Bleue la Rochelle']== 'Off' or devicechanged['France Info']== 'Off' or devicechanged['France Inter']== 'Off' or devicechanged['Rtl 2']== 'Off'or devicechanged['Rires et Chansons']== 'Off' or devicechanged['Virgin']== 'Off' or devicechanged['Nostalgie']== 'Off' or devicechanged['Rmc']== 'Off' ) and otherdevices['Arret radio']== 'Off') ) then
if (devicechanged['Arret radio']== 'Off' ) then
os.execute('bash /home/pi/domoticz/scripts/sh/radiokill.sh &')
commandArray[#commandArray + 1]={['UpdateDevice'] = '982|1|Radio éteinte'} -- renseigne le virtuel text avec la radio en cours d'écoute
os.execute('bash /home/pi/domoticz/scripts/sh/radiokill.sh &')
commandArray[#commandArray + 1]={['UpdateDevice'] = '982|1|Radio éteinte'} -- renseigne le virtuel text avec la radio en cours d'écoute
os.execute('bash /home/pi/domoticz/scripts/sh/radiokill.sh &')
commandArray[#commandArray + 1]={['UpdateDevice'] = '982|1|Radio éteinte'} -- renseigne le virtuel text avec la radio en cours d'écoute
os.execute('bash /home/pi/domoticz/scripts/sh/radiokill.sh &')
commandArray[#commandArray + 1]={['UpdateDevice'] = '982|1|Radio éteinte'} -- renseigne le virtuel text avec la radio en cours d'écoute
os.execute('bash /home/pi/domoticz/scripts/sh/radiokill.sh &')
commandArray[#commandArray + 1]={['UpdateDevice'] = '982|1|Radio éteinte'} -- renseigne le virtuel text avec la radio en cours d'écoute
os.execute('bash /home/pi/domoticz/scripts/sh/radiokill.sh &')
commandArray[#commandArray + 1]={['UpdateDevice'] = '982|1|Radio éteinte'} -- renseigne le virtuel text avec la radio en cours d'écoute
os.execute('bash /home/pi/domoticz/scripts/sh/radiokill.sh &')
commandArray[#commandArray + 1]={['UpdateDevice'] = '982|1|Radio éteinte'} -- renseigne le virtuel text avec la radio en cours d'écoute
os.execute('bash /home/pi/domoticz/scripts/sh/radiokill.sh &')
commandArray[#commandArray + 1]={['UpdateDevice'] = '982|1|Radio éteinte'} -- renseigne le virtuel text avec la radio en cours d'écoute
os.execute('bash /home/pi/domoticz/scripts/sh/radiokill.sh &')
commandArray[#commandArray + 1]={['UpdateDevice'] = '982|1|Radio éteinte'} -- renseigne le virtuel text avec la radio en cours d'écoute
end
----------------------------------------------------------------------------------------------
--Actions pour monter ou baisser le volume
-------------------------------------------------------------------------------------------------
if (devicechanged['volume raspberry plus']== 'On' or devicechanged['volume raspberry plus']== 'Off') then
os.execute('bash /home/pi/domoticz/scripts/sh/volumeplus.sh &')
elseif (devicechanged['volume raspberry moins']== 'On' or devicechanged['volume raspberry moins']== 'Off') then
os.execute('bash /home/pi/domoticz/scripts/sh/volumemoins.sh &')
end
return commandArrayCode : Tout sélectionner
#!/bin/sh
amixer set Master 5%- > /dev/nullCode : Tout sélectionner
#!/bin/sh
amixer set Master 5%+ > /dev/nullCode : Tout sélectionner
#!/bin/sh
sudo killall vlc > /dev/null # /tmp/mon_log_vlc.txtCode : Tout sélectionner
#!/bin/sh
radio="$1"
pactl unload-module module-loopback >/dev/null
sudo killall vlc > /dev/null # > /tmp/mon_log_vlc.txt # /dev/null
sleep 2
sudo -u pi cvlc "$radio" > /dev/null #>> /tmp/mon_log_vlc2.txt # /dev/null #2>&1 &