MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Little magic mirror (but not a mirror)

    Scheduled Pinned Locked Moved Show your Mirror
    10 Posts 7 Posters 3.4k Views 9 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      SJK
      last edited by

      Used an old kindle to display the info.

      I’ve got a Raspberry Pi that creates the magic mirror info and saves it as an image file, the kindle just downloads and displays the image every 5 minutes. Seems to work well so far.

      Phot.jpeg

      mumblebajM E 2 Replies Last reply Reply Quote 3
      • mumblebajM Offline
        mumblebaj Module Developer @SJK
        last edited by

        @SJK Very cool.

        Check out my modules at: https://github.com/mumblebaj?tab=repositories

        1 Reply Last reply Reply Quote 0
        • D Offline
          djgigabit
          last edited by

          That is really cool! I’m trying to use an old (unrootable) Kindle and am having trouble finding a way to do it that would hide the browser bar. This looks like something that might work out, though! Would you mind sharing a bit about how you got the MM to take an image and how you’re having the Kindle download it? I’m not much of a programmer so still trying to figure a lot of this out.

          H S 2 Replies Last reply Reply Quote 0
          • H Offline
            heronlen @djgigabit
            last edited by

            @djgigabit said in Little magic mirror (but not a mirror):

            That is really cool! I’m trying to use an old (unrootable) Kindle and am having trouble finding a way to do it that would hide the browser bar. This looks like something that might work out, though! Would you mind sharing a bit about how you got the MM to take an image and how you’re having the Kindle download it? I’m not much of a programmer so still trying to figure a lot of this out.

            Agreed, please share, that looks so good.

            1 Reply Last reply Reply Quote 0
            • S Offline
              SJK @djgigabit
              last edited by

              @djgigabit Can’t take any credit for the coding, and this is just various bits of software hacked together. :beaming_face_with_smiling_eyes:

              How to setup the Kindle and the script to grab the webpage came from Matt Healy (https://matthealy.com/kindle).

              I’ve done a couple of things different. I added a pause in the script for the Kindle (about 4 seconds) after the curl command, just to allow the magic mirror page to finish generating. The other difference is, I’m running the script on the same Raspberry Pi as the magic mirror, not the Heroku site. The cron script is set to run every 5 minutes, which is fine for the info I’m displaying.

              The magic mirror install is fairly normal, just needed to jam every thing into a small screen. Everything is ‘top_centre’ and then I just adjusted the margins to get it sitting nice. You have to start it in server mode ‘npm run server’ otherwise it will get upset that it does not have a screen to use.

              An idle thought that occurred to me - instead of using a Raspberry Pi, you could run both bits of software on your everyday PC/laptop. If it’s not powered on (or in the building) when the Kindle asks for an update, it will fail to get a new image, so it will just display the last image it downloaded.

              Hope this helps.

              D kayakbabeK 2 Replies Last reply Reply Quote 0
              • D Offline
                djgigabit @SJK
                last edited by

                @SJK Oh nice, thank you! This is going to be helpful. The Fully browser I was trying to use didn’t like the webview version and there was no way to update on the Kindle or the Nexus 7 I was attempting to use so this is good info, thanks!

                S 1 Reply Last reply Reply Quote 0
                • H Offline
                  harney
                  last edited by

                  very cool use of broken gadgets. less for landfill and looks awesome

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    SJK @djgigabit
                    last edited by

                    @djgigabit Here is my (sanatized) version of the index.js file from the web-to-kindle:

                    const express = require('express');
                    const path = require('path');
                    const puppeteer = require('puppeteer');
                    const execFile = require('child_process').execFile;
                    const fs = require('fs');
                    
                    const PORT = process.env.PORT || 3000;
                    
                    express()
                      .use(express.static(path.join(__dirname, 'public')))
                      .set('views', path.join(__dirname, 'views'))
                      .set('view engine', 'ejs')
                      .get('/', async (req, res) => {
                        const browser = await puppeteer.launch({ 
                            executablePath: '/bin/chromium-browser'
                            });
                        const page = await browser.newPage();
                        await page.setViewport({ width: 600, height: 800 });
                        await page.goto(process.env.SCREENSHOT_URL || '<web address of magicmirror>');
                    
                        await new Promise(r => setTimeout(r, 3000));
                    
                        await page.screenshot({
                          path: '/home/<user>/screenshot.png',
                        });
                    
                        await browser.close();
                    
                        await convert('/home/<user>/screenshot.png');
                        screenshot = fs.readFileSync('/home/<user>/screenshot.png');
                    
                        res.writeHead(200, {
                          'Content-Type': 'image/png',
                          'Content-Length': screenshot.length,
                        });
                        return res.end(screenshot);
                      })
                      .listen(PORT, () => console.log(`Listening on ${PORT}`));
                    
                    
                    function convert(filename) {
                      return new Promise((resolve, reject) => {
                        const args = [filename, '-gravity', 'center', '-negate', '-extent', '600x800', '-colorspace', 'gray', '-depth', '6', '-alpha', 'remove', '-level', '50x100%', filename];
                        execFile('convert', args, (error, stdout, stderr) => {
                          if (error) {
                            console.error({ error, stdout, stderr });
                            reject();
                          } else {
                            resolve();
                          }
                        });
                      });
                    }
                    

                    This is where I added the pause before it captures the screenshot. I also had to change the puppeteer.launch command as it was not a happy bunny running on a headerless server.

                    1 Reply Last reply Reply Quote 1
                    • kayakbabeK Offline
                      kayakbabe @SJK
                      last edited by

                      @SJK this is very cool! This method could be used for an eInk type display. It’s really making me think those old pi zeros could be very useful again.

                      1 Reply Last reply Reply Quote 0
                      • E Offline
                        esamecar @SJK
                        last edited by

                        This post is deleted!
                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post
                        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