A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.
  • From JSON to display on MM

    Jan 12, 2023, 2:56 AM
    0 Votes
    2 Posts
    382 Views
    @lkthomas said in From JSON to display on MM: which module should I use as an example for JSON iteration? How could I filter the closest timestamp with current time then display it in minute on MM? there is an array filter function you pass in the array, the logic looks at each element one by one… true means keep it in the results, false say don’t keep it. the resulting array is the good subset of the total javascript and json are very close friends. url get request can return a javascript object of the json text … then u can pass the array part (data I think from your sample) to the filter… if you use fetch , you can do this in the browser side of the module, otherwise have to use a helper… https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch fetch('http://example.com/movies.json') .then((response) => response.json()) .then((data) => console.log(data)); data is now a js object of the json text see my sample module for building a starter… https://github.com/sdetweil/SampleModule the browserside of the module (I call it modulename.js, cause its name MUST match the name of the module, and it has to be in a folder called the exact same) creates a small segment of html content (either text or actual DOM nodes) … and gives that to MM when requested (the getDom() function) and MM will put the content where u configured the module to have its content shown. so folder, modulename.js and modulename all match if you do the fetch on a timed cycle, once u have the data, call updateDom() to inform mm your module has new content, then mm will call your getDom() to get the new content. getDom() either creates the content or knows where the previously created content is.
  • Svenskalag.se

    Nov 29, 2022, 3:02 PM
    0 Votes
    5 Posts
    653 Views
    @Henrik nice work
  • ChatGPT is creating Modules

    Dec 13, 2022, 7:54 AM
    1
    1 Votes
    3 Posts
    1k Views
    That is so cool, if it works
  • Widgit accessabililty

    Oct 21, 2022, 6:20 PM
    1 Votes
    6 Posts
    837 Views
    @wishmaster270 I ended up using MMM-EmbedURL and it worked fine for what I was trying to do. Thanks all for your help N6NG DENNIS
  • Hide a module by default

    Oct 29, 2022, 12:08 PM
    0 Votes
    11 Posts
    2k Views
    @BKeyport ah, I see the question… never heard a period called that
  • 0 Votes
    1 Posts
    281 Views
    I created powersaving program for automatically start the RaspberryPi, if a motion ist detected via PIR-sensor and shut down after a waiting time. It’s at Git and I want to share it with you. I would be happy if you give me Feedback. https://github.com/ChrisBaehrig/MM-PIR-motion-poweron
  • 0 Votes
    8 Posts
    545 Views
    @CurlyQ12391 np. I was just trying to help you make progress. I know nothing about the API. but couldnt find anything similar to the code in the helper
  • 0 Votes
    6 Posts
    1k Views
    @FlatPepsi also, something like this might help https://github.com/amcolash/MMM-json-feed put in your url, display data
  • ES6 notation

    Sep 7, 2022, 5:20 PM
    0 Votes
    7 Posts
    947 Views
    @MMRIZE and @sdetweil Thanks guys, Thought I would put the question out there and see what crawls out the woodwork. ;-)
  • Notion Integration

    Unsolved Sep 7, 2022, 8:49 AM
    2
    0 Votes
    2 Posts
    842 Views
    @Amit5001 so, you will need to write a module. mm runs inside a browser, electron, chrome, Firefox, … it displays one web page each module gets data from somewhere and builds a small blob of html, or dom content, and gives that to mm, which places it in the browser DOM in the position you configured the spec is here https://docs.magicmirror.builders/development/introduction.html you can use my SampleModule as a starting place, it’s got all the parts https://github.com/sdetweil/SampleModule something to do before that, is to figure out how u want it displayed and build the html to do that, it’s just text. you can test that output in any browser. a module is split into 2 parts. the part that runs in the browser and does all the display work I call it modulename.js cause it’s filename matches the module name. it’s the part that interfaces to mm but a browser cannot read files (incl database) or touch hardware directly. for security. browser cannot import or require to load libraries. so if u need to do that, you use the helper, called node_helper.js. there is a small communication mechanism between the two parts. modulename.js sends a message, send socket notification and the helper receives them, receiveSocketNotification when done the exact same calls are used in the other direction. helper sends module name.js receives. this is a private channel between this module and it’s helper.
  • 0 Votes
    9 Posts
    978 Views
    @kayakbabe DRAT! I just crushed my microSD with my wheelchair. It is definitely time for bed.
  • 0 Votes
    4 Posts
    2k Views
    @EphraimB you can view and save that as an image. the railroad tracks and terminals are not gonna move today… or anytime soon
  • 0 Votes
    15 Posts
    5k Views
    @sdetweil Works as you wrote. Sadly its not in the documentation.
  • Need help with new Modul "Scare"

    Jun 21, 2022, 3:27 PM
    0 Votes
    8 Posts
    630 Views
    @Rattenjunge8080 So, i found a Solution, if anyone is interested, be my guest to copy this (spaghetti-code! I catch exceptions cause i am not able to check if and how many pictures are already loaded): /* MagicMirror² * Module: Scare * * By Rattenjunge8080 * */ Module.register("Scare", { // Default module config. defaults: { }, start: function(){ //The container which will be shown in DOM this.container = document.createElement("div"); this.visible = true; //set true via resume this.blocker = false; //block multiple DOM-calls image1 = document.createElement("img"); image1.src = '/modules/Scare/img1.jpg'; image1.classList.add("image1"); image2 = document.createElement("img"); image2.src = '/modules/Scare/img2.jpg'; image2.classList.add("image2"); }, // system notification your module is being hidden // typically you would stop doing UI updates (getDom/updateDom) if the module is hidden suspend: function(){ console.log('suspend'); this.visible = false; this.updateDom(1000); //TODO If in future not all pictures are removed->Delete the container: //this.container.remove(); }, // system notification your module is being unhidden/shown // typically you would resume doing UI updates (getDom/updateDom) if the module is shown resume: function(){ console.log('resume'); //TODO If in future not all pictures are removed->add here the container: //this.container = document.createElement("div"); this.visible = true; this.updateDom(); }, /* * Here the first Image will be added to a container, shown on screen * and a timer will count down. Let them feel safe for a while... * then a new image will pop up and a sound is played */ showImageAndPlaySound() { this.blocker = true; //TODO: Maybe useful in future //this.container.innerHTML = "<img src=\"/modules/Scare/OVAL.png\" width=\"200px\" height=\"500px\">"; //Put in picture to let it print on DOM this.container.appendChild(image1); this.updateDom(); console.log("set timeout 10s"); try { setTimeout(() => this.container.removeChild(image1), 10000); }catch (e) {console.log("catch timeout line 70");} setTimeout(() => this.container.appendChild(image2), 10000); this.updateDom(); //Generate the Audio from local file TODO auch mit setTimeout machen var audio = new Audio("/modules/Scare/sound.mp3"); audio.play(); this.blocker = false; }, /* * Here the first Image will be added to a container, shown on screen * and a timer will count down. Let them feel safe for a while... * then a new image will pop up and a sound is played */ getDom: function(){ if(this.visible){ if(this.blocker === false){ this.showImageAndPlaySound(); }else{} }else{ //When the Module is not shown, then remove the 2 Images try { this.container.removeChild(image1); this.container.removeChild(image1); this.container.removeChild(image1); this.container.removeChild(image1); this.container.removeChild(image1); this.container.removeChild(image1); } catch (e) {console.log("catch remove child img 1");} try { this.container.removeChild(image2); this.container.removeChild(image2); this.container.removeChild(image2); this.container.removeChild(image2); this.container.removeChild(image2); this.container.removeChild(image2); }catch (e) {console.log("catch remove child img 2");} } return this.container; } });
  • 0 Votes
    16 Posts
    3k Views
    @jwilson5607 glad u got it working… if I hadn’t done my own chartjs module, I would have had no clue,
  • 0 Votes
    7 Posts
    1k Views
    @bugsounet Thanks a lot for your kind informations.
  • 0 Votes
    3 Posts
    458 Views
    @sdetweil Thanks Sam. Will give that a go.
  • 0 Votes
    2 Posts
    546 Views
    @kylelamb1324 see my sample module it’s node helper receives a message and sends one back https://github.com/sdetweil/SampleModule its string identifying the message and some buffer of data, completely up to you, string, number, structure… then on the receiving side u get the identifier, so you can tell different messages apart and a pointer to the buffer sent by the sender socket notifications are private to your module an example use the node_helper does not get any of the info from config.js like the modulename.js does so, typically the first thing would be to send the this.config buffer to the node_helper
  • Change Folder of Logs of PM2 and NPM

    Apr 9, 2022, 7:20 AM
    0 Votes
    11 Posts
    4k Views
    @thgmirror and there is a $HOME/.npm folder for npm, but I have no idea what all is stored there, and what needs to be persistent and not
  • PIR Sensor doesnt detect movement

    Apr 1, 2022, 12:06 PM
    0 Votes
    10 Posts
    1k Views
    @1BlauNitrox it’s 28 inch lcd monitor. Few years old. Don’t know the model