Read the statement by Michael Teeuw here.
Limit API calls by deactivating the modul based on time?
-
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?
-
@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#suspendand resume()
https://docs.magicmirror.builders/module-development/core-module-file.html#resume -
@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 -
@Kastore hide and show are MagicMirror functions
suspend and resume are the functions the module needs to implementMMM-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
-
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 withsuspendthen 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 -
@sdetweil Awefully sorry for not replying till now - didnt see the message about a new reply.
Thanks alot for adjusting the module!
-
@Kastore did it make a difference?
-
@sdetweil i am setting it up today and will run some tests. Will get back to you asap :)
-
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”
-
@Kastore You have to be in the module directory when you run
git checkout withsuspend, so you dogit clone https://github.com/sdetweil/MMM-TomTomCalculateRouteTrafficthen run
cd MMM-TomTomCalculateRouteTrafficthen
git checkout withsuspend -
@mumblebaj Yes, I see I left out the cd into the module folder, instructions corrected
-
@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?
-
@Kastore yes, you need MMM-ModuleScheduler
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