Skip to content
This repository has been archived by the owner on Aug 3, 2020. It is now read-only.

Multiple Instances of The Module #3

Closed
amcolash opened this issue Feb 4, 2018 · 2 comments
Closed

Multiple Instances of The Module #3

amcolash opened this issue Feb 4, 2018 · 2 comments

Comments

@amcolash
Copy link
Owner

amcolash commented Feb 4, 2018

Making a ticket based off of some forum feedback:

nitram: Jan 31, 1:50 PM
Nice work. Do you know if it’d handle two instances - i.e. two google accounts? I can imagine some friendly competition in my house with this!

amcolash: Jan 31, 1:54 PM
I have not played around with multiple instances of a MM module, but I can take a look into it when I get some time this weekend. There are some assumptions that are made right now that prevent multiple instances from accessing different accounts. That being said, I am not sure how much work it would take to do but I am up for at least investigating this.

nitram: Feb 1, 1:27 PM
That’d be awesome! I hope it’s straightforward. Also, I’m using it currently on a pi zero W and had no issues with the authentication process. Cheers.

@amcolash
Copy link
Owner Author

amcolash commented Feb 4, 2018

I was playing around a little bit with having multiple instances of the module and it looks like it should be doable without any real code changes. Note: this method is pretty hackish and is probably not the best solution long-term if more people need this feature.

Follow these steps for each extra module. We will use X in the below instructions to denote the x-th module (i.e. use 2 for your 2nd module)

$ cd MagicMirror/modules
$ git clone https://github.com/amcolash/MMM-GoogleFit.git MMM-GoogleFitX, change X accordingly.

Add this to your config/config.js file, change number if needed.

{
    module: 'MMM-GoogleFitX',
    position: 'position',
    config: {
        // If desired
    }
},

Rename MagicMirror/modules/MMM-GoogleFitX/MMM-GoogleFit.js to MagicMirror/modules/MMM-GoogleFitX/MMM-GoogleFitX.js and change line 3 from:
Module.register("MMM-GoogleFit", {
to
Module.register("MMM-GoogleFitX", {

That should get you up and running with a 2/3/4/etc instance of the module.

Note: Each version of the module needs to be updated separately. Therefore to update, you will need to do:
$ cd MagicMirror/modules/MMM-GoogleFit
$ git pull
$ cd MagicMirror/modules/MMM-GoogleFit2
$ git pull
etc.

@amcolash
Copy link
Owner Author

amcolash commented Feb 6, 2018

Got a nice response from nitram 😀

nitram: Feb 5, 5:56 PM
@amcolash Amazing!! Thanks so much. This all worked perfectly for me, with the exception that I also needed to rename the MMM-GoogleFit.js file in the second instance’s directory to MMM-GoogleFit2.js - nothing happened otherwise. I also took the opportunity to change the innerhtml content in that file to something more distinctive for each instance and now we can all see our steps. Super happy with this - even the wife thinks its good now!

I am closing out this ticket for now and will revisit if there is more interest.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant