Created
April 17, 2018 20:37
-
-
Save jawa-the-hutt/626024fcb0e66a61af20d6dc0dd5c70a to your computer and use it in GitHub Desktop.
function-code-part1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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