• 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. 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: 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
    Jan 27, 2018, 10:28 PM
  • 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
    Jan 27, 2018, 8:10 PM
  • 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
    Jan 27, 2018, 7:48 PM
  • 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
    Jan 27, 2018, 5:50 PM
  • 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
    Jan 27, 2018, 3:42 PM
  • 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
    Jan 26, 2018, 11:04 PM
  • 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
    Jan 26, 2018, 10:48 PM
  • 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
    Jan 26, 2018, 10:39 PM
  • 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
    Jan 26, 2018, 10:19 PM
  • 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
    Jan 22, 2018, 9:29 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