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

    Posts

    Recent Best Controversial
    • RE: Disable auto-updates?

      There is no automatic update of any of these three sources.
      You receive notifications only, if there is an update for magic mirror or a module. To get rid of this you can simply remove the update notification module from your config file

      posted in General Discussion
      yawnsY
      yawns
    • RE: Help needed simple API based module

      great. Now tidy up your code ;) and present your module in modules showcase

      posted in Development
      yawnsY
      yawns
    • RE: How do I delete my MagicMirror Forum Account?

      You can’t. Only @administrators (not Moderators) can delete your account.
      Just out of curiosity: why do you want to leave? :)

      posted in General Discussion
      yawnsY
      yawns
    • RE: Display values from a JSON file hosted online

      Quick and dirty, but should get you going :)

      You have to use the node_helper, because using XMLHttpRequest would result in an “origin error”.

      MMM-backlog.js

      /* global Module */
      
      /* Magic Mirror
       * Module: MMM-backlog
       *
       * By Stefan Krause http://yawns.de
       * MIT Licensed.
       */
      
      Module.register('MMM-backlog',{
      
      	defaults: {
      		units: config.units,
      		animationSpeed: 1000,
      		updateInterval: 1000 * 3600, //update every hour
      		refreshInterval: 1000 * 60 * 10, //refresh every minute		
      		timeFormat: config.timeFormat,
      		lang: config.language,
      
      		initialLoadDelay: 0, // 0 seconds delay
      		retryDelay: 2500,
      
      		fileUrl: "https://www.dropbox.com/s/k1t6mjjc3knxp3a/dataset.json?raw=1"
      	},
      
      	// 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("div");
      
      		if (!this.loaded) {
      			wrapper.innerHTML = this.translate('LOADING');
      			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.graph;
      		var content = document.createElement("div");
      		content.innerHTML = "";	
      		
      		for (var i in t.datasequences) {
      			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);
      	}
      
      });
      

      node_helper.js

      'use strict';
      
      /* Magic Mirror
       * Module: MMM-backlog
       *
       * By Stefan Krause http://yawns.de
       * MIT Licensed.
       */
      
      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;
      		}
      	}
      });
      
      
      posted in Development
      yawnsY
      yawns
    • MMM-icanhazdadjoke - Fetch a random joke

      Description

      Per request by WNG_Brady this module fetches a random joke in JSON format from icanhazdadjoke.com and shows it on screen.
      Please note the jokes differ in length. So you should use the maxWidth value to adjust it to your specific MagicMirror layout and to avoid overlapping with other modules. Based on the location you choose maxWidth of course differ. If you use bottom_bar you could use the entire width of the screen if you want to. If you use it in between other modules you should set a limit.

      Download

      [card:yawnsde/MMM-icanhazdadjoke]


      Version history

      Initial release

      posted in Fun & Games
      yawnsY
      yawns
    • RE: call API (no CORS), used to do it with php proxy

      Instead of using the XMLHttpRequest in your main module file you use request() in node_helper

      Take a look at this code: https://forum.magicmirror.builders/topic/5743/mmm-solartemp

      I’m sure you will understand the workflow. If not, just let us know what you have and where you are stuck

      posted in Development
      yawnsY
      yawns
    • RE: Fuel Monitor for Austria

      @strawberry-3.141 said in Fuel Monitor for Austria:

      @schlachtkreuzer6 would be great if someone is able to integrate this into my fuel module for germany :)

      That was my first thought as well. Would require a switch to choose between Germany and Austria and as such send different requests. I might be able to look at that on Sunday

      posted in Requests
      yawnsY
      yawns
    • RE: Prepping my first build. Care to check my work?

      @3DPrintedWaffles

      1. Most tv’s show stuff like “signal lost” on screen when you disable hdmi in raspberry to hide the screen, and in some tv’s you cannot disable that
      2. Cheap tv’s have a poor resolution. The 32" I bought for some bucks only runs 1366x768 and text on your mirror (calendar for example) looks blurry.

      But you can still live with it. I will use mine to see if we actually use the magic mirror at all. Then I can still invest money in a better display add replace it

      posted in Development
      yawnsY
      yawns
    • RE: FB Bday List

      @iMAGiC said in FB Bday List:

      @plybz18 in your fb events, you can copy bday link form bottom left.

      And then add it as a calendar :)

      posted in Requests
      yawnsY
      yawns
    • RE: regions...

      Shouldn’t the index.html be changed as well to add additional divs with his classes?

      posted in Development
      yawnsY
      yawns
    • 1 / 1