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

    Posts

    Recent Best Controversial
    • RE: module that displays a certain text from a website, the text on the website is updated daily

      Now create MMM-Dnevni_citat.js
      Inside you need first to registar module

      Module.register("MMM-Dnevni_citat", {
      	defaults: {
      		updateInterval:  10 x  60 x 1000,       //  minute ,seconds ,milliseconds
      		//retryDelay: 5000          // not needed for now
      	},
      

      Then first function will be start function

         start: function () {
              Log.info("Starting module: " + this.name);
              requiresVersion: "2.1.0";
              this.loaded = false;
              this.scheduleUpdate();
      
          },
      

      with first function we are calling second ( scheduleUpdate) , how often will fetch data.

         scheduleUpdate: function () {
              setInterval(() => {
                  this.getData();
              }, this.config.updateInterval);
              this.getData();
          },
      

      Then we are calling getData function. Sending socketNotification to node_helper.

      getData: function () {
              this.sendSocketNotification(''GET_TEXT_DATA'', this.config);
          },
      

      Whe node_helper send back, next function will check if data is received and update DOM

      socketNotificationReceived: function (notification, payload) {
             if (notification === "TEXT_RESULT") {
                 this.textDataRecived = payload;
                 this.loaded = true;
            },this.updateDom();
      

      Now only is left to create DOM

          getDom: function () {
              var wrapper = document.createElement("div");
      
              if (!this.loaded) {
                  wrapper.innerHTML = "LOADING";
                  return wrapper;
              }
              if (this.loaded) {
             // here to add elements and styling
                 return wrapper;
             }
          },
      
      posted in Requests
      L
      lolo
    • RE: module that displays a certain text from a website, the text on the website is updated daily

      This should be your node_helper.

      const NodeHelper = require("node_helper");
      const cheerio = require("cheerio");
      const request = require('request');
      
      module.exports = NodeHelper.create({
      
          start: function () {
              self = this;
              console.log("Starting node_helper for: " + this.name);
          },
      
          getData: function () {
              const url = 'https://wol.jw.org/hr/wol/h/r19/lp-c';
              request({
                  url: url,
                  method: 'GET'
              }, (error, response, body) => {
                  if (error) {
                      return console.error(error)
                  };
      
                  var $ = cheerio.load(body);
                  //console.log($.html());
                  const data = $('div[class="tabContent"]').first();
      
                  let header = $(data).find('h2').text();
                  let title = $(data).find('p').first().text();
                  let text = $(data).find('div.pGroup>p').text();
                  //console.log(header,title,text);
                  var recivedData = {
                      header,
                      title,
                      text
                  }
      			console.log(recivedData);
                  
      			self.sendSocketNotification('TEXT_RESULT', recivedData);
              });
          },
      
          socketNotificationReceived: function (notification, payload) {
      
              if (notification === 'GET_TEXT_DATA') {
                  self.getData();
              }
          },
      });
      
      
      posted in Requests
      L
      lolo
    • RE: MMM-NewPIR v3

      This should work

      cd ~/MagicMirror/modules/MMM-NewPIR
      
      git pull
      
      npm run update
      
      sudo reboot
      
      posted in System
      L
      lolo
    • RE: module that displays a certain text from a website, the text on the website is updated daily

      Try to do something with this code. It will retrieve data from current day. Modifying that node_helper is not great idea.

          const url=  'https://wol.jw.org/hr/wol/h/r19/lp-c';
          request({
              url: url,
              method: 'GET'
              }, (error, response, body) => {
                  if (error) {
                      return console.error(error)
                  };
               
                  var $ = cheerio.load(body); 
                  //console.log($.html());  
                  const data =  $('div[class="tabContent"]').first();
                          
                  let header = $(data).find('h2').text();
                  let title = $(data).find('p').first().text();
                  let text = $(data).find('div.pGroup>p').text();
                  //console.log(header,title,text);
                  var recivedData={
                      header,
                      title,
                      text
                  };
                  //console.log(recivedData);
                  
            
          });   
      
      posted in Requests
      L
      lolo
    • RE: module that displays a certain text from a website, the text on the website is updated daily

      It gonna be harder than u think as your text is changing daily. Just follow the the pattern.
      Every day this is changed( https://wol.jw.org/hr/wol/h/r19/lp-c).
      new day new text.
      Text is in :
      div id=“dailyText”
      but if you ignore reference in text as (Mat. 16:24, 25; Ivan 15:20) located in a class it’s gonna be more easier.
      And with cheerio u can complete this.

      posted in Requests
      L
      lolo
    • RE: Local .ics file access error

      I have local calendar and is working fine.
      Copy file.ics in modules folder and add to config

      url: "webcal://localhost:8080/modules/file.ics" 
      

      or

      url: "webcal://0.0.0.0:8080/modules/file.ics" 
      
      posted in Troubleshooting
      L
      lolo
    • RE: Local .ics file access error

      Should be like this .

      url: "webcal://0.0.0.0:8080/file.ics"
      
      posted in Troubleshooting
      L
      lolo
    • RE: MMM-NewPIR v3

      Thx. Even one my module have problem with that. For now I will keep it as false.

      posted in System
      L
      lolo
    • RE: MMM-NewPIR v3

      @Bugsounet With new version of MagicMirror I decides to try this module.
      Running rpi4 with HC-SR501 sensor.
      Can you please explain me how exactly ecoMode working. I have some problems with that enabled true. I’m still trying to figure out exactly problem but no luck. I’m using MMM-Globe by Eunanibus and its not reloading (not showing ) after monitor is turn on and sometime even monitor doesn’t wont to turn on. Should I just keep this option false? With ecoMode false at the moment everything is working fine.
      Anyway, great work and thank you for your contribution.

      posted in System
      L
      lolo
    • RE: MMM-HNB-Exchange

      Thank you.

      posted in Productivity
      L
      lolo
    • 1 / 1