Read the statement by Michael Teeuw here.
Updating Compliments using a spreadsheet
-
@emrah_asl well, what does the node_helper do? there is a specific structure to that file, as it is a program under mm as part of a module. if u created it as a standalone pgm, then it won’t work like u want.
-
@sdetweil after I created node__helper.js manually, then I typed ‘npm start’ , the file has created, bu this time there was electron error (MM closed) interesting.
-
@emrah_asl yeh, that won’t work
-
@sdetweil so, what is formula to run this ? what do you think acording your experience ?
-
@emrah_asl well, the problem is coming up w something u have the skills to do.
-
so, thinking more.
do you have a js routine that will download the sheet in json and convert to the proper format now? you would execute it with
node ???whatever your script name is???
if so, you could add it to the installers/mm.sh script that is used by pm2 to start mm.
this way every time mm is started, you would download the new compliments file sheet and convert it
-
Hi @sdetweil ,
Thanks for reply.
my code in node_helper.js (under compliments folder) are creating file on root normally when you start mm with npm start
The problems are,
1 - I need to change save folder not root side, it needs to be under compliements folder, so I change this but not worksvar fs = require('fs'); fs.writeFile("modules/default/compliments/remotefile.json", compliments, function(err) { if (err) { return console.log(err); } console.log("The file was saved!"); });
- The second problem , my magic mirror fires electron.js error when I try to create file. I’m new on these, how can i use mm.sh for create&locate remotefile.json under compliments folder ?
-
@emrah_asl said in Updating Compliments using a spreadsheet:
fs.writeFile("modules/default/compliments/remotefile.json", compliments, function(err) {
- my code in node_helper.js (under compliments folder) are creating file on root normally when you start mm with npm start
don’t make this node_helper.js as MM has a special use for that…
make it createCompliments.jsthen the best thing is use the full path for the file
fs.writeFile("/home/pi/MagicMirror/modules/default/compliments/remotefile.json", compliments, function(err) {
how do you start MM?
pm2 start 0 (and it starts on boot too…) If you used the automated install script u would have been prompted to set this up.
(if u want to add it now, you can run the fixuppm2.sh script from here
https://github.com/sdetweil/MagicMirror_scripts
just one line to copy/paste
)now, if you use pm2, it launches MM by using the installers/mm.sh script. you can add your
node modules/default/compliments/createCompliments.js
to the mm.sh and all will continue as normal.
-
The second problem , my magic mirror fires electron.js error when I try to create file.
i don’t understand this.
npm start fires electron.js
npm reads the package,json file and looks for the command requested
"scripts": { "start": "DISPLAY=\"${DISPLAY:=:0}\" ./node_modules/.bin/electron js/electron.js",
the ‘start’ command executes that line.