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.

    Module to display a local list?

    Scheduled Pinned Locked Moved Troubleshooting
    8 Posts 2 Posters 4.7k Views 2 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.
    • J Offline
      jasondreher
      last edited by

      Is there a module to display a list saved locally (or on dropbox)? A module to pull a .txt file or .json?

      I am using this for a shopping list using any.do, I was using todoist but wanted more than one list displayed (and synced with amazon alexa).

      I tried mmm-backlog from https://forum.magicmirror.builders/topic/1949/display-values-from-a-json-file-hosted-online/2 but could not get it to work properly for my needs.

      1 Reply Last reply Reply Quote 0
      • J Offline
        jasondreher
        last edited by jasondreher

        No one?
        I got mmm-backlog working but it breaks other modules and does not sow up in my remote module so I assume it is missing something.

        And I tried MMM-HTTPRequestDisplay but cant get it to pull from a local file.

        Here is my mmm-backlog module (renamed MMM-samslist)
        MMM-samslist.js

        
        Module.register('MMM-samslist',{
        
        	defaults: {
        		title: 'List',
            		fileUrl: '',
        		units: config.units,
        		animationSpeed: 1000,
        		updateInterval: 360000, //update every hour
        		refreshInterval: 360000 , //refresh every minute		
        		timeFormat: config.timeFormat,
        		lang: config.language,
        		
        		initialLoadDelay: 0, // 0 seconds delay
        		retryDelay: 2500,
        		
        		//fileUrl: "http://192.168.43.159:8080/modules/MMM-shoppinglist/list.json"
        	},
        
        	// Define required scripts.
        	getScripts: function() {
        		return ["moment.js"];
        	},
        
        	// Define requird styles
        	getStyles: function() {
        		return ["font-awesome.css"];
        	},
        
        	start: function() {
        		Log.info('Starting module: ' + this.name);
        
        		this.loaded = false;
        		this.sendSocketNotification('CONFIG', this.config);
        	},
        
        	getDom: function() {
        		
        		//var wrapper = document.createElement("ticker");
        		//Added
        		var wrapper = document.createElement("ticker");
            		wrapper.className = 'dimmed small';
        
            		var data = this.result;
            		var statElement =  document.createElement("header");
            		var title = this.config.title;
            		statElement.innerHTML = title;
        		wrapper.appendChild(statElement);
        		//Added
        
        
        		if (!this.loaded) {
        			wrapper.innerHTML = this.translate('LOADING-Jason');
        			wrapper.className = "dimmed light small";
        			return wrapper;
        		}
        
        		if (!this.data) {
        			wrapper.innerHTML = "No data";
        			wrapper.className = "dimmed light small";
        			return wrapper;
        		}
        
        		var t = this.data.list;
        		var content = document.createElement("div");
        		content.innerHTML = "";	
        		
        		for (var i in t.datasequences) {
        			content.innerHTML += t.datasequences[i].title + "<br />";
        			//content.innerHTML += t.title  + " - " + t.datasequences[i].title + "<br />";
        			//for (var j in t.datasequences[i].datapoints) {
        			//	content.innerHTML += t.datasequences[i].datapoints[j].title + ": " + t.datasequences[i].datapoints[j].value + "<br />";
        			//}
        		}
        		
        		wrapper.appendChild(content);
        
        		return wrapper;
        	},
        
         	socketNotificationReceived: function(notification, payload) {
            		if (notification === "STARTED") {
        				this.updateDom();
        			}
        			else if (notification === "DATA") {
        				this.loaded = true;
        				this.processData(JSON.parse(payload));
        				this.updateDom();
            		}
        	},
        
        	/* processData(data)
        	 * Uses the received data to set the various values.
        	 *
        	 * argument data object - tide information received form worldtides.info
        	 */
        	processData: function(data) {
        
        		if (!data) {
        			// Did not receive usable new data.
        			// Maybe this needs a better check?
        			return;
        		}
        
        		this.data = data;
        
        		this.loaded = true;
        		this.updateDom(this.config.animationSpeed);
        	}
        });
        

        and node_helper.js

        'use strict';
        
        
        const NodeHelper = require('node_helper');
        var request = require('request');
        
        module.exports = NodeHelper.create({
        
        	start: function() {
        		this.started = false;
        		this.config = null;
        	},
        
        	getData: function() {
        		var self = this;
        		
        		var myUrl = this.config.fileUrl;
        				
        		request({
        			url: myUrl,
        			method: 'GET',
        		}, function (error, response, body) {
        			if (!error && response.statusCode == 200) {
        				self.sendSocketNotification("DATA", body);
        			}
        		});
        
        		setTimeout(function() { self.getData(); }, this.config.refreshInterval);
        	},
        
        	socketNotificationReceived: function(notification, payload) {
        		var self = this;
        		if (notification === 'CONFIG' && self.started == false) {
        			self.config = payload;
        			self.sendSocketNotification("STARTED", true);
        			self.getData();
        			self.started = true;
        		}
        	}
        });
        
        1 Reply Last reply Reply Quote 0
        • ? Offline
          A Former User
          last edited by

          I think you can modify MMM-HTMLBox for your purpose. It can read local html file and show it on MM.
          [card:eouia/MMM-HTMLBox]

          1 Reply Last reply Reply Quote 0
          • J Offline
            jasondreher
            last edited by

            How do I get it to refresh? I added it to “refresh_interval_sec: 60,” but it does not seem to refresh. If I “Ctrl+R” i refreshes and shows changes.

            Other than that it works great!!!
            This is my test pi, the list from HTMLBox is in the upper right.
            0_1512583760228_2017-12-06-114646_1680x1050_scrot.png

            ? 1 Reply Last reply Reply Quote 0
            • ? Offline
              A Former User @jasondreher
              last edited by

              @jasondreher
              You are right. I did some mistakes about refreshing. (I didn’t test it. sorry)
              I think it was caused by caching.
              You can made hot-fix about that.

              In line 58 of MMM-HTMLBox.js

              xmlHttp.open("GET", url, true)
              

              modify it like this;

              xmlHttp.open("GET", url + "?" + Date.now(), true)
              

              I think it will work. sorry.

              1 Reply Last reply Reply Quote 1
              • J Offline
                jasondreher
                last edited by

                @Sean said in Module to display a local list?:

                xmlHttp.open(“GET”, url + “?” + Date.now(), true)

                I did this but no change, it still will not update…

                ? 1 Reply Last reply Reply Quote 0
                • ? Offline
                  A Former User @jasondreher
                  last edited by A Former User

                  @jasondreher
                  Weird. Is Your local file updated periodically? Can you show your config for this module?
                  I’ve tested it now, and it works definitely.

                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    jasondreher
                    last edited by

                    Darn it, I was changing the update time in the module but not the config. It works now, thanks for all your help, this is a fantastic module!!!

                    1 Reply Last reply Reply Quote 0

                    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                    With your input, this post could be even better 💗

                    Register Login
                    • 1 / 1
                    • 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