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

    Posts

    Recent Best Controversial
    • 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
      mochmanM
      mochman
    • RE: MMM-Gas

      @rob73 I haven’t tried this to see how it looks, but you may just be able to comment out a few of the lines in MMM-Gas.js
      Try commenting out the last 2 lines of this code in the getDom() function.

       var td5 = document.createElement("td");
       td5.innerHTML = dist;
       TDrow.appendChild(td5);
       weatherTable.appendChild(TDrow);
      

      It should look like this when you’re done.

      var td5 = document.createElement("td");
      td5.innerHTML = dist;
      //TDrow.appendChild(td5);
      //weatherTable.appendChild(TDrow);
      

      You should also comment out this part as well.

      var bjumpy = document.createElement("th");
      bjumpy.setAttribute("style", "text-align:center");
      bjumpy.classList.add("xsmall");
      bjumpy.innerHTML = "Distance";
      //xFCRow.appendChild(bjumpy);
      //weatherTable.appendChild(xFCRow);
      
      posted in Transport
      mochmanM
      mochman
    • RE: Weather based on another provider..

      Or just get the new MagicMirror 2.0.2 that was released today. It has those changes incorporated.

      posted in Requests
      mochmanM
      mochman
    • RE: Nubie question... How do I kill magic mirror so that I test new settings for config.js

      Right, the nohup command removes the process from the terminal window. If you shut down the terminal, it’ll also shut down your magic mirror without the nohup command before npm.

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

      I updated the module to also let you use it as a physical button. Besides sending notification, you can also have it activate another GPIO pin as a momentary press. I’m thinking about integrating it with either Alexa (which looks for a button press) or @EoF’s Hide All Module.

      posted in Utilities
      mochmanM
      mochman
    • RE: ipWhitelist HowTo

      Have you tried adding "10.0.0.1/24" to the list since it looks like your client is using an IPv4 connection?

      posted in Tutorials
      mochmanM
      mochman
    • RE: Weather based on another provider..

      @cowboysdude said in Weather based on another provider..:

      @mochman said in Weather based on another provider..:

      Or just get the new MagicMirror 2.0.2 that was released today. It has those changes incorporated.

      That’s awesome! Thank you but I just got weather underground working and I like it :)

      Yeah it does, that’s the one I use too.

      posted in Requests
      mochmanM
      mochman
    • RE: Calendar config

      Try putting your config.js in a website like http://jshint.com/. It should help you find any brackets you might be missing.

      posted in Troubleshooting
      mochmanM
      mochman
    • RE: ipWhitelist doesn't work for me

      @DazDavid Yeah, I messed up with the CIDR notation for IPv6. The reason why “/24” works is because that gives you practically every IP (especially every IP4 address). If you want to just have 192.168.X.0 - 192.168.X.255 whitelisted, you should use "::ffff:192.168.X.1/120".

      I added a HOWTO guide here to help out everyone.

      posted in Bug Hunt
      mochmanM
      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
      mochmanM
      mochman
    • 1 / 1