Skip to content

Instantly share code, notes, and snippets.

@jawa-the-hutt
Created April 17, 2018 20:37
Show Gist options
  • Save jawa-the-hutt/626024fcb0e66a61af20d6dc0dd5c70a to your computer and use it in GitHub Desktop.
Save jawa-the-hutt/626024fcb0e66a61af20d6dc0dd5c70a to your computer and use it in GitHub Desktop.
function-code-part1.js
// setup array of arrays to hold info for conversion into objects later.
let roomArray = new Array();
let deviceArray = new Array();
// get info from function settings and create the array of arrays
for(let i=1; i <= GetEnvironmentVariable('NUMBER_OF_ROOMS'); i++){
roomArray.push([GetEnvironmentVariable('ROOM_' + i + '_NAME'), GetEnvironmentVariable('ROOM_' + i + '_DTV_ADDRESS')]);
deviceArray.push([GetEnvironmentVariable('ROOM_' + i + '_NAME'), GetEnvironmentVariable('ROOM_' + i + '_DEVICE_ID')]);
};
// map the rooms to a MAC address of the STB
const rooms = Object.assign(...roomArray.map( ([k, v]) => ({[k]: v}) ));
// map the alexa devices you have to their Amazon deviceID
const devices = Object.assign(...deviceArray.map( ([k, v]) => ({[k]: v}) ));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment