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

    Posts

    Recent Best Controversial
    • RE: MMM-Instagram - Pull and animate photos from Instagram feed

      Here is my MMM-Instagram.js

      /* global Module */
      
      /* Magic Mirror
       * Module: MMM-Instagram
       *
       * By Jim Kapsalis https://github.com/kapsolas
       * MIT Licensed.
       */
      
      Module.register('MMM-Instagram', {
      
          defaults: {
              format: 'json',
              lang: 'en-us',
              id: '',
              animationSpeed: 1000,
              updateInterval: 60000, // 10 minutes
              access_token: '',
              count: 200,
              min_timestamp: 0,
              loadingText: 'Loading...'
          },
          
          // Define required scripts
          getScripts: function() {
              return ["moment.js"];
          },
          
          /*
          // Define required translations
          getTranslations: function() {
              return false;
          },
          */
          
        
      
          // Define start sequence
          start: function() {
      	var self = this;
              Log.info('Starting module: ' + this.name);
              this.data.classes = 'bright medium';
              this.loaded = false;
              this.images = {};
              this.activeItem = 0;
              this.url = 'https://api.instagram.com/v1/users/self/media/recent' + this.getParams();
      	var insturl = this.url;
      //        Log.info('instaurl = ' + this.url);
      	setInterval(function() {
      //				Log.info('NewUrl = ' + this.url);
      			        self.sendSocketNotification("INSTAGRAM_GET", insturl); 
      				    }, 40000); //perform every 1000 milliseconds.	
      
      },
      
          
          getStyles: function() {
              return ['instagram.css', 'font-awesome.css'];
          },
      
          // Override the dom generator
          getDom: function() {
              var wrapper = document.createElement("div");
              var imageDisplay = document.createElement('div'); //support for config.changeColor
      
              if (!this.loaded) {
                  wrapper.innerHTML = this.config.loadingText;
                  return wrapper;
              }
              
              // set the first item in the list...
              if (this.activeItem >= this.images.photo.length) {
                  this.activeItem = 0;
              }
              
              var tempimage = this.images.photo[this.activeItem];
              
              // image
              var imageLink = document.createElement('div');
              //imageLink.innerHTML = "<img src='https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png'>";
              imageLink.id = "MMM-Instagram-image";
              imageLink.innerHTML = "<img src='" + tempimage.photolink + "'>";
              
              imageDisplay.appendChild(imageLink);
              wrapper.appendChild(imageDisplay);
             
              return wrapper;
          },
      
          /* scheduleUpdateInterval()
           * Schedule visual update.
           */
          scheduleUpdateInterval: function() {
              var self = this;
      
              Log.info("Scheduled update interval set up...");
              self.updateDom(self.config.animationSpeed);
      	
      
              setInterval(function() {
                  Log.info("incrementing the activeItem and refreshing");
                  self.activeItem++;
                  self.updateDom(self.config.animationSpeed);
              }, this.config.updateInterval);
          },
      
          /*
           * getParams()
           * returns the query string required for the request to flickr to get the 
           * photo stream of the user requested
           */
          getParams: function() {
              var params = '?';
              params += 'count=' + this.config.count;
              params += '&min_timestamp=' + this.config.min_timestamp;
              params += '&access_token=' + this.config.access_token;
              return params;
          },
      
          // override socketNotificationReceived
          socketNotificationReceived: function(notification, payload) {
              //Log.info('socketNotificationReceived: ' + notification);
              if (notification === 'INSTAGRAM_IMAGE_LIST')
              {
                  //Log.info('received INSTAGRAM_IMAGE_LIST');
                  this.images = payload;
                  
                  //Log.info("count: " +  this.images.photo.length);
                  
                  // we want to update the dom the first time and then schedule next updates
                  if (!this.loaded) {
                  this.updateDom(1000);
                      this.scheduleUpdateInterval();
                  }
                  
                  this.loaded = true;
              }
          }
      
      });
      
      :::
      
      Spoiler Text
      
      :::
      
      
      
      posted in Utilities
      Y
      Yurick
    • RE: MMM-Instagram - Pull and animate photos from Instagram feed

      Read my post 4 months ago. I changed the code and it works fine for me. As I am a copy-paste coder, I can’t post it here for not to be damned. :) But if we ask a author to fix it using my clues it would be nice to have a working module.

      posted in Utilities
      Y
      Yurick
    • RE: Modules to display Stock (Capital Stock)

      3rd module with google finance works for me just fine, all you need it to find the correct ticker. For currency try “CURRENCY:EURUSD”, for commodities unfortunately you will need to find some substitute. You can try “NYSEARCA: USO” or “NYSEARCA: BNO” in case of crude oil.

      posted in Troubleshooting
      Y
      Yurick
    • RE: MMM-Instagram - Pull and animate photos from Instagram feed

      Hi, this is really nice module, the only problem is it doesn’t update photos from instagram. I managed to make it work properly using setInterval for grabPhotos function AND storing url in a new variable which I used in sendSocketNotification (this.url somehow works only at the first iteraction, then it overwrited by something). Since I could not find the real problem, my code looks ugly but still works. Now it takes couple minutes to display a just taken picture on a mirror.

      posted in Utilities
      Y
      Yurick
    • 1 / 1