Control PiMusicbox with lua
Posted: Tuesday 15 March 2016 12:49
I created this script to control my http://www.PiMusicbox.com with Domoticz.
Code: Select all
-- Script to control my Pi Musicbox
--
-- Usage of a two Dummy devices: Selector (MusicBox radio) and Dimmer (MusicBox volue)
--
--
commandArray = {}
if devicechanged['MusicBox volume'] then
if (devicechanged['MusicBox volume']=='Off') then
os.execute('mpc --host=musicbox.local stop')
print('Switch off Radio')
else
if (devicechanged['MusicBox volume']=='On') then
os.execute('mpc --host=musicbox.local play')
print('Switch on Radio')
else
os.execute('mpc --host=musicbox.local volume '..otherdevices_svalues['MusicBox volume'])
print('Set volume to '..otherdevices_svalues['MusicBox volume'])
end
end
end
if (devicechanged['MusicBox radio']=='100% NL') then
os.execute('mpc --host=musicbox.local clear')
os.execute('mpc --host=musicbox.local add http://stream.100p.nl/100pctnl.mp3')
os.execute('mpc --host=musicbox.local volume '..otherdevices_svalues['MusicBox volume'])
os.execute('mpc --host=musicbox.local play 1')
print('Switched Radio to 100% NL')
end
if (devicechanged['MusicBox radio']=='3FM Serious Radio') then
os.execute('mpc --host=musicbox.local clear')
os.execute('mpc --host=musicbox.local add http://icecast.omroep.nl/3fm-bb-mp3.m3u')
os.execute('mpc --host=musicbox.local volume '..otherdevices_svalues['MusicBox volume'])
os.execute('mpc --host=musicbox.local play 1')
print('Switched Radio to 3FM')
end
if (devicechanged['MusicBox radio']=='Studio Brussel') then
os.execute('mpc --host=musicbox.local clear')
os.execute('mpc --host=musicbox.local add http://mp3.streampower.be/stubru-high.mp3')
os.execute('mpc --host=musicbox.local volume '..otherdevices_svalues['MusicBox volume'])
os.execute('mpc --host=musicbox.local play 1')
print('Switched Radio to Studio Brussel')
end
if (devicechanged['MusicBox radio']=='Radio 538') then
os.execute('mpc --host=musicbox.local clear')
os.execute('mpc --host=musicbox.local add http://vip-icecast.538.lw.triple-it.nl/RADIO538_MP3.m3u')
os.execute('mpc --host=musicbox.local volume '..otherdevices_svalues['MusicBox volume'])
os.execute('mpc --host=musicbox.local play 1')
print('Switched Radio to Radio 538')
end
if (devicechanged['MusicBox radio']=='Sky radio') then
os.execute('mpc --host=musicbox.local clear')
os.execute('mpc --host=musicbox.local add http://8573.live.streamtheworld.com:80/SKYRADIO_SC')
os.execute('mpc --host=musicbox.local volume '..otherdevices_svalues['MusicBox volume'])
os.execute('mpc --host=musicbox.local play 1')
print('Switched Radio to Sky Radio')
end
return commandArray