MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. morozgrafix
    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 3
    • Posts 136
    • Groups 2

    Posts

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

      I also updated JSfiddle example with sum calculation logic: https://jsfiddle.net/morozgrafix/8oz1t9g4/2/

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

      It would be very difficult for me to guide you through building entire module without seeing the code and understanding what it is doing. That’s the reason why I’m only able to give you bits and pieces of information. One of the things that can help is for you to create a repo on GitHub with code that you got so far and then I can take a look and possibly offer some suggestions.

      In your original post you mentioned that you wanted to display CSV data from the file in HTML table format which seems a bit different from your most recent requirement:

      For some context, my .csv data table contains two columns of time-series data for which I want to sum together. And then I just want to output a sentence like, “Your sum is XXX.”

      To achieve the above following very rough logic would need to be implemented:

      1. CSV file is created/updated in /home/pi/MagicMirror/modules/datafeed/file.csv
      2. When module is loaded JS creates a variable and reads contents of the CSV file into it (similar to what compliments module does)
      3. CSV data in that variable is parsed, sum of the values in one of the columns calculated and assigned to another variable (sum).
      4. DOM element is created and innerHTML of that element is updated with "Your sum is " + sum
      5. At given config interval steps 1-4 are repeated to get fresh set of data.

      Is this close to something that you are trying to do?

      (Above steps aren’t accounting for any error handling etc.)
      BTW I don’t think you need to convert your CSV to JSON, especially if this is a simple 2 column file. Commenting out or removing xobj.overrideMimeType("application/json"); from complimentFile example should be sufficient for CSV file reading.

      Thanks.

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

      I’ve moved this thread into Development category, since conversation is now mostly related to your module development.

      Thanks.

      posted in Development
      morozgrafixM
      morozgrafix
    • RE: Displaying data from a CSV file saved on my Pi?

      we have ongoing conversation about getting this done in this topic https://forum.magicmirror.builders/topic/1515/how-to-load-a-script-src-script-into-my-mirror

      @nbrenn are you ok if I lock this topic and we will keep going in the thread mentioned above?

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

      @nbrenn glad you are getting closer to solving this.

      Root directory that is served by webserver that is running on localhost:8080/ is mapped to MagicMirror directory. In most cases and in your case the full path of that is /home/pi/MagicMirror.
      By default it is configured to serve you index.html.

      So mapping looks kind of like this:

      http://localhost:8080					---->	/home/pi/MagicMirror/
      http://localhost:8080/index.html			---->	/home/pi/MagicMirror/index.html
      http://localhost:8080/modules/module_name		---->	/home/pi/MagicMirror/modules/module_name/
      http://localhost:8080/modules/module_name/foo.html	---->	/home/pi/MagicMirror/modules/module_name/foo.html
      

      as you can see from above when you asking for

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

      webserver will attempt to serve you something from

      /home/pi/MagicMirror/home/pi/MagicMirror/modules/datafeed/JANUARY22TEST.csv
      

      which doesn’t really exist and that’s the reason why you can’t use absolute file path in the URL. Which also brings up another point: because root directory that is served by webserver is mapped to /home/pi/MagicMirror, webserver can’t serve anything above the /home/pi/MagicMirror directory. (for example you won’t be able to access /home/pi/foo.html).

      This is just a small portion of how it works and there are other rules that play role, but hopefully this info shines some light and gives you enough explanation on why your path didn’t work.

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

      @nbrenn that path is incorrect. Try

      wget http://localhost:8080/modules/datafeed/JANUARY22TEST.csv
      
      posted in Development
      morozgrafixM
      morozgrafix
    • RE: How to load a <script> src = " " </script> into my mirror?

      @nbrenn when your electron MM app shows up on the screen and while it is running, you should be able to do wget http://localhost:8080 without getting connection refused.

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

      @nbrenn is your mirror up and running with npm start or node serveronly? If webserver isn’t running on port 8080 you will get connection refused error when attempting to access it over HTTP.

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

      Sorry I’m on mobile right now and it’s not easy to write code samples on the phone.

      You will not be able to access your local file via URL like that. You would need to read it from the file system. In default compliments module there is a piece of code that you can modify to achieve that.

      EDIT: If you place your JANUARY22TEST.csv file in the directory of your module named datafeed it should be available at this URL: http://localhost:8080/modules/datafeed/JANUARY22TEST.csv

      Here is a snippet, but I would recommend looking through the whole module to get a better idea how it works:

      	/* complimentFile(callback)
      	 * Retrieve a file from the local filesystem
      	 */
      	complimentFile: function(callback) {
      		var xobj = new XMLHttpRequest();
      		xobj.overrideMimeType("application/json");
      		xobj.open("GET", this.file(this.config.remoteFile), true);
      		xobj.onreadystatechange = function () {
      			if (xobj.readyState == 4 && xobj.status == "200") {
      				callback(xobj.responseText);
      			}
      		};
      		xobj.send(null);
      	},
      

      In this case it’s reading JSON file, but you would need to read plain text CSV. There are a few examples that are similar on Stack Overflow and in tutorials online. I will try to dig up an example when I’m back in front of my computer, but I’m sure you can easily search for them.

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

      It seems that you are appending table element to the body. If you take a look at HelloWorld sample module you will see a basic structure for getDom method. It needs to return element that will be injected into HTML of the MM when system calls getDom method.

      Very basic example would look like this:

      getDom: function() {
      	var wrapper = document.createElement("div");
      	wrapper.innerHTML = "Hello World!";
      	return wrapper;
      }
      

      When system calls getDom it will get wrapper which would have <div>Hello World!</div> HTML.
      If you have a simple CSV file d3 may be an overkill for that, you can probably use a fairly simple javascript to get that done. Here is an example of how you can do it (I didn’t load CSV from external file in that example, I kind of threw it together quickly, but it seems to work): https://jsfiddle.net/morozgrafix/8oz1t9g4/1/

      Module development documentation is also pretty good: https://github.com/MichMich/MagicMirror/tree/master/modules
      In case your CSV data gets updated while mirror is running, you can also figure out how to periodically update information that you display by looking at other modules.

      posted in Development
      morozgrafixM
      morozgrafix
    • RE: My Vertical Split Screen Dashboard

      @vicdilou Can you please start a new thread in Troubleshooting section of the forum? You will get more responses that way and it will avoid highjacking this thread.

      Thank you.

      posted in Show your Mirror
      morozgrafixM
      morozgrafix
    • RE: How to load a <script> src = " " </script> into my mirror?

      Here is a snippet from Module Development documentation. Full details are here: https://github.com/MichMich/MagicMirror/tree/master/modules#getscripts

      getScripts: function() {
          return [
              'script.js', // will try to load it from the vendor folder, otherwise it will load is from the module folder.
              'moment.js', // this file is available in the vendor folder, so it doesn't need to be available in the module folder.
              this.file('anotherfile.js'), // this file will be loaded straight from the module folder.
              'https://code.jquery.com/jquery-2.2.3.min.js',  // this file will be loaded from the jquery servers.
          ]
      }
      

      I would recommend saving it locally in your module directory and loading it from there, because mirror will stall if it can’t access externally hosted file.
      Hope this helps.

      posted in Development
      morozgrafixM
      morozgrafix
    • RE: Test suite for MagicMirror²

      Great idea to setup test suite. Thanks for getting it started @roramirez. I’ve made some minor cleanup changes on top of your initial work, PR is sitting on GitHub. I will try to contribute to tests as much as I can.

      posted in Upcoming Features
      morozgrafixM
      morozgrafix
    • RE: Settings in config.js aren't loaded after reboot of RasPi

      @LincolnClay I’m not really sure why MM code is not picking up your /home/pi/MagicMirror/config/config.js after restart.

      By the way config.js.sample is just a sample config that can be copied into config.js and it comes along with MM code and doesn’t really play any role when MM starts up, so there is no need to modify that file in any way.

      If your /home/pi/MagicMirror/config/config.js keeps your desired changes, I wonder if you somehow have 2 different locations where MM is installed and configured. (I noticed that you have node_modules directory in /home/pi which seems a bit odd.)

      I’m assuming you are starting MM with pm2 on a startup. Can you please show post contents of your /home/pi/mm.sh file (you can run cat /home/pi/mm.sh and copy/paste contents of the output) and also run pm2 list and pm2 show mm and copy/paste output here?

      Sorry I’m kind of running out of ideas without knowing more information.

      Thanks.

      P.S. I’ve forked our conversation into a separate topic, this way we will not highjack original topic.

      posted in Troubleshooting
      morozgrafixM
      morozgrafix
    • RE: WE WANT YOU! [New Moderators]

      @paviro & @MichMich thank you for warm welcome. I’m looking forward to contributing more and helping this amazing community thrive.

      posted in Forum
      morozgrafixM
      morozgrafix
    • RE: Settings in config.js aren't loaded after reboot of RasPi

      @LincolnClay before reinstalling did you delete MagicMirror directory from /home/pi directory? I just want to make sure that your pi user has full access to files inside of MagicMirror directory. You can check who owns MagicMirror directory by running following command in the terminal:

      ls -l /home/$USER
      

      which will give you output similar to this:

      drwxr-xr-x  2 pi       4.0K Jan 21 14:30 foo/
      drwxr-xr-x  2 root     4.0K Jan 21 14:31 foo1/
      drwxr-xr-x 14 pi       4.0K Jan  8 14:52 MagicMirror/
      

      as you can see in the example above directory foo and MagicMirror are owned by pi user and foo1 is owned by root. To change ownership from root to pi this command needs to be executed (in the example below it will change ownership of foo1 directory from root to currently logged in user):

      sudo chown -R $USER /home/$USER/foo1/
      

      basically it does translates to this: Running as root user (one who currently owns foo1 directory and has write permissions) change owner (‘chown’) recursively (-R) to currently logged in user ($USER which is pi in our case) for directory foo1. After running this command foo1 will belong to pi and running ls -l /home/$USER should produce results similar to this:

      drwxr-xr-x  2 pi       4.0K Jan 21 14:30 foo/
      drwxr-xr-x  2 pi       4.0K Jan 21 14:31 foo1/
      drwxr-xr-x 14 pi       4.0K Jan  8 14:52 MagicMirror/
      

      QUESTION: When you changed /home/pi/MagicMirror/config/config.js did you actually save that file? I’m trying to understand what you mean by “I get the standard info displayed on MM” Does it show default settings? Did it ever show info with your local weather?

      I also see some Xlib: errors or warnings in your logs and I have no idea where that coming from.

      P.S. It maybe worth opening your own thread with exact steps that you already did for easier troubleshooting and not to highjack another thread.

      posted in Troubleshooting
      morozgrafixM
      morozgrafix
    • RE: MMM-horoscope - daily horoscope

      @fox If you know of a source for daily horoscope in German (preferably in API form, but RSS feed may also work) I’m happy to look into adding it to the module.

      posted in Entertainment
      morozgrafixM
      morozgrafix
    • RE: Npm start...

      @cowboysdude sweet I’m glad you got it working.

      posted in Troubleshooting
      morozgrafixM
      morozgrafix
    • RE: Npm start...

      @LincolnClay I’m glad it all worked out for you. But I would be careful adding sudo command to everything. You may run into permissions issues. The reason why you need to use sudo when installing packages with apt-get is because you need to have elevated privileges as you are making system wide changes. Cloning MM repository in your home directory shouldn’t require sudo, if you use sudo to clone all files will belong to root user and your user (usually pi) will not have permissions to create or modify files in MagicMirror directory (which opens a whole different can of worms).

      TL;DR version: try to use sudo only when necessary.

      @cowboysdude Do you have only one monitor (your TV through HDMI) to your Ubuntu box? Also you may want to attempt to run https://github.com/electron/electron-quick-start just to see electron app running on your rig completely outside of MM codebase.

      @cianoo45 are you still having problems starting the MM? That writeup was specifically for @cowboysdude who was trying to get MM setup on his Ubuntu system. You should be fine with npm v4.0.0 (on my RasPi I’m running node v6.9.2 and npm v3.10.9 if that matters)

      posted in Troubleshooting
      morozgrafixM
      morozgrafix
    • RE: Npm start...

      I’m replying from my phone at the moment and will post full reply to all later when I’m in front of my computer.

      When I said “but npm start worked just fine” I meant I was running it from terminal on Ubuntu box and not through SSH from my MacBook.

      posted in Troubleshooting
      morozgrafixM
      morozgrafix
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 5 / 7