• 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
  1. Home
  2. k-0
  3. Posts
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.
K
Offline
  • Profile
  • Following 1
  • Followers 0
  • Topics 2
  • Posts 8
  • Groups 0

Posts

Recent Best Controversial
  • RE: Canteen-module // Mensa-Modul

    @lavolp3
    Ah, i didn’t know this.

    Now it works with your example! :)

    Unfortunately he takes the current date and not the date of the actual meal. (keyword: switchingTime). If and else apparently don’t work in the getTemplateData function. Or am I wrong?

    posted in Requests
    K
    k-0
    Dec 29, 2019, 8:25 PM
  • RE: Canteen-module // Mensa-Modul

    Hi @lavolp3 ,

    i added

    <header>{{ config.canteenName }}, {{ moment().format("dddd") }}</header>
    

    to my MMM-Canteen.njk. But I always get “undefined”.

    It works with

    {{ config.canteenName }}
    

    It seems there is a problem with moment() in the header. Do you have an idea?

    posted in Requests
    K
    k-0
    Dec 20, 2019, 10:49 AM
  • RE: Canteen-module // Mensa-Modul

    Hi Dirk,

    I could test it today and I really love it! Thank you so much!

    0_1575297143322_mmm.PNG

    I already updated the ReadMe and added the “€” to the price in the .njk-file.

    It would be nice to have the date in the header on which the meal refers. :P

    Cheers,
    Kevin

    EDIT: I think that a option to show the whole week is nice, especially for ppl who have only one or two meals per day. Otherwise it will be to much informations to show.

    posted in Requests
    K
    k-0
    Dec 2, 2019, 2:35 PM
  • RE: Canteen-module // Mensa-Modul

    I couldn’t find my old code (node_helper.js and module.js files) from my first attempts, but i created new files and merged the code from @lavolp3.
    Here is the github url: https://github.com/k-0/MMM-Canteen

    Yes, the main problem was handling the asynchrous call. But i’m pretty sure, that there are more problems. :P

    posted in Requests
    K
    k-0
    Nov 19, 2019, 4:22 PM
  • RE: Canteen-module // Mensa-Modul

    Here is my working code (console-output works…).
    The outcommented code is for the second canteen and has no relevance.

    
    setTimeout(function() {
    var request = require('request');
    var heute;
    if ((new Date().toISOString().substr(11,2) < 16)) {
    	 heute = new Date().toISOString().substr(0,10);
    }
    else
    {
    	 heute = new Date();
    	 heute.setDate(heute.getDate()+1);
    	 heute= heute.toISOString().substr(0,10);
    
    }
    var cnt = 0;
    request({
      url: 'https://openmensa.org/api/v2/canteens/838/days/'+heute+'/meals',
      json: true
    }, function(error, response, body) {
    	 console.log('\nCAFETERIA EAH am ' +  heute.substring(8,10)+ '.'+heute.substring(5,7) +'.'+heute.substring(0,4)+':');
    	if (body.length < 1){
    		console.log('Heute geschlossen!')
    	}
    	else {
    	  while (body.length > cnt) {
    		console.log(body[cnt].name);
    		console.log(body[cnt++].prices.employees.toFixed(2) +'€');
    		}				
    	}
    });
    //var cntr = 0;
    //request({
    //  url: 'https://openmensa.org/api/v2/canteens/76/days/'+heute+'/meals',
    //  json: true
    //}, function(error, response, body) {
    //	 	if (body.length < 1){
    //		console.log('Heute geschlossen!')
    //	}
    //	else {
    //	 console.log('\nMENSA ZEISS am ' +  heute.substring(8,10)+ '.'+heute.substring(5,7) +'.'+heute.substring(0,4)+':');
    //	  while (body.length > cntr) {
    //		console.log(body[cntr].name);
    //		console.log(body[cntr++].prices.employees.toFixed(2)+ ' €');
    //	}}
    //});
    }, 6000);
    

    The output is:

    Z:>node curl.js

    CAFETERIA EAH am 18.11.2019:
    Backleberkäse mit Paprikasoße, Balkangemüse und 1 Beilage
    4.00€
    Seelachsfilet mit Remouladensoße, Pommes frites und Salat
    4.60€
    Orientalische Linsen-Kürbis-Birnen-Suppe mit Brötchen
    4.00€

    posted in Requests
    K
    k-0
    Nov 18, 2019, 8:40 AM
  • Canteen-module // Mensa-Modul

    *** Deutsche Version darunter // German version below ***

    Hi guys,

    i tried to develop a canteen-modul, which shows the menu including the prices of our canteen. It’s based on openmensa.org, a website which host most canteens from different universities in germany and switzerland.
    See this link from my first try: https://forum.magicmirror.builders/topic/10932/module-shows-no-text
    But I couldn’t solve my problem with the asyncronous request yet.
    Maybe someone can help me or want to implement this modul. :)


    Hallo Leute,

    ich habe versucht ein Kantinen-Modul zu entwickeln, dass das Menü inklusive der Preise unserer Mensa anzeigt. Es basiert auf openmensa.org, einer Website, auf der die meisten Kantinen verschiedener Universitäten in Deutschland und der Schweiz untergebracht sind.
    Hier ist der Link von meinem ersten Versuch ein solches Modul zu implementieren: https://forum.magicmirror.builders/topic/10932/module-shows-no-text
    Aber ich konnte mein Problem mit der asynchronen Anfrage leider nicht lösen.
    Vielleicht kann mir jemand helfen oder möchte dieses Modul implementieren. :)

    posted in Requests
    K
    k-0
    Nov 15, 2019, 10:42 PM
  • RE: Module shows no text.

    Can you (or someone else) give me an example? I have no experience with async programming.
    I tried to solve this problem with setTimeout(function() { mycode }, 6000) , but it doesn’t work.

    posted in Development
    K
    k-0
    Aug 15, 2019, 11:08 AM
  • Module shows no text.

    Hi everybody! :upside-down_face:

    I tried to write a module for the first time. It was supposed to show the menu including the prices of the canteen at our university, but for some reason I don’t get an output. I tried to run the logic and a test module with „hello world“ and both worked. I attached to this message my code and I hope that someone can help me out with this issue.

    Here ist my code:

    Module.register("MMM-Test", {
      defaults: {},
      start: function () {
    	this.count = 0
      	var timer = setInterval(()=>{
        		this.updateDom()
        		this.count++
      		}, 30000) // 1000 = 1s
    	},
      getDom: function() {
        var element = document.createElement("div")
      element.className = "myContent"
        var subElement = document.createElement('table');
        var tr = document.createElement('tr');
        var td1 = document.createElement('td');
        var td2 = document.createElement('td');
        var request = require('request');
        var text1;
        var text2;
        var heute = new Date().toISOString().substr(0,10);
        var cnt = 0;
     request({
        url: 'https://openmensa.org/api/v2/canteens/838/days/'+heute+'/meals',
        json: true
     }, function(error, response, body) {
            element.innerHTML = ('\nCAFETERIA EAH am ' +  heute.substring(8,10)+ '.'+heute.substring(5,7) +'.'+heute.substring(0,4)+':');
    	if (body.length < 1){
    		text1 = document.createTextNode('Heute geschlossen!');
    	}
    	else {
    	  while (body.length > cnt) {
    		text1 = document.createTextNode((body[cnt].name));
    		text2 = document.createTextNode(body[cnt++].prices.employees.toFixed(2) +' €');
    		}
    	}
    });
        td1.appendChild(text1);
        td2.appendChild(text2);
        tr.appendChild(td1);
        tr.appendChild(td2);
        subElement.appendChild(tr);
        subElement.id = "COUNT"
        element.appendChild(subElement)
    return element
    },
      notificationReceived: function() {},
      socketNotificationReceived: function() {},
    })
    
    
    posted in Development
    K
    k-0
    Aug 8, 2019, 2:53 PM
  • 1 / 1
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