A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.
  • include npm module like firebase module into our own MM module

    9
    0 Votes
    9 Posts
    2k Views
    K

    @sean ok will try it out later =)

  • Learning Node.js

    2
    0 Votes
    2 Posts
    1k Views
    Mykle1M

    @timcadieux said in Learning Node.js:

    will I be able to do the development on my Windows PC (vs 2017) and merely copy it over to my PI

    Yes, you can. I was developing under Windows. I know some others that still do. I do my module work in ubuntu now.

  • how to detect main window size via code

    4
    0 Votes
    4 Posts
    1k Views
    S

    @sean said in how to detect main window size via code:

    clientHeight

    thanks… duh, so easy!..

  • can i inject javascript as part of my modules getDom content?

    7
    0 Votes
    7 Posts
    1k Views
    S

    @sdetweil well, that was easy and works great!..

    gotta figure out how to have a div with a fill color to replace the black edges when the pics are not fulls screen.

    also the bottom edge of the pic is clipped by the bottom of the screen somehow… half the newsfeed line is over the clip line

  • Is there any callback for getDom execution ?

    3
    1 Votes
    3 Posts
    1k Views
    ?

    As I know, there is no callback or notification when getDom is executed.
    However, if you want to catch the changing of the output of the specific module, you can use MutationObserverin your module.

  • Raspberry Pi 0w Module Errors

    5
    0 Votes
    5 Posts
    2k Views
    E

    @ninjabreadman++ Thank you again for your reply, I will review the MM on the pi0w with the dir name the same as the Module.register(). That said, if this is truly the issue, wouldn’t the same issue persist when booting up the electron app locally on my mac?

    re loader.js error that appears to be coming from MagicMirror/js/loader.js which appears to be failing to load my MMM-my-module.js file AFAIK

  • Using Unicode Character and symbols in module

    2
    0 Votes
    2 Posts
    1k Views
    A

    Hi to all,

    i found a solution.
    0_1536262932769_lock.JPG

    I use font awesome (which comes with mm anyway) an the following css:

    .fa-lock1:after { content: "\f023"; }

    AxLED

  • Accesing config in node_helper

    3
    0 Votes
    3 Posts
    1k Views
    R

    @sean Yep, thats what i do now. Messaging config around :-) Thanks for clarifying so i can rest assured not to overlock something obvious :-)

  • omxplayer overlay

    19
    0 Votes
    19 Posts
    5k Views
    evroomE

    The MPG2 license I most probably needed in order to be able to stream the satellite TS stream.
    With the codec disabled, I am still able to play the .mov and .mp4 files.

    In general the rule applies: when you can play / stream a source using omxplayer from the command-line, you should be able to play that source via MM (as long as the module used passes the right omxplayer parameters).

    If you want to pursue the issue further, you can add the --genlog parameter in order to generate the omxplayer.log file:

    cd /MagicMirror/modules/MMM-RTSPStream $ vi node_helper.js Edit line 113: args.unshift("--genlog", "--avdict", "rtsp_transport:tcp"); Restart MM. $ ls -als /home/pi/MagicMirror/omxplayer.log

    Perhaps this log will reveal why the file does not play.

  • CSS-help

    5
    0 Votes
    5 Posts
    1k Views
    J

    @cowboysdude
    Thanks! Finally did it!

  • Show notification and hide compliments

    1
    0 Votes
    1 Posts
    1k Views
    D

    In the early days of MagicMirror,
    i got a module, that was able to fetch data from OpenHAB and displays it in place (instead of the compliment section)
    If the string is empty, the comments won’t be hided.

    Is it possible to bring this to the current version of MagicMirror?

    https://raw.githubusercontent.com/Dom1n1c/Smartmirror/master/js/openhab/openhab.js

  • error loop

    11
    0 Votes
    11 Posts
    3k Views
    ?

    @jchenaud
    MODULE_DOM_CREATED is not so good time. Because, It would be emitted when Your DOM was created, but All of other DOMs are not rendered yet. DOM_OBJECTS_CREATED is better.
    If you want to using position, use .getDom(). A usual way to use position is, in .getDom() to initialize your rendering and to prepare the framework to draw.
    And you can choose one of drawing tricks.

    getDom() shall take care of all the drawing. in .getDom() put all of your rendering framework and contents. and you can refresh your render by calling .updateDom()

    getDom() shall draw only framework, Contents should be drawn by your another function with HTML DOM manipulation.

    or getDom() just return empty wrapper, Then, all of your rendering and refreshing will be performed by yourself.

    Which is better? case-by-case.

    For the last question; I cannot figure out. :)

  • Convert existing javascript code to magic mirror module

    Moved
    2
    0 Votes
    2 Posts
    984 Views
    S

    what does it do? I just ported over my pure node/angular/javascript code to mm…

    took some thinking about how to separate the existing code to fit the MM execution model…

    in general on MM you supply fragments of a page to be shown in some location on the MM page… you can also do a whole page in an iframe…

  • This topic is deleted!

    1
    0 Votes
    1 Posts
    14 Views
  • Help with converting this HTML file to MM2 module format...

    4
    0 Votes
    4 Posts
    1k Views
    D

    I’d put them in a different structure, perhaps, depending on what you want to achieve.

    If it’s just this list that you want: Remove all line breaks and tabs, lead all quotation marks with a backslash (\") and put that complete one line of code in:

    targetElement.innerHTML = "your Code here";

    More flexible:

    var newsSources = [
    {
    “id”:“washington_post”,
    “name”:“Washington Post”,
    “alt”:“Washington Post”,
    “link”:“https://www.washingtonpost.com/?reload=true”
    },
    {
    “id”:“usa_today”,
    “name”:“USA Today”,
    “alt”:“USA Today”,
    “link”:“http://rssfeeds.usatoday.com/UsatodaycomNation-TopStories”
    },
    {
    “id”:“irish_news”,
    “name”:“Irish News”,
    “alt”:“Irish News”,
    “link”:“http://www.irishnews.com/news/worldnews/”
    },
    {
    “id”:“wall_street_journal”,
    “name”:“Wall St. Journal”,
    “alt”:“Wall St. Journal”,
    “link”:“https://www.wsj.com/news/us”
    },
    {
    “id”:“kansas_city_star”,
    “name”:“The Kansas City Star”,
    “alt”:“Kansas City, MO News”,
    “link”:“https://www.kansascity.com/news/”
    },
    {
    “id”:“bbc_news”,
    “name”:“BBC World News”,
    “alt”:“BBC World News”,
    “link”:“https://www.bbc.com/news/world”
    }
    ];
    newMainElement = document.createElement(“div”);
    newMainHeadline = document.createElement(“h2”);
    newMainHeadline.innerHTML = “< img src=“pix/break_news.png” alt=“Breaking News” />”;
    newMainElement.apply(newMainHeadline);
    frstWrapper = document.createElement(“div”);
    scndWrapper = document.createElement(“div”); // really neccessary?
    thrdWrapper = document.createElement(“div”); // really neccessary?
    newsList = document.createElement(“ul”);
    for (i=0; i< =newsSources.length; i++) {
    newsItem = document.createElement(“li”);
    newsLogo = document.createElement(“div”);
    newsLogo.innerHTML = “< img src=“pix”+newsSources[i].id+”.png" alt=“”+newsSources[i].alt+“” />"
    newsLink = document.createElement(“h3”);
    newsLink.innerHTML = “< a href=”“+newsSources[i].link+”" target=“myIframe”>“+newsSources[i].name+”";
    newsItem.apply(newsLogo);
    newsItem.apply(newsLink);
    newsList.apply(newsItem);
    }
    thrdWrapper.apply(newsList); // really neccessary? see above
    scndWrapper.apply(thrdWrapper); // really neccessary? see above
    frstWrapper.apply(scndWrapper);
    newMainElement.apply(frstWrapper);

    I didn’t use the code block because it can’t handle \".
    In < img and < a you have to remove the space.
    id = image name, you’ll have to adapt a little, I wrote them in a more uniform style.
    alt = could be the same as the name, but I put it in as you varied a little with your alt titles.

    Oh, by the way:
    Seems like this could also be a good case for a template system.
    https://forum.magicmirror.builders/topic/2443/html-templating-system
    https://forum.magicmirror.builders/topic/5053/better-way-to-use-html-in-module-development

  • Real Time ECG

    3
    0 Votes
    3 Posts
    1k Views
    D

    For anything involving a graph drawn from JS(ON) data, I can only recommend highcharts.

    It’s possible to display dynamic graphs from live data. Example: https://www.highcharts.com/stock/demo/dynamic-update/
    https://www.highcharts.com/docs/working-with-data/live-data

    Your python code could provide a JSON and the MM-module calls the JSON and prints the graph.

    I’ve used highcharts before but never dynamically like in the example above.
    Here’s an example where I used it in a module: https://github.com/TTigges/MMM-Oiltank/blob/master/MMM-Oiltank.js

  • help developing an outofmilk.com module

    8
    0 Votes
    8 Posts
    2k Views
    D

    Uh, interesting topic. I like API calls. :D Back when I started, my main issue was understanding the node_helper.js – and that it was neccessary.
    I’m still struggling to make sense of your token complexity. Apart from that, your files would be something like this:

    MMM-OutOfMilk.js:

    Module.register("MMM-OutOfMilk",{ defaults: { // your defaults }, start: function() { var payload = "start"; // example this.sendSocketNotification("GetMyShoppingList", payload); }, socketNotificationReceived: function(notification, shoppingList) { if (notification === "ShoppingListRecieved") { this.handeShoppingList(shoppingList); } }, handleShoppingList: function(shoppingList) { // do something with your shopping list } }

    node_helper.js:

    var NodeHelper = require("node_helper"); var request = require("request"); // needed? see below var fs = require("fs"); // needed? see below var timer = 0; // needed? see below "I added a timer" var token; module.exports = NodeHelper.create({ start: function() { }, socketNotificationReceived: function(notification, payload) { if (notification === "GetMyShoppingList") { // start the logic to recieve the shopping list // get token? // make call this.getShoppingList(payload); } }, getToken: function(payload) { // however you get your token getShoppingList(payload); }, getShoppingList: function(payload) { var self = this; var source = ; // your source URL if (token) { request({ url: source, json: true }, function (error, response, body) { if (!error && response.statusCode === 200) { self.sendSocketNotification("ShoppingListRecieved", body); } else { // check error if it's a token issue // if so, get new token self.getToken(payload); } }) } } }

    From another project I know that sometimes a token can be used for a while. In that case I’d directly call the getShoppingList and only on an error that read “wrong token” or something like that, I’d call getToken which saves the token to a global variable and calls back getShoppingList to try again. That way you don’t have to get a new token for every call.

    Alternatively?

    getShoppingList: function(token) { var self = this; var source = ; // your source URL var rawdata = fs.readFileSync(source); var history = JSON.parse(rawdata); self.sendSocketNotification("ShoppingListRecieved", history); }

    I’d also use a timer to request data on the first call and after that automatically only every full hour:
    So, in the node_helper.js, in the socketNotificationReceived I don’t forward the payload to this.updateTimer(payload) instead of getToken or getShoppingList to do this:

    updateTimer: function(payload) { var self = this; var d = new Date(); var h = d.getHours(); var min = d.getMinutes(); var sec = d.getSeconds(); if (timer === 0) { timer ++; // prevent unnecessary timer by double calls this.getShoppingList(payload); if((min == '00') && (sec == '00')){ // console.log(h + ":" + min + ":" + sec + " - update and wait 1 hour"); // console.log("restart timer"); setTimeout(() => { this.clearTimer(payload); }, 60*1000*60); // 60 sec * 1000 ms = 1 min * 60 = 1 hour } else { // console.log(h + ":" + min + ":" + sec + " - update waits for " + (59-min) + " min and " + (60-sec) + "sec"); // console.log("restart timer"); setTimeout(() => { this.clearTimer(payload); }, ((60-sec)*1000)+(60*1000*(59-min))); } } else { // console.log("timer already running, data displayed outside of timer run"); this.getShoppingList(payload); } }, clearTimer: function(payload) { timer --; this.updateTimer(payload); }

    For one of my modules I couldn’t use fs.readFile... or request because of CORS issues. In that case I had to use a php proxy.
    I’d strongly suggest trying to solve this with fs.readFile... or request but just for the sake of completeness and maybe to help you understand:

    In order to use PHP within nodeJS via Child Process Dependency you have to have PHP installed and in your PATH!
    You can read how I used it, here: https://forum.magicmirror.builders/topic/5830/call-api-no-cors-used-to-do-it-with-php-proxy/9

  • Gurus, what is the problem with this code ?

    10
    0 Votes
    10 Posts
    2k Views
    ?

    @rsellmer
    one more thing;
    config.js is validated when MM is booted up, not rendered. maybe you can put some codes in config.js but that would not be working as your expectation.

  • MagicMirror to msSQL

    8
    0 Votes
    8 Posts
    3k Views
    rsellmerR

    Hi, I’ve sent an e-mail to you because I am new in MM and I need to do something like yours.
    Please, help me.
    Tks,
    Renato

  • Calling a general function

    3
    0 Votes
    3 Posts
    980 Views
    ?

    @rsellmer I’m not sure, but you seem to use jQuery. but jQuery is not included by default. You should include jQuery into your module.