Read the statement by Michael Teeuw here.
remoteFile in compliments module
-
@Lahim said in remoteFile in compliments module:
Does compliments.json file has to be somehow written as json file?
Uhh, it MUST be saved as a .json file. It’s in the README file of compliments module.
QUOTE:
“This file must be straight JSON. Note that the array names need quotes around them (“morning”, “afternoon”, “evening”, “snow”, “rain”, etc.).”I don’t use nano if I don’t have to. I use notepad++. You don’t need the terminal to use it and it saves files in just about every file format imaginable, including JSON.
I will post my file in a moment
-
You MUST save this as a json file.
{ "anytime" : [ "You look like I need a drink!", "Did Pop create the Matrix?", "Why are you looking at yourself?", "That gut must be embarrassing!", "There's a zit on your forehead!", "You're fugging ugly!" ], "morning" : [ "Good morning, Pop!", "How's that dream job?", "You look like shit!", "Enjoy your day!", "Don't work too hard!" ], "afternoon" : [ "When my Bottle Pop?", "Move your fat ass today!", "Take a nap!", "Cowboysdude is a GURU!", "Is the pool open yet?", "You are not appreciated!", "You need a shave!" ], "evening" : [ "Strawberry 3.141 Rocks!", "What the hell are you?", "You're one ugly mother fucker!", "Pop is a fucking genius!", "You look fat in that dress!", "Did someone mention SEX?" ] }
-
compliments.js_original
So, you did change something in the module file? That is not recommended and it makes it very difficult for me or anyone else to troubleshoot for you
-
I tried to change
remoteFile: null,
for remoteFile: ‘compliments.json’ previously but, as you know, did not help.
Now I came back to the oryginal file, saved your compliments as json file in Notepad++ as you wrote, and…
IT IS WORKING!!!Thank you so much!!!
F…ck, so many time I spent tring different solutions and finaly it works.
One more time thank you for attention and help!
The module - great job!! -
Ok, I found where was the problem and where is the problem now.
Because I am using Pi0 with Midori, with oryginal file the compliments were not show on the mirror but I was able to see them thru LAN.
So I found the solution to change:if (this.config.remoteFile != null) { this.complimentFile((response) => { this.config.compliments = JSON.parse(response); }); }
to:
if (this.config.remoteFile != null) { this.complimentFile( function(response){ this.config.compliments = JSON.parse(response); }); }
and yes, that make my compliments shown on mirror but in same time the text is only from
compliments.js
file.
So now, to see the compliments I have to copy own text to .js file :(That is the problem.
-
@Lahim said in remoteFile in compliments module:
IT IS WORKING!!!
Thank you so much!!!Fantastic! You’re welcome. :-)
-
Will you be able to find the solution to the problem I described above?
-
@Lahim because you changed the context by removing the arrow function, to preserve the context you have to do something like:
if (this.config.remoteFile != null) { var self = this; this.complimentFile(function(response){ self.config.compliments = JSON.parse(response); }); }
-
I found it in the meantime but now I tested it - yes, it works!!!
Thank you! -
has anyone tried to get the compliments in an file on a external Server?