Play streaming radio
Purpose
This script will play a streaming radio for 1800 seconds. It is useful to give ambiant music.
Dependencies - hardware / software / operating system
- To trigger this script you can use Trigger a bash script method or any other method.
- 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 : sudo apt-get install Mplayer
Domoticz Setup - switches, variables, version
N/A
Installation instructions
Copy this script in your domoticz\scripts\ folder.
Script with comments Part 1 (lua)
-- script name : script_device_tunein.lua -- This script will trigger a bash script to play a streaming radio when the device "Sensor" is On -- Replace "sensor2, etc" variable by your virtual device name. e.g. : "Radio - BBC" local sensor = 'Radio - Kill All' local sensor2 = 'Radio - BBC' local sensor3 = 'Radio - Road Trip Tunes' local sensor4 = 'Radio - TD Summer Jams' local sensor5 = 'Radio - Jazz Songbook' local sensor6 = 'Radio - Latin Top 40' local sensor7 = 'Radio - World' local sensor8 = 'Radio - Sonica' local sensor9 = 'Radio - Heppners Opera Gems' local sensor10 = 'Radio - Nesrallahs Tempo' local sensor11 = 'Radio - Essential Classics' local sensor12 = 'Radio - Baroque' local sensor14 = 'Radio - Modern Masters' local sensor15 = 'Radio - Orchestral' local sensor16 = 'Radio - Piano' local sensor17 = 'Radio - Chamber' local sensor18 = 'Radio - Canadian Composers' local sensor19 = 'Radio - Choral' local sensor20 = 'Radio - Classical Serenity' local sensor22 = 'Radio - Bachmans Guitarchives' local sensor24 = 'Radio - Tamashiros Tonic' local sensor25 = 'Radio - Phil Dwyers Jazz Canada' local sensor26 = 'Radio - Tom Powers Deep Roots' local sensor27 = 'Radio - Laurie Brown The Signal' local sensor28 = 'Radio - Jians New Wave' local sensor29 = 'Radio - Colin James Blues' local sensor31 = 'Radio - Adult Alternative' local sensor32 = 'Radio - Indie' local sensor33 = 'Radio - Rock' local sensor34 = 'Radio - Rock Classics' local sensor35 = 'Radio - Workout Mix' local sensor36 = 'Radio - Chill Out' local sensor37 = 'Radio - Saddest Songs' local sensor38 = 'Radio - Pop 40' local sensor39 = 'Radio - Adult Pop' local sensor41 = 'Radio - The 70s' local sensor42 = 'Radio - The 80s' local sensor43 = 'Radio - The 90s' local sensor44 = 'Radio - Hip Hop' local sensor46 = 'Radio - Jazz Songbook' local sensor48 = 'Radio - Smooth Jazz' local sensor51 = 'Radio - Canadian Songwriters' local sensor52 = 'Radio - Singer Songwriter' local sensor55 = 'Radio - Reggae' local sensor57 = 'Radio - Blues Classics' local sensor58 = 'Radio - RB Soul' local sensor59 = 'Radio - Classic Soul RB' local sensor61 = 'Radio - Aboriginal' local sensor62 = 'Radio - Hot Country' local sensor63 = 'Radio - Country Classics' commandArray = {} if (devicechanged[sensor] == 'On') then os.execute ("killall mplayer") end if (devicechanged[sensor2] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://www.bbc.co.uk/radio/listen/live/r1_aaclca.pls") commandArray[sensor2]='Off' end if (devicechanged[sensor3] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_SPCIAL_H.pls") commandArray[sensor3]='Off' end if (devicechanged[sensor4] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_SPCIA2_H.pls") commandArray[sensor4]='Off' end if (devicechanged[sensor5] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_JAZMAS_H.pls") commandArray[sensor5]='Off' end if (devicechanged[sensor6] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_LATIN1_H.pls") commandArray[sensor6]='Off' end if (devicechanged[sensor7] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_WORLDM_H.pls") commandArray[sensor7]='Off' end if (devicechanged[sensor8] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_SONICA_H.pls") commandArray[sensor8]='Off' end if (devicechanged[sensor9] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_OPERAT_H.pls") commandArray[sensor9]='Off' end if (devicechanged[sensor10] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_R2CLAS_H.pls") commandArray[sensor10]='Off' end if (devicechanged[sensor11] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_ECLASS_H.pls") commandArray[sensor11]='Off' end if (devicechanged[sensor12] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_BAROQU_H.pls") commandArray[sensor12]='Off' end if (devicechanged[sensor14] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_MODMAS_H.pls") commandArray[sensor14]='Off' end if (devicechanged[sensor15] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_ORCHES_H.pls") commandArray[sensor15]='Off' end if (devicechanged[sensor16] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_PIANO1_H.pls") commandArray[sensor16]='Off' end if (devicechanged[sensor17] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_GGSAMP_H.pls") commandArray[sensor17]='Off' end if (devicechanged[sensor18] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_CANCOM_H.pls") commandArray[sensor18]='Off' end if (devicechanged[sensor19] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_CHORAL_H.pls") commandArray[sensor19]='Off' end if (devicechanged[sensor20] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_SERENE_H.pls") commandArray[sensor20]='Off' end if (devicechanged[sensor22] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_GUITAR_H.pls") commandArray[sensor22]='Off' end if (devicechanged[sensor24] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_R2JAZZ_H.pls") commandArray[sensor24]='Off' end if (devicechanged[sensor25] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_JAZCDN_H.pls") commandArray[sensor25]='Off' end if (devicechanged[sensor26] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_DROOTS_H.pls") commandArray[sensor26]='Off' end if (devicechanged[sensor27] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_SIGNAL_H.pls") commandArray[sensor27]='Off' end if (devicechanged[sensor28] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_NEWWAV_H.pls") commandArray[sensor28]='Off' end if (devicechanged[sensor29] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_BLUES1_H.pls") commandArray[sensor29]='Off' end if (devicechanged[sensor31] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_ADLTAL_H.pls") commandArray[sensor31]='Off' end if (devicechanged[sensor32] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_INDIE1_H.pls") commandArray[sensor32]='Off' end if (devicechanged[sensor33] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_ROCK01_H.pls") commandArray[sensor33]='Off' end if (devicechanged[sensor34] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_ROCKCL_H.pls") commandArray[sensor34]='Off' end if (devicechanged[sensor35] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_WRKOUT_H.pls") commandArray[sensor35]='Off' end if (devicechanged[sensor36] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_CHILL1_H.pls") commandArray[sensor36]='Off' end if (devicechanged[sensor37] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_SADSNG_H.pls") commandArray[sensor37]='Off' end if (devicechanged[sensor38] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_POP040_H.pls") commandArray[sensor38]='Off' end if (devicechanged[sensor39] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_JUKEBO_H.pls") commandArray[sensor39]='Off' end if (devicechanged[sensor41] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_70S001_H.pls") commandArray[sensor41]='Off' end if (devicechanged[sensor42] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_80S001_H.pls") commandArray[sensor42]='Off' end if (devicechanged[sensor43] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_90S001_H.pls") commandArray[sensor43]='Off' end if (devicechanged[sensor44] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_HIPHOP_H.pls") commandArray[sensor44]='Off' end if (devicechanged[sensor46] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_JAZSON_H.pls") commandArray[sensor46]='Off' end if (devicechanged[sensor48] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_JAZSMO_H.pls") commandArray[sensor48]='Off' end if (devicechanged[sensor51] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_CANSON_H.pls") commandArray[sensor51]='Off' end if (devicechanged[sensor52] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_SINSON_H.pls") commandArray[sensor52]='Off' end if (devicechanged[sensor55] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_REGGAE_H.pls") commandArray[sensor55]='Off' end if (devicechanged[sensor57] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_BLCLAS_H.pls") commandArray[sensor57]='Off' end if (devicechanged[sensor58] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_RBSOUL_H.pls") commandArray[sensor58]='Off' end if (devicechanged[sensor59] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_SOULCL_H.PLS") commandArray[sensor59]='Off' end if (devicechanged[sensor61] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_ABORIG_H.pls") commandArray[sensor61]='Off' end if (devicechanged[sensor62] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_CONTRY_H.pls") commandArray[sensor62]='Off' end if (devicechanged[sensor63] == 'On') then os.execute ("/root/domoticz/domoticz/scripts/stream_radio.sh 3600 http://playerservices.streamtheworld.com/pls/CBC_CLSCRY_H.pls") commandArray[sensor63]='Off' end return commandArray
Script with comments Part 2 (Bash)
#!/bin/sh killall mplayer mplayer -ao alsa -noconsolecontrols -endpos $1 -playlist $2 > /dev/null 2>&1
Example of use (if relevant) i.e. output files / screen displays
N/A