MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. maxfarrior
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    M
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 3
    • Groups 0

    maxfarrior

    @maxfarrior

    3
    Reputation
    459
    Profile views
    3
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    maxfarrior Unfollow Follow

    Best posts made by maxfarrior

    • Compliments module stops cycling compliments

      Alright, my problem is that over a short period of time (5-10 updates) the default Compliments module will stop changing compliments. It simply displays the same compliment endlessly.

      I decided to dig into the issue. I will spare you the troubleshooting process, but I found out that the Compliments module will append the ‘anytime’ compliment to the end of the existing compliments array. So the compliments array gets longer every time it is updated.

      The ‘anytime’ compliments are appended to the end of the compliments array, which grows the array indefinitely. The random compliment function works as intended, but if the compliments array has 10 ‘anytime’ compliments and 3 ‘afternoon’ compliments, there’s a high chance that a ‘anytime’ compliment will be chosen. The odds that an ‘anytime’ compliment will be chosen goes up every update.

      Specifically, I’ve found the issue to occur right when the compliments array is filled with compliments. What happens (in my case) is that the compliments that get added to the compliments array already includes the ‘anytime’ compliments. Then, a few lines later, the ‘anytime’ compliments are appended to the end of the now-filled compliments array.

      Why this happens is not clear to me at all. Looking at the code, the ‘afternoon’ compliments should be added to the compliments array, then the anytime compliments should be appended. The compliments array is initially set to null, and that works, but for some reason, when the ‘afternoon’ compliments are assigned to the compliments array, the anytime compliments are included. Again, this does not make sense. (It shouldn’t be doing that)

      To illustrate what I am talking about, add the following lines right after the if-then-else loop that sets the compliments array.

      Log.info("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
      Log.info("COMPLIMENTS FROM FILE (afternoon):  " + this.config.compliments.afternoon);
      Log.info("~~~~");
      Log.info("COMPLIMENTS STORED IN COMPLIMENTS VARIABLE " + compliments);
      

      Make sure you change ‘afternoon’ to whatever time of day it currently is. Then run `npm start dev’ and watch the console on the right side of the screen.

      What I saw (in the dev console) was that this.config.compliments.afternoon displayed the correct compliments defined by the defaults or whatever external file I specified. However, the compliments array would somehow have the ‘anytime’ compliments in it. Every time the program updated the compliments array, there would be one more set of ‘anytime’ compliments at the end.

      Using the same method of displaying the array at different points of program, I found out that the compliments array is being set to null initially. I can’t for the life of me figure out why the ‘anytime’ compliments would get in there.

      To eliminate even more variables, I renamed my ~/MagicMirror directory and downloaded and installed a new one. I put the lines above in the compliments.js file and I observed the same behavior.

      Hopefully, I explained this issue well enough that other people can understand. I also hope that this is a simple fix or mistake on my end. I would be glad to provide any extra info that might be needed. Thank you for any assistance.

      posted in Troubleshooting
      M
      maxfarrior

    Latest posts made by maxfarrior

    • RE: Compliments module stops cycling compliments

      Alright I will switch to the develop branch.

      Very interesting. I’m glad the issue got resolved!

      posted in Troubleshooting
      M
      maxfarrior
    • RE: Compliments module stops cycling compliments

      Awesome! Your explanation makes sense and I’m glad you were able to understand what I was saying and then make a fix.

      First, can I go ahead and copy your fix into my code? I don’t see why not, but I thought I’d ask.

      Second, am I really the first person to notice this? I feel like the behavior is pretty noticeable.

      posted in Troubleshooting
      M
      maxfarrior
    • Compliments module stops cycling compliments

      Alright, my problem is that over a short period of time (5-10 updates) the default Compliments module will stop changing compliments. It simply displays the same compliment endlessly.

      I decided to dig into the issue. I will spare you the troubleshooting process, but I found out that the Compliments module will append the ‘anytime’ compliment to the end of the existing compliments array. So the compliments array gets longer every time it is updated.

      The ‘anytime’ compliments are appended to the end of the compliments array, which grows the array indefinitely. The random compliment function works as intended, but if the compliments array has 10 ‘anytime’ compliments and 3 ‘afternoon’ compliments, there’s a high chance that a ‘anytime’ compliment will be chosen. The odds that an ‘anytime’ compliment will be chosen goes up every update.

      Specifically, I’ve found the issue to occur right when the compliments array is filled with compliments. What happens (in my case) is that the compliments that get added to the compliments array already includes the ‘anytime’ compliments. Then, a few lines later, the ‘anytime’ compliments are appended to the end of the now-filled compliments array.

      Why this happens is not clear to me at all. Looking at the code, the ‘afternoon’ compliments should be added to the compliments array, then the anytime compliments should be appended. The compliments array is initially set to null, and that works, but for some reason, when the ‘afternoon’ compliments are assigned to the compliments array, the anytime compliments are included. Again, this does not make sense. (It shouldn’t be doing that)

      To illustrate what I am talking about, add the following lines right after the if-then-else loop that sets the compliments array.

      Log.info("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
      Log.info("COMPLIMENTS FROM FILE (afternoon):  " + this.config.compliments.afternoon);
      Log.info("~~~~");
      Log.info("COMPLIMENTS STORED IN COMPLIMENTS VARIABLE " + compliments);
      

      Make sure you change ‘afternoon’ to whatever time of day it currently is. Then run `npm start dev’ and watch the console on the right side of the screen.

      What I saw (in the dev console) was that this.config.compliments.afternoon displayed the correct compliments defined by the defaults or whatever external file I specified. However, the compliments array would somehow have the ‘anytime’ compliments in it. Every time the program updated the compliments array, there would be one more set of ‘anytime’ compliments at the end.

      Using the same method of displaying the array at different points of program, I found out that the compliments array is being set to null initially. I can’t for the life of me figure out why the ‘anytime’ compliments would get in there.

      To eliminate even more variables, I renamed my ~/MagicMirror directory and downloaded and installed a new one. I put the lines above in the compliments.js file and I observed the same behavior.

      Hopefully, I explained this issue well enough that other people can understand. I also hope that this is a simple fix or mistake on my end. I would be glad to provide any extra info that might be needed. Thank you for any assistance.

      posted in Troubleshooting
      M
      maxfarrior