A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.
  • Long running tasks - json parsing from url

    3
    0 Votes
    3 Posts
    1k Views
    C

    Thank you for the direction. It would seem that after a full day of mucking about, I have finally got it. Horray!
    Emby Media Server now has a place on my mirror.

    I’ll have to go tell the guys over there about. I have a feeling this Magic Mirror might catch on over there, especially now that there will be an official Emby plugin for it.

    Thank you again @E3V3A for taking the time to show some direction.

    Chef

  • Reverse Lookup MMM-FRITZ-Box-Callmonitor - help needed

    16
    0 Votes
    16 Posts
    6k Views
    A

    Hi pinsdorf,

    thanks for your reply, here are some answers to your questions:

    putting the lookup in a own module.
    => Feel free, you just have to tell me, how i can grant write permissions to you (maybe via PN) i closed my own pull request, as i didnt find any other option

    Maybe you can also help in fixing this issue: https://github.com/paviro/MMM-FRITZ-Box-Callmonitor/issues/30

    Regards

    AxLED

  • Custom module to run python script

    4
    1 Votes
    4 Posts
    3k Views
    strawberry 3.141S

    @Sputnik the facerecognition moduel of @paviro makes also heavy use of python scripts, take a look here https://github.com/paviro/MMM-Facial-Recognition/blob/master/node_helper.js

  • What other factors are affecting the updateInterval?

    8
    0 Votes
    8 Posts
    2k Views
    E

    @strawberry-3.141 Thanks a lot! PR merged.

  • MMM-Domoticz : update time ?

    11
    0 Votes
    11 Posts
    9k Views
    Y

    After 6 days, It works perfectly. Thanks you guys !

    To summarize you have to :

    Change line 56 from this.scheduleUpdate(this.config.initialLoadDelay);

    to

    this.scheduleUpdate(this.config.updateInterval) Change line 169 from setTimeout(function() {

    to

    setInterval(function() { Optionnal, you can adjust timers at lines 13, 14 and 19

    Have fun :-)

  • Why are people doing this: var self = this?

    5
    0 Votes
    5 Posts
    2k Views
    E

    @ninjabreadman Great Find! Exactly what I needed. That it seem a great lesson on this.

    In the reference…

    To fix the problem with using this inside the anonymous function passed to the "forEach" method, we use a common practice in JavaScript and set the this value to another variable before we enter the "forEach" method.
  • 0 Votes
    13 Posts
    4k Views
    E

    The module is now working and alive!! Thank you all for all your patience!!

  • module develop help!

    11
    0 Votes
    11 Posts
    5k Views
    E

    Did you ever get your module to work?

  • How to best process an [object Promise]?

    9
    0 Votes
    9 Posts
    3k Views
    E

    I’ve got a partially working function, but it’s a bit funny. For some reason the call to cleanup the JSON is not liked, because it seem that the actual result is not returned, but the Promise .

    This is the code snippet:

    radarPing: function() { console.log("ENTER (inside)"); Promise.all([ radar(-8.20917,114.62177,-9.28715,115.71243) ]).then(function(results) { var ping = results; console.log("PING1:"); console.log(ping); var cleanData = jZen(ping); console.log("PING2: ", cleanData); self.sendSocketNotification("NEW_DATA", ping); //"PING" return cleanData; //ping; }); console.log("EXIT (inside)"); }, readData: function() { //const myfile = 'modules/MMM-FlightsAbove/demo.json'; // The demo API use improper JSON var radarData = ""; radarData = this.radarPing(); console.log("The DATA:\n", radarData); /* if ( radarData === "" ) { } */ //let cleanData = jZen(data); //let cleanData = jZen(radarData); let cleanData = radarData; if (isJSON(cleanData) ) { this.sendSocketNotification("NEW_DATA", cleanData); } else { // So WTF is it? console.log("- JSON: false"); console.log("- isAO(dirty): " + isAO(radarData)); console.log("- isAO(clean): " + isAO(cleanData)); console.log("- Data:\n", radarData); } }, ... }); // To check if something is JSON function isJSON(str) { try { return (JSON.parse(str) && !!str); } catch (e) { return false; } } // To check if something is an Array or Object (parsed JSON) function isAO(val) { return val instanceof Array || val instanceof Object ? true : false; } // -------------------------------------------------------------------------- // What: A dirt simple JSON cleanup function that also compactifies the data // NOTE: - Only use on flat and trustworthy ASCII JSON data! // - Cannot handle any characters outside [A-Za-z0-9_\-]. (e.g. UTF-8) // - Using remote data without further sanitation is a security risk! // -------------------------------------------------------------------------- const re1 = /([A-Za-z0-9_\-]+):/gm; // use const to make sure it is compiled function jZen(juice) { //let re1 = /([A-Za-z0-9_\-]+):/gm; // Find all ASCII words $1 before an ":" //let data = juice; let str = ""; str = juice.replace(/\s/gm, ''); // Remove all white-space str = str.replace(/\'/gm, '\"'); // Replace all ' with " str = str.replace(re1, '\"$1\":'); // Replace $1: with "$1": //console.log("Dirty JSON is:\n" + data.toString() ); //console.log("Clean JSON is:\n" + str); return str; }

    The output is:

    ... ENTER (inside) EXIT (inside) The DATA: undefined - JSON: false - isAO(dirty): false - isAO(clean): false - Data: undefined PING1: [ [ { id: '108be389', timestamp: 1519647028, registration: 'PK-GQL', flight: 'QG8816', callsign: 'CTV8816', ...

    As you can see, PING2 never happens…

  • How to pass a value between functions in a Module?

    5
    0 Votes
    5 Posts
    2k Views
    D

    getDom: function() is called initially to set up the content. Usually you have something like div.innerHTML = variable; but at the beginning, varibable might be empty. To make the variable usable globally (in the scope of your module), you set it up and call it as this.variable.

    When your function that fills this variable updates that variable content, you call updateDom();
    That makes the dom reload and this time, this.variable has content to show.

    There’s other ways to fill the element with the content of a variable without totally rebuilding the DOM:
    In the function that handles the variable, you could say document.getElementbyId(elementId).innerHTML = variable;

    Edit: To complete this. If you want to pass a value from one function to another (but this is not working for the Dom, because that has to be set up initially):

    firstFunction: function () { var greeting: "Hello"; secondFunction(greeting); } secondFunction: function (word) { var greeting: word; Log.info(greeting); // "Hello" }
  • 0 Votes
    2 Posts
    1k Views
    goonerbeatyaaG

    search the forum for " how-to-add-modules-for-absolute-beginners "

  • I got sucked up into a magic mirror! (and need some help)

    14
    0 Votes
    14 Posts
    5k Views
    E

    @raywo It’s now working and I’ve pushed all updates to repo. :)
    My first module…that does nothing. :D

  • Creating a module with existing Nodejs client?

    3
    0 Votes
    3 Posts
    1k Views
    B

    @ninjabreadman Thanks for the explanation!!

  • What is the difference between require() and getScripts()?

    7
    0 Votes
    7 Posts
    3k Views
    Mykle1M

    @cowboysdude

    Both? ;-)

  • What is the difference between these function definitions?

    3
    0 Votes
    3 Posts
    1k Views
    E

    @ninjabreadman Fantastic! Again, the best explanation I’ve heard! I love that juice analogy!

    Thank you so much for having patience with all my dumb questions. Surely a lot of them are trivial to most developers. (If you’re a moderator, feel free to mark this as solved.)

  • What is the startup order in a Module with node_helper.js?

    1
    0 Votes
    1 Posts
    697 Views
    E

    What is the exact startup order of a module?
    What is processed first and how can I learn/understand the process?

  • Adding a jQuery Module

    7
    0 Votes
    7 Posts
    3k Views
    E

    @NiviJah Did you get jQuery to run at all?

  • 0 Votes
    3 Posts
    2k Views
    E

    @ninjabreadman Hi! Thanks, I knew about that, but was hoping to use the default lxterminal, but unfortunately it only allows --geometry=CHARACTERSxLINES as option.

    Your solution of using rxvt-unicode seem pretty good as it supports 256 colors etc. However, in the end, I decided that I’d rather have a native MMM, than just throwing a window on top of everything. That complicates things though. I simply don’t see how to go about implementing the JS version of xterm into a Module. Perhaps something to suggest in the requests area?

    Anyway, could be useful for all those people and command-line junkies, who want to see their raw python output.

  • Weather Forecast - maxNumberOfDays

    2
    0 Votes
    2 Posts
    1k Views
    R
    What count is return when requesting: https://api.openweathermap.org/data/2.5/forecast/daily?id=1234567&APPID=$APPID What is the max count possible: https://api.openweathermap.org/data/2.5/forecast/daily?id=1234567&APPID=$APPID&cnt=$COUNT
  • Module Developer Challenge - I surrender!

    Solved
    33
    0 Votes
    33 Posts
    14k Views
    cowboysdudeC

    @Mykle1 said in Module Developer Challenge - I surrender!:

    @E3V3A said in Module Developer Challenge - I surrender!:

    I’m very impressed with your progress.

    I appreciate that. Frankly, I’m amazed that I’ve gotten any of my modules to work. I joined this forum 13 months ago without the slightest idea of what linux or a raspberry pi even was. I realized quickly enough that I wanted to learn how things worked and started reading and asking questions. With the help of some very nice people I was able to make my first module, MMM-Cocktails. At this point, I was totally hooked. It’s still magic to me and I enjoy every minute of the learning process.

    HEYYYYYYYYYYYYYYYY hands above the desk…ABOVE…LOL