I am trying to adjust the script a little bit. What I want is randomly put 17 Spotify Playlists to 3 better logic variables, called PlayListDay1 PlayListDay2 and PlayListDay3. After that I want to add the content off the 3 playlist variables PlayListDay1, PlayListDay2, PlaylistDay3 towards the variables Radio12, Radio13 and Radio14
Then put 11 radiostations towards 11 better variables. Called Radio1, Radio 2 …Radio11. After this i want the content off Radio1 - Radio14 randomly set to the better Logic variables RadioDay1 - RadioDay14.
Hope it makes some sense.
This is what I made untill now
// Script for randomly playing radiostations and playlists from Spotify with your Sonos Device
// With the use of a Synology Server and the Sonos Docker Api
// Using Homey's apps Better Logic and HTTP request
//Prefix voor radiostations en playlists
//Add your local ip adres at IPadres en your Portnumber at Portnumber between the quotes
const IpAdres = '192.168.178.2';
const Portnumber = '5005';
const RadioPrefix = 'http:%2F%2F' + IpAdres + ':' + Portnumber + '%2Fwoonkamer%2Ffavorite%2F';
const PlayListPrefix = 'http:%2F%2F'+ IpAdres + ':'+ Portnumber + '%2Fwoonkamer%2Fspotify%2Fnow%2Fspotify:user:spotify:playlist:';
//Add your station at //Radiostations. In your Sonos app, from Sonos(not Homey) you
//need to add your radiostation as favorite. Use this exact name. In this script
// I have added three playlists. Therefore the variable names Radio12, Radio13 en Radio14 must be
//stay the same and not been altered.
//To add some random playlist I have made 17 playlist which you can adjust. Just search the ID
//off your playlist in your Spotify App(not Homey) and paste this ID at //PlayList between
//the quotes
// Add 14 string variables in Better Logic, called RadioDay1, RadioDay2.....Radioday3 and three extra
//string variables called PlayListDay1, PlayListDay2 and PlayListDay3. The names are capital sensitive.
//Radiostations Add the name off your Sonos favorite between the quotes
const Radio1 = RadioPrefix + '538 Ibiza Radio';
const Radio2 = RadioPrefix + 'Deep House Ibiza';
const Radio3 = RadioPrefix + '538 Dance Radio';
const Radio4 = RadioPrefix + 'Dance FM';
const Radio5 = RadioPrefix + '538 Global Dance Chart';
const Radio6 = RadioPrefix + 'Deep Radio';
const Radio7 = RadioPrefix + 'Disco Radio Action';
const Radio8 = RadioPrefix + 'Our House';
const Radio9 = RadioPrefix + 'Sky Radio 101 FM';
const Radio10 = RadioPrefix + 'Qmusic';
const Radio11 = RadioPrefix + 'Slam!';
//const Radio12 = 'Playlist1';//Do not adjust this variable
//const Radio13 = 'Playlist2';//Do not adjust this variable
//const Radio14 = 'Playlist3';//Do not adjust this variable
//Playlist. Ad the ID of your Spotify playlist between the quotes. For own needs you can add the
//name of the playlist after the //
const PlayList1 = PlayListPrefix + ‘7GQS3BcOeogh8wKEeA3fN8?si=taswh15eRZuXmFAkyn6IfQ’//12inch Classics Part 1
const PlayList2 = PlayListPrefix + ‘1C5F8dA3nWRN46u6lCehqm?si=67RdCbXtSG27gx6C7qP2Sw’//Deep Delight Part 2
const PlayList3 = PlayListPrefix + ‘1QdAD45sKZQwptkm4VeKmO?si=_5P2-G9-SZG91WsNHt0f4g’//360 Dance Part 2
const PlayList4 = PlayListPrefix + ‘4YKqPMOlV5JJK6XVKKdWJ9?si=SL7iH53eSNu-PnsZJIcr6A’//Deep House Part 2
const PlayList5 = PlayListPrefix + ‘7jzMzltNsYhaI5Xfkxe9If?si=IwDTD4ylQJC9c5JWxEUXQw’//Massive Pop Remixes Part 1
const PlayList6 = PlayListPrefix + ‘5sInx9KNxVqnONg9EsIptX?si=8T0QWluxSDqI3bClrf0OOQ’//Dance Classics Part 1
const PlayList7 = PlayListPrefix + ‘0NhMKI95ujIjriBaRXrIBs?si=pG_J4OXGTz6mhN_kG1mvMg’//Dance Pop Remixes Part 1
const PlayList8 = PlayListPrefix + ‘1s4YUBb95LaWazpgvNGzAu?si=35wEzzqcQIKAgSZq7bkEaA’//Deep House Relax Part 3
const PlayList9 = PlayListPrefix + ‘60HqFyCYzr6dxr4OMxDtS7?si=x7Oa5bNBQXy4DQlC2COLaw’//Truly Deeply House Part 1
const PlayList10 = PlayListPrefix + ‘00JuraVC5HSlXCLpYJ4RQx?si=LJFWf4UoQ-2DtayVAGb26g’//360 Dance Part 1
const PlayList11 = PlayListPrefix + ‘0C66rsP0YemHrh3dUhSszt?si=gdtcDlzURLWQVZCKi8Evkw’//Deep House Relax Part 2
const PlayList12 = PlayListPrefix + ‘4Vaus40H2m6gkwNqhzzril?si=6y9qg0HxQAqfB_B3bhfeIQ’//Deep Delight Part 1
const PlayList13 = PlayListPrefix + ‘0nXxaEdtBNILZHvltonbpT?si=4IxGc-mzQ7OGoFKCPGD2vA’//Dance Pop Part 1
const PlayList14 = PlayListPrefix + ‘3xDZn9OQLBxJBtWYSfNO3p?si=9C5nZsdZT7Kd3knE2KcngA’//Marcels Favorieten 2018 en 2019
const PlayList15 = PlayListPrefix + ‘28MJ5Ws6Hw7K3sM0buLxvS?si=sR9304GXTzikRt1n3so-MQ’//Marcels Favorieten 2017
const PlayList16 = PlayListPrefix + ‘4oH8GC0TMvQGlTXlj3luUq?si=RnmzYP4YRCWSPa9ptJTuRA’//Deep House Relax Part 1
const PlayList17 = PlayListPrefix + ‘6tN0M7JUSAUnPbqe4cPz8I?si=juDi1DjuQjms0iBzMowMag’//Marcels Favorieten 2016
var PlayListMake = [PlayList1,PlayList2,PlayList3,PlayList4,PlayList5,PlayList6,PlayList7,
PlayList8,PlayList9,PlayList10,PlayList11,PlayList12,PlayList13,PlayList14,PlayList15,
PlayList16,PlayList17];
var usedNums = [];
let BLApp = await Homey.apps.getApp({id:"net.i-dev.betterlogic" });
while (PlayListMake.length) {
var number = PlayListMake.length.toString();
var randomIndex = Math.floor(Math.random() * (PlayListMake.length));
var randomNumber = PlayListMake.splice(randomIndex, 1)[0];
console.log(randomNumber.toString() + " " + number) ;
let result=BLApp.apiPut("PlayListDay"+number+"/" + randomNumber.toString());
};
let PlayListDay1=await BLApp.apiGet('PlayListDay1');
let Radio12 = PlayListDay1;
let PlayListDay2=await BLApp.apiGet('PlayListDay2');
let Radio13 = PlayListDay2;
let PlayListDay3=await BLApp.apiGet('PlayListDay3');
let Radio14 = PlayListDay3;
var nums = [Radio1,Radio2,Radio3,Radio4,Radio5,Radio6,Radio7,Radio8,Radio9,Radio10,Radio11,
PlayListDay1,PlayListDay2,PlayListDay3];
var usedNums = [];
//let BLApp = await Homey.apps.getApp({id:"net.i-dev.betterlogic" });
while (nums.length) {
var nummer = nums.length.toString();
var randomIndex = Math.floor(Math.random() * (nums.length));
var randomNumber = nums.splice(randomIndex, 1)[0];
console.log(randomNumber.toString() + " " + nummer) ;
let result=BLApp