Read the statement by Michael Teeuw here.
MMM-compliment showing evening compliment anytime
-
@sdetweil
Here’s :){ "anytime": [ "Comment ça va ?", "Bonjour" ], "morning": [ "Un petit café ?", "Bien dormi ?", "Bonne journée !" ], "evening": [ "Bonne soirée !", "Bonne nuit...", "Agréable soirée" ], "day_sunny": [ "Le temps est ensoleillé aujourd'hui !", "C'est une belle journée" ], "day_cloudy": [ "C'est nuageux aujourd'hui..." ], "snow": [ "Bataille de boules de neige !!!" ], "rain": [ "N'oublie pas ton parapluie...", "Et si on restait au sec aujourd'hui ?" ] }
With " as indicated on the readme when using remote file.
But, i had the problem before using remote file, i’ve do this hoping this would resolve the problem, but it’s dont.Is it possible to “remove/reinstall” default module like compliments ?
-
@selyjohns said in MMM-compliment showing evening compliment anytime:
Is it possible to “remove/reinstall” default module like compliments ?
no, but u can get the original code back (which you shouldn’t have changed)
do
cd ~/MagicMirror
check for changed files
git status
if the compliments module has anything is listed as modified
git checkout modules/default/compliments/compliments.js (or whatever filename
-
@sdetweil ok, looking at the code again, duh
it takes the time period AND the anytime, mashes them together and then randomly picks one of the list
so, if u don’t want ‘anytime’ , then remove it… or understand it will happen ‘anytime’
-
@sdetweil Thank you for your time :)
The problem doesn’t concern “anytime” values, but “evening”.
Anytime is anytime and it’s normal that compliment in this section can be displayed at anytime…:)Compliments define in “evening” are displayed all the day, not only on the evening. This is my problem. The MM showing evening compliment at anytime…
With my exemple, the MM display “Bonne soirée” or “Bonne nuit…”, also the morning, or afternon. Like this compliment was positionned in “anytime”
-
@selyjohns I copied your compliments to my config, and do not see that
the code gets the current system time hour (in 24 hour format)
and only uses the evening list if neither morning nor afternoon ranges include the current hour (all OTHER time)
then adds anytime if specified to that list
then adds weather related if specified
then picks one
-
@sdetweil
Ok, thank you for your test.
So maybe a problem on my system time. However it seem to be correct. Another solution to verify that ? (Other than timedatectl ?)Is it possible to have verbose log to see the how the module decide to display compliment ?
-
@selyjohns there is no debug on how it decided, but you could walk thru the code.
open the developers window ctrl-shift-i and select the source tab, and navigate the left lane to modules , default, compliments, compliments.js
the code will appear in the right pane
scroll down to
let compliments;
the next line of code is using the hour
to test if in between morning, then afternoon
the the else for evening of someclick the number in the left column, turns blue
hit F5 to reload the page. will stop there
you can hover the mouse over variables to examine their value
blue arrow upper right to run , or circle be t to step one instruction
-
@sdetweil Hi,
Ok great.
I be able to see the value of hour variable.
It seem to be correct because it’s 17.Condition of morning not verified.
Condition of afternoon verified, so the line is executed (because 17 is between 12 and 18)compliments = this.config.compliments.afternoon.slice(0);
I don’t know why evening compliments are displayed…it’s very strange
-
@selyjohns there are a few more lines of code to step thru…
when it gets to the return compliments u can go er over compliments and then expand the array to see what is in there
-
@sdetweil Yes ! Problem found…
Step by step, i’ve understandif (hour >= this.config.morningStartTime && hour < this.config.morningEndTime && this.config.compliments.hasOwnProperty("morning")) { compliments = this.config.compliments.morning.slice(0); } else if (hour >= this.config.afternoonStartTime && hour < this.config.afternoonEndTime && this.config.compliments.hasOwnProperty("afternoon")) { compliments = this.config.compliments.afternoon.slice(0); } else if (this.config.compliments.hasOwnProperty("evening")) { compliments = this.config.compliments.evening.slice(0); }
The JS need to have a “morning” and “afternoon” compliments define, else it choosing “evening” by default if define.
My problem was i don’t had afternoon compliment define…but i’ve evening one.
Thank you very much for your time and your time :) It was very helpful.