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

    Posts

    Recent Best Controversial
    • RE: How to load a <script> src = " " </script> into my mirror?

      @morozgrafix You got it! The path was the issue. Do you know why I can’t use the path the way I specified?

      Now, I’ll go back and try your solution and see if I have any other problems!

      Thanks again for your help. It’s much appreciated.

      posted in Development
      nbrennN
      nbrenn
    • RE: How to load a <script> src = " " </script> into my mirror?

      @morozgrafix Yep, when the mirror was running, and running the wget http://localhost:8080 command, I connected successfully.

      So then when I open up a command terminal while the mirror is running, and run:

      wget http://localhost:8080/home/pi/MagicMirror/modules/datafeed/JANUARY22TEST.csv
      

      it says connected to 8080, but returns 404 Not Found.

      posted in Development
      nbrennN
      nbrenn
    • RE: How to load a <script> src = " " </script> into my mirror?

      @morozgrafix I start my mirror with npm start. And my Mirror config.js, I am using Port 8080.

      posted in Development
      nbrennN
      nbrenn
    • RE: How to load a <script> src = " " </script> into my mirror?

      @morozgrafix Thanks for the response and the support!

      This looks very promising solution and I’ll give it a go once I solve one nagging problem. I am receiving the connection refused error when I am connecting to the localhost: 8080:

      pi@raspberrypi:~ $ wget --verbose localhost:8080
      --2017-01-24 12:11:12--  http://localhost:8080/
      Resolving localhost (localhost)... ::1, 127.0.0.1
      Connecting to localhost (localhost)|::1|:8080... failed: Connection refused.
      Connecting to localhost (localhost)|127.0.0.1|:8080... failed: Connection refused.
      pi@raspberrypi:~ $
      
      posted in Development
      nbrennN
      nbrenn
    • RE: How to load a <script> src = " " </script> into my mirror?

      Thanks for the great response. Your example is very helpful.

      I would like to update the CSV while the mirror is running, so I will have to look in to how to accomplsh that.

      One question about loading the CSV, if I were to use your example. In your example, you are reading the CSV data from a text area. In my case, how would I read the CSV from a directory on my Raspberry Pi? It looks like I would have to access the file and then save it as the object “csvData”.

      It also looks like I am receiving a “http://localhost:8080/home/pi/MagicMirror/modules/datafeed/JANUARY22TEST.csv Failed to load resource: the server responded with a status of 404 (Not Found)” error. The connection to port 8080 is refused (and my mirror is running on Port 8080 and all of my other modules are running fine). Do you know a workaround for this?

      Thank you!

      posted in Development
      nbrennN
      nbrenn
    • RE: How to load a <script> src = " " </script> into my mirror?

      Thanks for your response! I tried to change it to the method you described, but it is still isn’t showing anything. Looking at my code, do you know if there is something else keeping it from working?

      I am getting an error that it failed to load resource, on the line of my csv. Do I have to specify the path?

      posted in Development
      nbrennN
      nbrenn
    • How to load a <script> src = " " </script> into my mirror?

      I am trying to have my module load the d3 library to create a table for my csv data. But I am not sure how to type in the line:

      src="d3.min.js?v=3.2.8"
      

      (which is wrapped in script brackets), into my module. Right now, nothing shows up on my Mirror aside from the name of the module, datafeed. My code is as follows:

      Module.register("datafeed",{
      getScripts: function() {
       	return ["d3.min.js"]
       },
      
       // Define styles.
       getStyles: function() {
       	return ["datafeed_styles.css"];
       },
       
      
       // Override dom generator.
       getDom: function() {
           d3.text("JANUARY22TEST.csv", function(data) {
                   var parsedCSV = d3.csvParseRows(data);
      
                   var container = d3.select("body")
                       .append("table")
      
                       .selectAll("tr")
                           .data(parsedCSV).enter()
                           .append("tr")
      
                       .selectAll("td")
                           .data(function(d) { return d; }).enter()
                           .append("td")
                           .text(function(d) { return d; });
               });
       },
      });
      
      posted in Development
      nbrennN
      nbrenn
    • Displaying data from a CSV file saved on my Pi?

      Hi all,

      I managed to connect my Raspberry Pi to a MySQL Database to retrieve some data from a database table. The file is then saved on my Raspberry Pi as a .csv, and I would like to display the data on my Mirror.

      The data contains time-series data from a remote temperature sensor, and I will try to update the query every few hours. The data has a column for the Time-Stamp and a column for the reading itself. I’d probably just have the output be a sentence like, “The temperature is X degrees” where X is taken from the .csv file.

      In my mind, I believe that I need to create an HTML document object that retrieves the data from the file, and then displays it. Is this a method that would be best for my application?

      Basically, how do I take the following code and turn it into code for the Magic Mirror?
      https://bl.ocks.org/ndarville/7075823

      posted in Development
      nbrennN
      nbrenn
    • RE: MMM-Fitbit

      Could this module be adapted to work for the Misfit?

      posted in Health
      nbrennN
      nbrenn
    • RE: Trying to write my own Module...

      @mochman I have another question. As shown below in the attached image, I am appending the name to the kWh values. How do I put the name into the Load column and the numbers into their kWh column?

      In this case, the “name” is in the same object as the channel, so that’s why I extracted it the way I do in my code… I have the name as a variable, but I can’t seem to put it into it’s own column.

      0_1484344461715_loadkhw2 (1).jpg

      Code:

         getDom: function(){
              var wrapper = document.createElement("div");
              if(!this.loaded) {
                      wrapper.innerHTML = "Loading...";
                      return wrapper;
              }
              if(this.xml !== null){
      	 var table = document.createElement("table");   
      	 var row = document.createElement("tr");   
      	 var header = document.createElement("th");
      	 var header2 = document.createElement("th");
      	 header.innerHTML = "Load";
      	 row.appendChild(header);
      	 header2.innerHTML = "kWh";
      	 row.appendChild(header2);
      	 table.appendChild(row);
      
      	 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++){
      		name = channels[i].getAttribute('name');
      		if(channels[i].children[n].tagName === "kWh"){
                      	var element = document.createElement("td");
      			element.classList.add(channels[i].children[n].tagName);
      		if (channels[i].children[n].textContent != 0){
      			element.innerHTML = name + " " + 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;
         },
      
      posted in Development
      nbrennN
      nbrenn
    • 1
    • 2
    • 3
    • 4
    • 5
    • 2 / 5