• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

How to load a <script> src = " " </script> into my mirror?

Scheduled Pinned Locked Moved Development
35 Posts 4 Posters 24.0k Views 5 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    nbrenn @morozgrafix
    last edited by Jan 25, 2017, 1:12 AM

    @morozgrafix Thanks for your outline. It is very, very helpful and appreciated. So I tried to take what you suggested to turn it into my code, and put it onto GitHub.

    I created a GitHub repository that contains my .css, .csv, and datafeed.js. My areas of confusion (which you’ll probably see in the code) are around how I called in the remoteFile in my getDom. I am not sure if I did that correctly. https://github.com/brennn1/Magic-Mirror-Datafeed-Module

    My .csv is coming in the format which you’ll see on the Github - so each data point is separated by a new line. So I changed where you had the line.split(",") to line.split("\n").

    Do you see anything obvious that will cause me problems? I will go ahead and see what errors I get when I load it onto my mirror.

    M 2 Replies Last reply Jan 25, 2017, 1:32 AM Reply Quote 0
    • M Offline
      morozgrafix Moderator @nbrenn
      last edited by Jan 25, 2017, 1:32 AM

      @nbrenn perfect!!! i can now see your full code and have better idea what you are trying to achieve.

      Your data file is not really a CSV (Comma Separated Values) file, just a text file with values on each line, so you were correct to remove that line.split(",") part. I already spotted a few things where your code will not work correctly. I will take a closer look at it later tonight and hopefully together we can get this resolved.

      1 Reply Last reply Reply Quote 3
      • M Offline
        morozgrafix Moderator @nbrenn
        last edited by morozgrafix Jan 25, 2017, 10:57 AM Jan 25, 2017, 10:56 AM

        @nbrenn I’ve reworked the code to follow that logic outline to get Your sum is 37 to show up in the middle of the MM. You can find a PR on GitHub or just look at my fork of your repo. Most of the code is commented and hopefully easy to follow. I also added some configuration options for better flexibility.

        0_1485341408447_upload-7b56fda4-6a24-42d5-8a75-8fc10ccd0dc4

        Since you didn’t need a table any longer, I took some shortcuts with processing the data and just calculating the sum of all numeric values from the file. You can add the module to the MM and then as it runs update the datafile with new values, MM should update in about a minute or whatever your updateInterval is set to.

        Let me know if you have any questions.

        P.S. I didn’t run it on RasPi, but it should work without a problem. :fingers_crossed: Also if you are planning to make this module available for others it may be worth renaming it to MMM-datafeed to follow the standard naming conventions.

        N 1 Reply Last reply Jan 25, 2017, 2:06 PM Reply Quote 1
        • N Offline
          nbrenn @morozgrafix
          last edited by Jan 25, 2017, 2:06 PM

          @morozgrafix This looks awesome! I will try to work with this over the next couple days and will let you know if I have any other questions! Thanks!

          M 1 Reply Last reply Jan 25, 2017, 3:26 PM Reply Quote 0
          • M Offline
            morozgrafix Moderator @nbrenn
            last edited by Jan 25, 2017, 3:26 PM

            @nbrenn sounds good. Good luck!

            N 1 Reply Last reply Feb 3, 2017, 1:45 PM Reply Quote 0
            • N Offline
              nbrenn @morozgrafix
              last edited by Feb 3, 2017, 1:45 PM

              @morozgrafix Everything is working very well so far!

              I am updating my “Sum” daily, but I would like to be able to show the previous day’s sum. Could I store the value of the sum at 11:59pm, each evening, and then display that value in addition to the current day’s sum?

              Additionally, how could I modify the line of code:

              this.sum = lines.reduce((a, b) => a + b, 0);
              

              to allow for me to sum across multiple columns? So, if my .csv has 3 columns, I’d like the sum total of them.

              M 1 Reply Last reply Feb 3, 2017, 11:27 PM Reply Quote 0
              • C Offline
                cowboysdude Module Developer
                last edited by Feb 3, 2017, 10:09 PM

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • M Offline
                  morozgrafix Moderator @nbrenn
                  last edited by Feb 3, 2017, 11:27 PM

                  @nbrenn sorry swamped at work today. That line just takes all of the values from each line and adds them up. It will not work for multiple columns and true csv files. You would need to resort to logic that we had initially in JSfiddle. If I have time I will look into this later today.

                  N 1 Reply Last reply Feb 4, 2017, 1:18 AM Reply Quote 0
                  • N Offline
                    nbrenn @morozgrafix
                    last edited by Feb 4, 2017, 1:18 AM

                    @morozgrafix I think I can work around this by changing the SQL query (that generates my .csv) to include just one column. Then I can implement it as a new module, placed above the current one.

                    1 Reply Last reply Reply Quote 0
                    • N Offline
                      nbrenn
                      last edited by Feb 4, 2017, 1:37 PM

                      Does anyone know of the best documentation for adding an image/graphic into a mirror module?

                      For my example here, Mirror Datafeed and Sum Module, I am summing over the values in a column in a .csv and then outputting it.

                      I would like to show an image based on what that value is. As a crude example, if the sum is greater than 50, output a frown. If it is less than 50, show a smiling face. What’s the best documentation for putting in graphics that will work on the mirror?

                      C 1 Reply Last reply Feb 4, 2017, 2:11 PM Reply Quote 0
                      • 1
                      • 2
                      • 3
                      • 4
                      • 3 / 4
                      • First post
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy