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

    Posts

    Recent Best Controversial
    • RE: show integer logs from python script as diagram in MM ?

      I have been following this, but I didn’t have time to comment.

      You asked about the. json file. Simplyfied, it’s a file that holds a (JS) object for data sharing.

      {{date:"2018-01-01", litre:500},{date:"2018-01-02", litre:498},{date:"2018-01-03", litre:495}}
      

      Probably comparable to what you did with your txt file.
      For a working solution, that would actually be enough. Grab the json, handle the object, print the result with highcharts.
      To me, the SQL db seems a bit “heavy weight” for such a simple use case, but it’s solid if you can make it work. Just my opinion.

      posted in Requests
      D
      doubleT
    • RE: Trim the fat in a JSON file?

      @DeathChicken said in Trim the fat in a JSON file?:

      I just want the 2.1 output

      So the value of the key “price”. I haven’t looked at the module’s code, but I think you have to say “price” instead of “key4”.

          values: ["price"]
      
      posted in Troubleshooting
      D
      doubleT
    • RE: Wrote 2 modules already, but don't know where to start for another...

      Check the code of those modules that can switch modules on/off (if they don’t just hide them, that is).

      Basically, after changing the config, the browser has to be refreshed in order to load the the new configuration. What you want could be compared to that. Instead of removing a module, you change the language.

      posted in Development
      D
      doubleT
    • RE: show integer logs from python script as diagram in MM ?

      I use highcharts to make a diagram for my gas station price module. It’s quite easy to implement and use if you have the data in an object.

      posted in Requests
      D
      doubleT
    • RE: Changing compliments

      Weird, it sounds like there shouldn’t be a problem at all.
      Do you have the possibility to edit the file externally and replace it? For example via FTP.
      Btw. how do you save the file?

      posted in Troubleshooting
      D
      doubleT
    • RE: Changing compliments

      So there’s a config and when you run the MagicMirror it says there’s a config error. And sudo nano config.js from within MagicMirror/config/ doesn’t work? Cann you go to MagicMirror/config/ and show us what it says when you put in ls -l? (that’s a small letter ‘L’) which will list files with their rights/owners.

      posted in Troubleshooting
      D
      doubleT
    • RE: Changing compliments

      That’s the correct file.
      Try sudo nano MagicMirror/config/config.js if you haven’t used sudo, that gives you advanced rights.

      Did you create config.js? I have a suspicion. At the beginning, there’s no config.js, you have to create it. But there’s a sample file.

      Let’s check.
      You’re in the dir MagicMirror,
      cd config change the directory to config
      ls list the dir contents. There should be a config.js.sample. If there is also a config.js, ignore the next step.
      sudo cp config.js.sample config.js makes a copy of config.js.sample and creates config.js
      ls should now show both files.
      sudo nano config.js to edit the config.js

      posted in Troubleshooting
      D
      doubleT
    • RE: Changing compliments

      @Stacy said in Changing compliments:

      @lavolp3 so how do I get to the modules to change them?

      All the modules get their information from the config.js cruunnerr and Mykle mentioned. You don’t need to change anything in the module folders.

      If the module code is broken at the moment, you can rebuild it from – or completely replace it with – the original here if you don’t want to start over again.

      This is the basic code for the compliment module to be added/changed/edited in the MagicMirror/config/config.js :

          {
              module: "compliments",
              position: "lower_third",	// This can be any of the regions.
                                              // Best results in one of the middle regions like: lower_third
              config: {
                  compliments: {
                      anytime: [
                          "Hey!",   // properties are followed by commas – most common mistake
                          "Hello."  // last property within brackets doesn't get a comma
                      ],
                      morning: [
                          "Hey!"
                      ],
                      evening: [
                          "Hey!"
                      ]
                  }
              }
          } // add a comma (,) if another module's config is following
      

      See the comments in the code. The most common mistakes are missing commas or missing brackets.

      posted in Troubleshooting
      D
      doubleT
    • RE: MMM-SwissStationboard

      Ah, yes of course, it will still only call the maximum number of entries. That’s a bit more challenging.

      posted in Troubleshooting
      D
      doubleT
    • RE: MagicMirror: Changing font colors

      It’s body {}, it addresses the whole html body (everything) and is empty in this case. It’s probably just an example.

      posted in Custom CSS
      D
      doubleT
    • RE: MagicMirror: Changing font colors

      Check my answer to that exact same question here, learning css, to learn a bit about addressing elements in css.

      Basically, .module.clock addresses the element with both classes .module and .clock. And .module.clock .time addresses the element with the class .time sitting inside that element with both classes .module and .clock.

      You don’t have to restart the Pi, not even the MM app, for some css changes. A refresh should do it. I don’t know why it shouldn’t work if you got the correct file css/custom.css and copied that exact code from j.e.f.f.

      posted in Custom CSS
      D
      doubleT
    • RE: Timetable with (almost) static data

      Ah, true. If that works for you, I’d leave it at that. But then again, it’s always good to learn something new.
      Do you want to try it yourself and maybe ask for help when you get stuck? Or maybe this would be an excellent case for a tutorial, I could try to do something like that.

      posted in Requests
      D
      doubleT
    • RE: Timetable with (almost) static data

      Or maybe I derailed it when I looked at the question of “how to get the csv” after the thread already went to the iframe solution? :D
      @AxLed Did you get the php page shown via iframe module?

      A. Show the .php page via node

      A. will not be able to show the php page via node – if you mean my suggestion. It will just get all echo’d content from the php file into the js module. So in this case it’s an over-complicated way of receiving the csv file into a module.

      B. use the node_helper.js to open a .csv file and loop through the datas.

      The node_helper.js should send the whole package back to the module.js and there it should loop through the datas.

      If you have the php knowledge to build a page that reads a csv and shows the content, it shouldn’t be too hard to get into the necessary js. To build a module for the MM, the Readme in the module folder is the first step to go to.

      posted in Requests
      D
      doubleT
    • RE: MMM-SwissStationboard

      Looking at the code it seems like “unreachable” trains get the class “.darkgrey”. Without changing the code of the module, you can add this line to your MagicMirror/css/custom.css :

      div.module.MMM-SwissStationboard .darkgrey { display: none; }
      

      Going further:

      If you want to change the code and care about making it configurable, add hideUnreachable: true to the config of the module and hideUnreachable: false to the defaults in the module’s js. Similar to the other if switch, add this at line 105:

      if ((diff > this.config.minWalkingTime) || (diff < this.config.minWalkingTime && this.config.hideUnreachable != true)) {
          // all the code from the original for-loop from line 106 on
          // you can leave the if switch at line 110 - 120
          // this way the unreachable trains will be darkgrey via css when hideUnreachable is not active
          // shows trains:
          // if diff is greater than minWalkingTime (= reachable) OR
          // if diff is smaller than minWalkingTime AND hide is not true (is false)
      }
      

      If you don’t care about config, default and css and want to change the code, just add an if switch at line 105 similar to line 110 but with switched signs < to >:

      if (diff > this.config.minWalkingTime) {
          // everything from the original for-loop from line 106 on 
          // only adds results that have a diff greater than your minWalkingTime
          // you can leave out the if switch at line 110 - 120 in this case
      }
      

      I didn’t test all of this, though.

      posted in Troubleshooting
      D
      doubleT
    • RE: MMM-PIR-Sensor: "Welcome back" message

      I don’t have a PIR to test, but looking at the code, I’d suggest trying something like this:

      You need a DOM element to show the message in. You can borrow it from the default module helloworld and modify it:

      getDom: function() {
          var wrapper = document.createElement("div");
          wrapper.setAttribute("id", "welcome-message");
          wrapper.innerHTML = "";
          return wrapper;
      }
      

      And then, based on self.sendSocketNotification("USER_PRESENCE", true); in the node_helper.js you add
      this to the MMM-PIR-Sensor.js :

      socketNotificationReceived: function(notification, payload) {
          if (notification === "USER_PRESENCE"){
              this.sendNotification(notification, payload)
      //  new:
              if (payload === true) {
              document.getElementById("welcome-message").innerHTML = "Welcome back!";
              setTimeout(() => {
                  this.removeMessage();
              }, (1*60*1000); // = 60 seconds
          }
      },
      removeMessage: function(payload) {
          document.getElementById("welcome-message").innerHTML = "";
      }
      

      If you use it like this, the message is only shown for 1 * 60 * 1000 miliseconds = 60 seconds (set as desired) and then removed.

      This is all untested but hopefully gives you some clues where to look and work on the code.

      posted in Troubleshooting
      D
      doubleT
    • RE: Timetable with (almost) static data

      Actually, I wasn’t really thinking about loading a page and displaying it (in an iFrame) but I rather looked at the questions of loading file contents and suggested the runner.exec child process because php was specifically mentioned (I don’t think PHP is necessary at all).

      If we’re talking about HTML, I’d agree with you (also without testing, though). But for PHP within Node.js: That won’t work, you’d have to have a PHP server running parallel to node and address it, etc. My suggestion (runner.exec child_process) doesn’t run a server but executes that one file with PHP and returns what it parsed.

      posted in Requests
      D
      doubleT
    • RE: Need Guidence, Or Someone To Make A Module For Me, Uses GPIO

      Maybe you saw this thread. I made a module for duedahlb that shows a full size image when the module MMM-Button registers a button press. I think that could be a good start to study and maybe reverse engineer some parts from both modules.

      posted in Requests
      D
      doubleT
    • RE: Powering my mirror?

      I put a hole in the drywall and made a neat little sunk in box with outlets for power (with a PIR for the monitor) and usb (for the pi 24/7) – no visible cables – but I know sometimes that’s not possible.

      My plan b was a cable that I’d sleeve really nice so it doesn’t look too bad that goes to small cable box where the cable is split and connected with a plug for the monitor (or in your case the psu) and a converter with a usb plug. Just be careful when working with electricity. I learned a painful lesson on that when I built my Mirror.

      posted in Hardware
      D
      doubleT
    • RE: Timetable with (almost) static data

      Node can execute a php – if a php.ini is in the PATH – with this in the node_helper.js :

      const runner = require("child_process");
      runner.exec("php " + proxy + " " + params, function(err, data, stderr) {
      //         ("php timetable.php parameter", function(err, data, stderr) {
          var content = data; // "Clean your room - now!"
          this.workWithTheData(content);
      });
      

      timetable.php :

      < ? php // remove spaces
      $params = explode(",", $argv[1]); // example, you can leave parameters out (see above)
      $content = "Clean your room – now!";
      echo $content;
      ?>
      

      Now that we know we can, let’s talk about if we should: I like it, I use it for a proxy to call APIs while ignoring CORS. BUT I don’t think it makes sense in this case! It’s like using a hammer to fix a loose screw.

      To show a static website in the iframe, HTML is enough. Do you really need server side scripts?

      If you want a csv, use this in the node_helper.js :

      const fs = require("fs"); // before module.exports = ...
      
      getTimeTable: function() {
          var rawdata = fs.readFileSync('modules/my-module/file.json'); // or txt or csv
          var timetable = JSON.parse(rawdata); // in this case
          this.sendSocketNotification("Response", timetable);
      }
      

      EDIT: I know that for users with basic HTML or even PHP knowledge, the iFrame solution is an easy win. Use runner or fs if you want to import data directly into your own module.

      posted in Requests
      D
      doubleT
    • RE: How can I remove all posts saying "This topic is deleted!" ?

      Not a direct solution, but if you’re really annoyed, there are browser addons that run individual JavaScript snippets for you where you can say, for example:

      var checkHeadExist = setInterval(function() {
          if (document.querySelector('head')) {
              clearInterval(checkHeadExist);
              styleElem = document.createElement('style');
              styleElem.setAttribute('id', 'counter-styles');
              styleElem.type = 'text/css';
              styleElem.appendChild(document.createTextNode('.deleted {display: none;}'));
              document.querySelector('head').appendChild(styleElem);
          }
      }, 100); // check every 100ms
      

      Try it out, Chrome has a snippet tool in the developer tools, in Firefox it’s called “JS environment” if I’m not mistaken. But these only work until you reload (in Chrome, you can save them). There are addons that automatically execute them for you.

      posted in General Discussion
      D
      doubleT
    • 1 / 1