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.

    How difficult would it be to change the data an existing module receives?

    Scheduled Pinned Locked Moved Development
    13 Posts 2 Posters 2.2k Views 2 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.
    • TipponT Offline
      Tippon
      last edited by

      I’m currently using the fantastic MMM-Fitbit2 module to display some of my fitness data. As I have a third party smart band though, Fitbit doesn’t accept all of my data. This then means that the module doesn’t have anything to pull for certain categories.

      How difficult would it be to tell the module to pull my steps and sleep from Google Fit, and my blood sugar readings from a spreadsheet? Would I be better off trying to create my own module so that I don’t break anything when MMM-Fitbit2 updates?

      I can’t do much in the way of programming, but I’m looking for a project to help me learn.

      Please forgive me if I'm slow to reply, I'm currently experiencing memory issues, and sometimes forget that I've asked a question >.<

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

        @Tippon you can clone (fork) the module and add on what you want…

        there are two parts of the module… the browser/ui part MMM-Fitbit2.js
        and the helper, node_helper.js

        the MMM-Fitbit2.js cannot access hardware or files directly, so it has to call the helper

        so, you could add on access to the spreadsheet (csv)
        and send that data back as part of the response… the front end would never know

        one of my modules uses a csv

        in the node_helper
        (you have to npm install csvtojson in the module folder to be able to use it)

        const cvt = require("csvtojson");
        

        and then

                                       cvt().fromFile(payload.tmpfile) // input xls  // changed to tmpfile
             				.subscribe((jsonObj, index) => { 
                                               // handle each row
                                           })
        

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        TipponT 2 Replies Last reply Reply Quote 2
        • TipponT Offline
          Tippon @sdetweil
          last edited by

          @sdetweil said in How difficult would it be to change the data an existing module receives?:

          @Tippon you can clone (fork) the module and add on what you want…

          Sorry, I should have clarified - I know that I can fork the module, but I don’t have the skills or knowledge to keep up with any changes that might be made to the original. If there was a security update, for example, I wouldn’t know how to integrate that into my fork. Considering the dates of the last changes though, that might not be an issue in this case.

          @sdetweil said in How difficult would it be to change the data an existing module receives?:

          there are two parts of the module… the browser/ui part MMM-Fitbit2.js
          and the helper, node_helper.js

          the MMM-Fitbit2.js cannot access hardware or files directly, so it has to call the helper

          so, you could add on access to the spreadsheet (csv)
          and send that data back as part of the response… the front end would never know

          one of my modules uses a csv

          in the node_helper
          (you have to npm install csvtojson in the module folder to be able to use it)

          const cvt = require("csvtojson");
          

          and then

                                         cvt().fromFile(payload.tmpfile) // input xls  // changed to tmpfile
               				.subscribe((jsonObj, index) => { 
                                                 // handle each row
                                             })
          

          So, ignoring any possible updates for now, I could edit the node_helper.js and basically trick the rest of the module into using my chosen data instead? That sounds great, thanks :)

          I’ve found some apps that share data between Fitbit and Google Fit, so depending on how well they all work together, this might be a bit easier than I thought.

          I’ve just discovered a problem with the Fitbit data though. Until recently, MMM-Fitbit2 would pull a lot of my data and display it on my mirror. Today though it’s not displaying my calories in figure. Google has taken over Fitbit, and recently forced a change of login, from Fitbit’s old system to a Google login. I’m not sure if this problem started at the same time, or if there’s been a change in the API. I’m pottering around trying to figure it out, but it might take me a while to figure out what I’m doing, never mind what Fitbit / Google are doing >.<

          Thanks as always for your help :)

          Please forgive me if I'm slow to reply, I'm currently experiencing memory issues, and sometimes forget that I've asked a question >.<

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

            @Tippon you don’t have to contribute back, or take any other changes…

            so don’t worry about those

            yes changes keep rolling along, non stop

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            TipponT 1 Reply Last reply Reply Quote 1
            • TipponT Offline
              Tippon @sdetweil
              last edited by

              I found a post by @greenza21 on Reddit that suggested Health Sync for Android

              https://play.google.com/store/apps/details?id=nl.appyhapps.healthsync

              I’ve tested Health Sync over the last few days, and it’s successfully transferred my Steps, Activities, Sleep, and Weight data from Google Fit in to Fitbit. It can also transfer Nutrition and Water Intake directly, but I already input those directly into Fitbit. It can export some other data too, but Fitbit doesn’t accept those inputs.

              I’ve got everything I want other than my blood sugar / glucose readings showing up in the MMM-Fitbit2 module just from using Health Sync, so when I get a bit more time over the next few days, I’m going to try to replace the floors entry with my blood glucose data, then maybe look at exporting my heart rate or oxygen levels from my smartwatch, depending on whether they can be pulled from the watch app. Not everything gets pulled to Google Fit, so they may be a dead end.

              Please forgive me if I'm slow to reply, I'm currently experiencing memory issues, and sometimes forget that I've asked a question >.<

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

                @Tippon so, summary

                you use the app to push data to fitbit,

                where the existing Fitbit2 module can get the data from the existing fitbit api…

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                TipponT 1 Reply Last reply Reply Quote 0
                • TipponT Offline
                  Tippon @sdetweil
                  last edited by

                  @sdetweil That’s right, yes :)

                  It’s ideal for me, and I have suspected ADHD, and don’t always remember to do things. I can just put the shortcut to this app next to my other health apps, and it acts as a reminder.

                  I’ve decided to remove one of the MMM-fitbit2 default categories and replace it with a modified copy of the calorie goal category instead. The default shows the calories remaining until your calorie goal, but I also want to see how many calories I’ve consumed. I just had a quick play and it seems easy enough, but I need to make sure that it doesn’t break the existing categories too.

                  Time for a break though, my kid’s about to get home from school, so any chance of peace and quiet is gone for the next few hours :D

                  Please forgive me if I'm slow to reply, I'm currently experiencing memory issues, and sometimes forget that I've asked a question >.<

                  1 Reply Last reply Reply Quote 0
                  • TipponT Offline
                    Tippon
                    last edited by

                    Just to double check before I break anything, if I forked the repo and replaced the installed version of MMM-Fitbit2 with my own, would I need to change anything in my config.js? I’m assuming that if I kept the same repo name it would just work, but I want to make sure.

                    Please forgive me if I'm slow to reply, I'm currently experiencing memory issues, and sometimes forget that I've asked a question >.<

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

                      @Tippon no changes to config unless you added something

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      TipponT 1 Reply Last reply Reply Quote 1
                      • TipponT Offline
                        Tippon @sdetweil
                        last edited by

                        @sdetweil Brilliant, thank you :)

                        Please forgive me if I'm slow to reply, I'm currently experiencing memory issues, and sometimes forget that I've asked a question >.<

                        1 Reply Last reply Reply Quote 0
                        • 1
                        • 2
                        • 1 / 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