Hey there!
I am trying to automate a super small part of my MagicMirror which involves the MMM-PlexNowPlaying module.
Basically, I’m trying to take a JSON file from the filesystem, read it to a JS Object, then use that Object as the value for the userNameFilter key within the config Object.
Code
This is the code I’ve made and added to my config.js to avoid writing an entire module lol:
if (typeof module !== "undefined") {
var plexUsers = require('/home/pi/mmConfig/user_list.json');
let obj = config.modules.find((o, i) => {
if (o.module === "MMM-PlexNowPlaying") {
config.modules[i].config.userNameFilter = plexUsers;
return true; // stop searching
}
});
let test = config.modules.find(o => o.module === "MMM-PlexNowPlaying");
console.log(test);
}
It’s located between var config = {}; and
if (typeof module !== "undefined") {module.exports = config;}
Confusion
The two scenarios I have compared against each other are
- running the code above without
- commenting out
let obj = {}; and hardcoding the Object (the normal way)
And in both cases the output of test is the exact same. Yet the behavior of the Mirror doesn’t seem to reflect that. The standard usage of 2 works as expected, yet 1 does
Any and all help would be greatly appreciated!