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.

    Limit API calls by deactivating the modul based on time?

    Scheduled Pinned Locked Moved Unsolved Troubleshooting
    13 Posts 3 Posters 419 Views 3 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.
    • K
      Kastore
      last edited by

      Hey everyone,

      I got the MM-TomTomCalculateRouteTraffic module and it is making calls with a TomTom API - now i would like to have really high amount of calls in the morning (about once every 30s) and non after a certain time.

      Is it possible to config a module to be deactivated after a certain time? e.g. run it from 7-8am and then not?

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

        @Kastore MMM-ModuleScheduler can show/hide based on a schedule…

        when hidden modules should stop accessing apis… many don’t…
        this module does not…

        One could add a couple small routines to support this, every module is different in what they need to do… stop timers, start timers, …

        suspend()
        https://docs.magicmirror.builders/module-development/core-module-file.html#suspend

        and resume()
        https://docs.magicmirror.builders/module-development/core-module-file.html#resume

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        K 1 Reply Last reply
        Reply Quote 0
        • K
          Kastore @sdetweil
          last edited by

          @sdetweil
          Okay that makes sense to stop and resume them but i am guessing i would need to somehow code the hide and show into the module as well.
          Since i got no clue on coding i am not sure if that will help me unforunately

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

            @Kastore hide and show are MagicMirror functions
            suspend and resume are the functions the module needs to implement

            MMM-ModuleScheduler calls the MagicMirror hide/show

            You can try it now, but this module will keep making api requests while hidden.

            Maybe you could open an issue on the module GitHub to engage the author to add those routines

            Sam

            How to add modules

            learning how to use browser developers window for css changes

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

              I submitted a pull request to the original repo

              you can try my fork in the meantime

              stop mm
              cd ~/MagicMirror/modules
              -rename the existing module folder to some other name
              git clone https://github.com/sdetweil/MMM-TomTomCalculateRouteTraffic
              cd MMM-TomTomCalculateRouteTraffic
              git checkout withsuspend
              

              then restart mm
              then if you use ModuleScheduler or pages, carousel, or other modules that support hiding and showing you could validate that no api calls are made during the hidden time

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              K 1 Reply Last reply
              Reply Quote 1
              • K
                Kastore @sdetweil
                last edited by

                @sdetweil Awefully sorry for not replying till now - didnt see the message about a new reply.

                Thanks alot for adjusting the module!

                S K 2 Replies Last reply
                Reply Quote 0
                • S
                  sdetweil @Kastore
                  last edited by

                  @Kastore did it make a difference?

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  K 1 Reply Last reply
                  Reply Quote 1
                  • K
                    Kastore @sdetweil
                    last edited by

                    @sdetweil i am setting it up today and will run some tests. Will get back to you asap :)

                    1 Reply Last reply
                    Reply Quote 0
                    • K
                      Kastore @Kastore
                      last edited by

                      i got the modules via the comands you send, however the “git checkout withsuspend” comes back with

                      “error: pathspec ‘withsuspend’ did not match any file(s) known to git”

                      mumblebajM 1 Reply Last reply
                      Reply Quote 0
                      • mumblebajM
                        mumblebaj Module Developer @Kastore
                        last edited by

                        @Kastore You have to be in the module directory when you run git checkout withsuspend, so you do

                        git clone https://github.com/sdetweil/MMM-TomTomCalculateRouteTraffic

                        then run
                        cd MMM-TomTomCalculateRouteTraffic

                        then
                        git checkout withsuspend

                        Check out my modules at: https://github.com/mumblebaj?tab=repositories
                        Check my blog-post: https://mumblebaj.xyz/
                        Check my MM Container: https://hub.docker.com/repository/docker/mumblebaj/magicmirror/general

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

                          @mumblebaj Yes, I see I left out the cd into the module folder, instructions corrected

                          Sam

                          How to add modules

                          learning how to use browser developers window for css changes

                          K 1 Reply Last reply
                          Reply Quote 0
                          • K
                            Kastore @sdetweil
                            last edited by Kastore

                            @sdetweil @mumblebaj
                            Thanks to both of you. i used the command in the cd and it works.

                            Just as a question: how am i able to adjust from when to when the module gets suspendend?

                            i found the coding but not sure how i enter the values in the config file

                            suspend: function() {
                            		clearInterval(this.timerHandle)
                            		this.timerHandle = null
                            	},
                            
                            	resume: function() {
                            		this.startTimer()
                            	}
                            

                            Also - do i need aditional modules for the suspend / resume feature?

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

                              @Kastore yes, you need MMM-ModuleScheduler

                              Sam

                              How to add modules

                              learning how to use browser developers window for css changes

                              1 Reply Last reply
                              Reply Quote 0

                              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                              With your input, this post could be even better 💗

                              Register Login
                              • 1 / 1
                              • 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