MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Updating Compliments using a spreadsheet

    Scheduled Pinned Locked Moved Development
    14 Posts 4 Posters 4.1k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E Offline
      emrah_asl
      last edited by

      Hi, where did you write this code ? When I try write on “compliments.js” my console does not recognize ‘require’ tag. Could you please share fullcode ?

      S 1 Reply Last reply Reply Quote 0
      • S Offline
        sdetweil @emrah_asl
        last edited by

        @emrah_asl the modulename.js does not allow require(). as it runs inside the browser. anything needing require() must be done in the node_helper.js, and the two parts must send data back and forth with socketNotifications per the mm spec.

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 0
        • E Offline
          emrah_asl
          last edited by emrah_asl

          Hi @sdetweil thanks I missed up

          , so what should I customize compliment.js ?

          Here is my change on compliement.js

          remoteFile: "remotefile.json",
          

          I created my json link and create node_helper.js file and put my folder with these codes.

          But I think I missed somethings, it doesn’t work, and there is no file creation on folder called “remotefile.json”

          S 1 Reply Last reply Reply Quote 0
          • S Offline
            sdetweil @emrah_asl
            last edited by

            @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.

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            E 1 Reply Last reply Reply Quote 0
            • E Offline
              emrah_asl @sdetweil
              last edited by

              @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.

              S 1 Reply Last reply Reply Quote 0
              • S Offline
                sdetweil @emrah_asl
                last edited by

                @emrah_asl yeh, that won’t work

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                1 Reply Last reply Reply Quote 0
                • E Offline
                  emrah_asl
                  last edited by

                  @sdetweil so, what is formula to run this ? what do you think acording your experience ?

                  S 1 Reply Last reply Reply Quote 0
                  • S Offline
                    sdetweil @emrah_asl
                    last edited by

                    @emrah_asl well, the problem is coming up w something u have the skills to do.

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      sdetweil
                      last edited by sdetweil

                      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

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      1 Reply Last reply Reply Quote 0
                      • E Offline
                        emrah_asl
                        last edited by

                        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 works

                         var 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!");
                                });
                        
                        1. 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 ?
                        S 1 Reply Last reply Reply Quote 0
                        • 1
                        • 2
                        • 2 / 2
                        • First post
                          Last post
                        Enjoying MagicMirror? Please consider a donation!
                        MagicMirror created by Michael Teeuw.
                        Forum managed by Sam, technical setup by Karsten.
                        This forum is using NodeBB as its core | Contributors
                        Contact | Privacy Policy