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

    Posts

    Recent Best Controversial
    • RE: Blank screen after successful install

      Are you not running npm start? Are you just opening up the index.html file? If so, please put all of the modules back and try running npm start in the ~/MagicMirror directory.

      Please take a look at the Complete Setup Tutorial to see how to run the program.

      posted in Troubleshooting
      M
      mochman
    • RE: Trying to write my own Module...

      Glad it all worked out for you!

      posted in Development
      M
      mochman
    • RE: Trying to write my own Module...

      Looks like you need to modify your other if/then statement. The one you’ve modified checks both the name and watts to see if they are !=0. Since the name always !=0, it’s displayed.

      posted in Development
      M
      mochman
    • RE: Module ignoring node_helper.js?

      node_helper.js doesn’t output console.log() to the same place the MMM-HiWorld.js does. You’ll see the log pop up in the npm output. You can see the data when you run npm start on the raspberry pi. If you are using pm2 to autostart Magic Mirror, you can ssh into your pi and run
      tail -f ~/.pm2/logs/mm-out-0.log to see the console messages. You can also run tail -f ~/.pm2/logs/mm-error-0.log to see all of your node_helper.js errors.

      posted in Development
      M
      mochman
    • RE: Trying to write my own Module...

      MMM-EMonitor.js

      Module.register ("MMM-EMonitor", {
      
          //default module config.
          defaults: {
              // Insert defaults here
              interval: 900000, // Every 15 mins
              security_key: null,
              animationSpeed: 1000
          },
      
          getStyles: function() {
              return ["MMM-EMonitor.css"];
          },
      
          // Define the start sequence
          start: function() {
              Log.log("Starting module: " + this.name);
              this.loaded = false;
              this.xml = null;
              this.url = 'https://api.emonitor.us/location/getCurrentData?security_key=';
              setInterval(this.getCurrentData(), this.config_interval);
          },
      
         getCurrentData: function() {
              var self = this;
              var xhttp = new XMLHttpRequest();
              xhttp.onreadystatechange = function() {
                      if (this.readyState == 4 && this.status == 200) {
                              self.xml = self.parseXML(this.responseText);
                              self.loaded = true;
                              self.updateDom(self.config.animationSpeed);
                      }
              };
              xhttp.open("GET", this.url+this.config.security_key, true);
              xhttp.send();
          },
      
      
         getDom: function(){
              var wrapper = document.createElement("div");
              if(!this.loaded) {
                      wrapper.innerHTML = "Loading...";
                      return wrapper;
              }
              if(this.xml !== null){
               var table = document.createElement("table");
               table.classList.add("xsmall", "table");
               var channels = this.xml.getElementsByTagName("channel");
               for(var i = 0; i < channels.length; i++){
                 var row = document.createElement("tr");
                 for(var n = 0; n < channels[i].children.length; n++){
                      if(channels[i].children[n].tagName === "name" || channels[i].children[n].tagName === "watts"){
                      var element = document.createElement("td");
                      element.classList.add(channels[i].children[n].tagName);
                      element.innerHTML = channels[i].children[n].textContent;
                      row.appendChild(element);
                      }
                 table.appendChild(row);
                 }
               }
               wrapper.appendChild(table);
              } else {
                      console.log("Returned no Data");
                      wrapper.innerHTML = "NO DATA";
              }
              return wrapper;
         },
      
         parseXML: function(xmlStr){
              return ( new window.DOMParser() ).parseFromString(xmlStr, "text/xml");
         }
      
      });
      

      Your config.js should have:

      {
                              module: 'MMM-EMonitor',
                              position: 'top_left',
                              config: {
                                      security_key: 'XXXXXXXXXXXXXXX'  //your security key
                              }
                      }
      

      This just displays everything in a large table. You may want to modify the for loop to not display data when the wattage is 0, that should get rid of a bunch of rows.

      posted in Development
      M
      mochman
    • RE: Trying to write my own Module...

      You don’t have this.xml defined anywhere in your script. If you look at @strawberry-3-141’s post, it says:

      I’m assuming that you saved your server response into this.xml

      You need to create a function that uses the URL and saves that data in a variable called xml. Since your program never does that, this.xml isn’t defined so your if/else always goes to “NO DATA”.

      Why do you have

      getCurrentData: function(that) {
             that.sendSocketNotification('GET-CURRENT-DATA', that.url);
             setTimeout(that.getCurrentData, that.config.interval, that);
          },
      

      in your program? Did you just see it in another persons code? This code snippet sends your URL to node_helper.js. Are you using that node_helper to pull the XML data from the website? If so, you’re going to need a socketNotificationReceived function to get the data and put it into the xml variable.

      The modules documentation shows you some examples of that.

      posted in Development
      M
      mochman
    • RE: Trying to write my own Module...

      Your code seems to abruptly end in the middle of the getDom() function, but from what I see, it looks like you are sending the URL to a node_helper.js that I assume will get the data you want.

      My recommendation would be to look at this page and see how to parse the XML to take out what you want. You then can use this data to create a simple table to display each <name> and <watts> in the getDom() function. I don’t think you’ll need a node_helper.js to do this though. You can probably just do it in the main .js file. Unless you’re running into a Access-Control-Allow-Origin error. Then you can get around it by using node_helper.js

      Another way people have done this has been described here.

      posted in Development
      M
      mochman
    • RE: Time wont change even if timezone is correct - WIFI

      Did you try this yet? If so, what other things have you tried?

      posted in Troubleshooting
      M
      mochman
    • RE: Trying to write my own Module...

      Can you paste your MMM-Emonitor.js using markdown? It looks like you’re missing a bunch of code.

      So the API sends you XML data and you want to pull out the wattage? Just the first one or all of them?

      posted in Development
      M
      mochman
    • RE: Magic Mirror With Amazon Alexa

      AlexaPi works pretty well too (once you get the sound to work). It has a wake word in case you don’t have a button to press. There is a Magic Mirror Module for it as well that displays what Alexa is doing on the pi (listening, speaking, errors, thinking, etc…).

      posted in Requests
      M
      mochman
    • RE: Module Regions - Tutorial Requested

      You can find information about them here.

      posted in Development
      M
      mochman
    • RE: MMM-Nest

      @tidus5 Thanks! I’m terrible at CSS, I just keep changing numbers until it looks right to me.

      posted in Utilities
      M
      mochman
    • RE: Printing to output Terminal

      @ZTA0796
      I don’t know your testing setup, but you usually can open up your browser (on your computer, not the pi) go to http://YOUR-PI-IP:8080 and then open up your broswer’s console. In chrome (using windows) you press ctrl+shift+i, if you’re using firefox it’s ctrl+shift+k. That’s where all of your console.log messages (from the module.js) will appear. But @LukeCodewalker is correct, you won’t see node_helper.js messages there. You can view those from the console tail -f .pm2/logs/mm-out-0.log & tail -f .pm2/logs/mm-error-0.log. That is, if you’re using the pm2 autostart from here.

      posted in Troubleshooting
      M
      mochman
    • RE: MMM-Swipe - Hand gestures

      @Blamer Yeah, this isn’t created with a certain module in mind. It sends that notification so you can use it in a module you create if you want. I haven’t been really using this too much after I made it so I don’t have any other modules that would utilize the notifications.

      posted in Troubleshooting
      M
      mochman
    • RE: MMM-Swipe - Hand gestures

      No, I have some speakers behind some speaker mesh. I put the sensors behind the mesh.

      posted in Troubleshooting
      M
      mochman
    • RE: Where are you from?

      @cowboysdude Where at in upstate NY? I grew up just north of Albany, but am currently living in Virginia.

      posted in General Discussion
      M
      mochman
    • RE: MMM-Nest

      I’ve updated the module for all of those that use multi-thermostat setups. You now have the option to select the thermostat you want to see in “nest mode”, or you’re able to see all of your thermostats in a “grid mode”.

      Thermostat Select
      Grid Mode

      [card:mochman/MMM-Nest]

      posted in Utilities
      M
      mochman
    • RE: Newsfeed and Weather Not Updating (bad index file causing the issue?)

      Just doing a search for that error it looks like it is probably a problem with your .git/index. You should be able to fix the “bad index” issue by running:

      cd ~/MagicMirror
      rm -rf .git/index
      git reset
      

      You may want to make a backup of your config.js file just in case it does anything weird. I’m not sure if that will solve your module problem. It should allow you to pull the latest MagicMirror version though.

      posted in Troubleshooting
      M
      mochman
    • RE: MMM-Swipe - Hand gestures

      @Jopyth Thanks! I was able to reproduce the error. I updated the package.json file and it runs correctly.

      posted in Troubleshooting
      M
      mochman
    • RE: MMM-Swipe - Hand gestures

      I’m running:

      RasPi 3 with Jessie
      NodeJs 6.7.0
      Fully updated with

      sudo apt-get update
      sudo apt-get dist-upgrade
      sudo rpi-update
      

      I just removed the entire MMM-Swipe Folder

      cd ~/MagicMirror/modules/
      git clone https://github.com/mochman/MMM-Swipe
      cd MMM-Swipe/
      npm install
      cd ~/MagicMirror/
      sudo npm start
      

      I don’t get any of those errors. I don’t know what module version 49 is?

      posted in Troubleshooting
      M
      mochman
    • 1 / 1