MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. ninjabreadman
    3. Best
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    N
    Offline
    • Profile
    • Following 0
    • Followers 3
    • Topics 4
    • Posts 201
    • Groups 0

    Posts

    Recent Best Controversial
    • RE: How to update the master branch?

      @PaulB First, make a backup of your install with cp -r ~/MagicMirror ~/MM-Backup. Then run git stash in ~/MagicMirror to temporarily stash your changes so that git can merge all those new commits.

      To merge, run git pull to update your MM install, then use npm install to upgrade or install any new dependencies to the appropriate version.

      Once complete, run git stash apply to reintroduce your changes (while also keeping them in the stash) – you may need to deconflict or otherwise review these changes. You can see your changes with git diff.

      Once you’re happy and MM is running smoothly, you can git stash drop to get rid of the stash. You can run rm -rf ~/MM-Backup once you’re content it’s all working as it should.

      Finally, I recommend you take the opportunity to also run sudo apt-get update && sudo apt-get dist-upgrade npm && sudo dist-upgrade pm2 (I think nodejs should upgrade as a dependency of npm but could be wrong).

      posted in Troubleshooting
      N
      ninjabreadman
    • RE: What is the difference between require() and getScripts()?

      @E3V3A

      require() is for when you mean “I’m going to use this code somewhere else in this script I am writing right now” — i.e. somewhere on the server-side.

      getScripts() is for when you mean “my client-facing/browser code will need this loaded to perform some operation” — i.e. somewhere on the client-side.

      (As always, this is what I understand and hope someone will correct me if I’m wrong.)

      posted in Development
      N
      ninjabreadman
    • Trouble with Smart Quotes, etc

      Someone sent you here because you were probably having trouble with smart directional (aka angled or curly) quotes. Most often this is an issue with Macs because they do “smart punctuation” replacement, including in TextEdit, the default text editor.

      This is mostly a problem for quotes, where it changes quotes (") to their directional alternatives (“ or ”). Here is their support document on the topic. When writing prose, this is generally a good idea. In writing code, it’s not.

      In Windows, such smart replacement done at a program level on certain word processors, like Microsoft Word, but not in things like Notepad, the default text editor for Windows. This is why it’s more of a problem for Mac users.

      Straight double quotes (") are different characters from open and close quotes (“ or ”). They look very similar to us, but the JavaScript/Node.js parser doesn’t think so. Straight quotes have the code points of U+0022 or U+0027, but directional quotes have completely separate code points.

      If you’re having trouble with smart quotes, you’ll need to start using a proper text editor that doesn’t allow the system to automatically insert directional quotes. The default editor on Mac (called TextEdit) is much more of a note taking or word processing program (much more like WordPad) than a text editor for code. It doesn’t understand code, and does things that break it. Use a true text editor like Atom, BBEdit, TextMate, etc. Or more sophisticated tools like Coda. Pick one, download it, install it, and use that to open/edit/save your config and other code files. (NB: I recommend Atom because it is supported and distributed by GitHub, is free, and is well-supported and open-source, with a good plugin architecture and community. YMMV.)

      Once you’ve downloaded and installed Atom (by moving it to your ~/Applications folder on your Mac) you can run it then open the file, or right-click a file and select “Open with…” and choose Atom. Not only will it not break your code, it will colour-code (called “syntax-highlighting”) it, show you where brackets/braces match, and can help to make your code legible (called “Beautify” in Atom).

      In order to edit remotely on (for example) a Raspberry Pi on your local network, you can use an SFTP client like FileZilla or CyberDuck. SFTP will need to be enabled on your RPi. You can then connect to the RPi and edit files remotely (not download, edit, upload; both programs have an “edit” option that will let you edit and save remotely in an editor … change it to Atom for js/css/html files in the preferences). This should allow you to edit files on your MM remotely.

      posted in Troubleshooting
      N
      ninjabreadman
    • RE: GIF update from URL with MMM-EyeCandy

      @Mykle1 @JRWJR

      I think this should work; add the following at the bottom of the start function in MMM-EyeCandy.js:

        start: function () {
        
          ...
            
          // ADDED: Schedule update timer
          setInterval(function() {
          self.updateDom(self.config.fadeSpeed || 0); // use config.fadeSpeed or revert to zero
          }, this.config.updateInterval);
      
        }, // this was line 83
      
      posted in Troubleshooting
      N
      ninjabreadman
    • RE: (2.1.0) Calendar will broadcast events.

      @jer78 Here is the Readme.md for third party modules, which details the notification system: https://github.com/MichMich/MagicMirror/blob/master/modules/README.md

      Your module will receive a CALENDAR_EVENTS notification, with a payload which is an array of calendar events objects with the following attributes: title, startDate, endDate, fullDayEvent, location and geo.

      You can make your own module, or modify an existing one. MMM-Traffic will display Google Maps directions to a given destination. You can override its receiveNotification function to (1) sort the payload to find the soonest event, (2) decide if there’s an event in the next 2 hours, and (3) display directions to the destination using the location or geo coordinates.

      Remember, you’ll need to populate those fields when creating your event entries, and you may also need to provide a hint (e.g. “Colombus, OH”) to Google so it knows which “Olive Garden” or “Municipal Library” you’re looking for.

      posted in Upcoming Features
      N
      ninjabreadman
    • RE: Prepping my first build. Care to check my work?

      @3DPrintedWaffles

      Just here to echo and add to the comments from @bhepler:

      • Liquid nails can work, but you will need to clamp (or otherwise brace) the corners to let it dry. Usually for a wood joint you will use fasteners (nails, screws) and reinforce with glue. If not using fasteners, you can also use a biscuit or tongue to reinforce the joint.
      • If you use screws, pre-drill the holes to avoid splitting your wood. You may also consider whether you want to create butt joints (square) or miter joints (angle).
      • The bezel is also often what hides the electronics behind your mirror. Without the bezel, you may still want a skirt behind the mirror to conceal those elements.
      • With bevel-less, you may want to find the most opaque material possible to prevent light entering the back of your mirror (that would otherwise be mostly blocked by the bezel/skirt).
      • I have no experience with gluing to glass, but would worry about seeing the glue beneath your mirror.
      • Also, given that your glass and display will be different sizes, if you mount the display in a corner of the glass you will need multiple mounting points for your mirror – it won’t hang level from a single point (as it won’t balance).
      posted in Development
      N
      ninjabreadman
    • RE: This Day in History ticker?

      @donutsoup I think @cowboysdude’s module should do what you want: https://forum.magicmirror.builders/topic/1803/mmm-history/9

      It’s a TDIH module that cycles through different years and their significance.

      posted in Requests
      N
      ninjabreadman
    • RE: change default position of module

      You’re right; for what you were trying to do, you need to use position in config.js. From what I understand you’re trying to do – I could be wrong – you can put this in your custom.css:

      div.region.bottom.left div.module.newsfeed {
        text-align: center;
        max-width: 500px; /* change to whatever width you want */
      }
      

      This will make any newsfeed module in the bottom_left position still center its text.

      By default, any module put against the sides align their text accordingly. This will override that behaviour. You will need max-width otherwise the module will simply (at least, in my testing) span the whole screen.

      nbm

      posted in Troubleshooting
      N
      ninjabreadman
    • RE: What is the difference between these function definitions?

      @E3V3A The former is object notation; therefore, you need to be defining an object. For example:

      var Lemon = {
        skinColor: "yellow",
        juice: 10, // in mL
        squeeze: function() {
          return this.juice;
        }
      }
      

      That way, for each Lemon you can call Lemon.squeeze(). It is relative to itself; the Lemon returns its juice, that it only knows about because it’s a complete object.

      Meanwhile, if you have myFunction() it doesn’t belong to an object. It just exists. You can call it from anywhere as myFunction(). You can even assign it to another variable and call it from there (this is also why you can pass a callback function as an argument):

      var myFunction = new function(){
      ...
      }
      var otherFunction = myFunction;
      otherFunction();
      

      You can also have “lambda” functions that have no name.

      But, to answer your question, you can only use the “object” style if you’re in the middle of defining an object. An “object” style function (most often called a “method” of the object) can also reference the object itself, whereas as a function without an object needs it to be passed as a parameter, such as squeeze(someLemon).

      posted in Development
      N
      ninjabreadman
    • RE: Change colors on each news feed

      If anyone is interested, as a consequence of this post (and a +1 I saw somewhere…), I’ve created a PR adding this functionality to the core newsfeed module. I don’t know that it will be accepted, but hope someone finds it useful.

      If anyone on the forums is interested, you can use PR #1137 on MM to check it out.

      Thanks!

      posted in Development
      N
      ninjabreadman
    • RE: Newbie to Pi looking to start a MM

      Welcome, @torc! You might also check out this thread from @3DPrintedWaffles.

      1. Automatic timed shutdown and boot up (no point it being on at night when nobody is there to benefit).

      This requires added hardware, as the RPi doesn’t have the internal capacity. See this thread on StackExchange. Given you’ll already have the monitor going into standby, you’ll need to determine whether the added cost, work and potential complications are worth the effort.

      1. motion sensor to activate display.

      @cruunnerr is the village expert. Check out this very thorough walkthrough to get started.

      1. small LEDs on back of frame that change with certain outside temperature changes.

      You can start at this post and module. However, there are endless articles on how to connect an RBG LED light strip to an RPi, etc.

      1. map display of selected mobile devices by clicking a button on another device (eg if I want to see where my kids mobiles are, click a button on mine and a map would appear in the mirror with theirs.

      You can trigger displaying modules via a phone/tablet/computer with MMM-Remote-Control, or a button with MMM-Buttons – both by @Jopyth. The harder part will be the map. It’s true that Apple and Google have something like Find My Friends (or Find My Phone for devices connected to your account) but I don’t know of any available APIs for those services. (There are apparently some unofficial Node.js clients.)There is tracking software you can install on Android, but it tends to be insecure garbage.

      posted in General Discussion
      N
      ninjabreadman
    • RE: Error in config file when adding modules, looking for another set of eyes

      Anyone having config.js issues can first copy/paste the module config (or whole thing) into JSHint (removing any API secrets or passwords). It will immediately draw attention to any syntax issues.

      posted in Troubleshooting
      N
      ninjabreadman
    • RE: How to best process an [object Promise]?

      @E3V3A I don’t think there’s a reload mechanism in MM’s config.js. For example, you can have an updateInterval variable in the module config, but it’s the module’s job to then implement the refresh – it isn’t done automagically by MM.

      See the code for the default compliments module for where it uses this.config.updateInterval to call setInterval() with updateDom() (to set a timer to reload the DOM after a delay) all within its start() function.

      posted in Development
      N
      ninjabreadman
    • RE: Should be an easy one: module_center stretches the entire width of the screen. How do I resize this?

      @beeficecream Add this in your custom.css in MagicMirror/css:

      .module.newsfeed {
      max-width: 500px; // adjust px to taste, or use %, em, etc
      }
      

      You can learn more about CSS units here. I think that’s the right selector for newsfeed, but may be mistaken.

      posted in Development
      N
      ninjabreadman
    • RE: Multiple screens fo MM.

      @Mykle1 I know, but I figured as the author of MMM-Hello-Lucy you might be able to explain how (and if) it could help (because it wasn’t apparent to me). I only meant to mention you so that you got a notification; it definitely wasn’t meant to be accusatory.

      posted in General Discussion
      N
      ninjabreadman
    • RE: npm start and black screen

      @dexterbeng I would guess 15-30 seconds. pm2 has to detect that the process has terminated and restart. It depends on the polling interval for pm2 (which, as far as I can tell from their docs/issues, is 100ms, and cannot be changed – seems more frequent than I expected).

      Why are you killing mm with Ctrl+Q? Better to use pm2 restart mm or even pm2 start mm --watch which will also restart mm after file system changes (you may need to configure which directories to watch).

      posted in Troubleshooting
      N
      ninjabreadman
    • RE: Raspberry Pi 0w Module Errors

      @elaniobro IIRC, your folder and filename should match the Module.register() call exactly. So your folder should be MMM-my-module (and NOT MMM-MY-module). You also have an error in loader.js so that’s my guess. It’s doesnt look like loader.js does any manipulation except to add/compare to loadedFiles.

      posted in Development
      N
      ninjabreadman
    • RE: Use MMM-Buttons to hide/show modules

      Hi @cruunnerr,

      payload.module isn’t part of payload.action, but should be a separate key:

      shortPress: {
        notification: "REMOTE_ACTION",
        payload: {
          action: "HIDE",
          module: "module_0_MMM-GoogleMapsTraffic"
        }
      },
      

      Hope that helps.

      posted in Troubleshooting
      N
      ninjabreadman
    • RE: updating without losing settings in config, and js files?

      @navyvette87 @Cyberwrights is right, and where possible you should migrate your changes into config.js, custom.css, etc.

      When updating, git insists that your files not have changes that conflict with those of the repository. Use git stash as outlined here to store your local changes, pull updates from the repo, then restore your own changes.

      posted in General Discussion
      N
      ninjabreadman
    • RE: How to update the master branch?

      @mochman Thanks! Sorry I subposted on you; I was writing on my phone (so didn’t see your post), plus Mobile Safari really hates the compose window of NodeBB, so it takes forever to post anything decent). That and autocorrect really hates git and npm. Cheers. ;)

      posted in Troubleshooting
      N
      ninjabreadman
    • 1 / 1