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

    Posts

    Recent Best Controversial
    • HTTP Server for streaming podcasts / news / volume

      Dear fellow Mirror Designers,

      I wasn’t sure where to put this so I will post it here. From various sources I created a small python httpserver that changes the mirrors volume, starts a podcast (100 Seconds german news, when brushing your teeth:grimacing_face: ) or opens a live stream. This is the code, nothing special but may be helpful for some of you.

      I use FHEM and Philips Hue Dimmer Switches to control it:

      0_1540136723272_IMG_20181021_174249.jpg

      Uses:
      python3, livestreamer, omxplayer

      #!/usr/bin/python3 -u
      
      host_name = '10.0.1.49'  # Change this to your Raspberry Pi IP address
      host_port = 8000
      proc = ''
      
      import RPi.GPIO as GPIO
      from pathlib import Path
      import os
      import subprocess
      import signal
      from subprocess import call
      from time import sleep
      from http.server import BaseHTTPRequestHandler, HTTPServer
      
      
      
      
      class MyServer(BaseHTTPRequestHandler):
      
          def do_HEAD(self):
              self.send_response(200)
              self.send_header('Content-type', 'text/html')
              self.end_headers()
      
          def do_GET(self):
              global proc
              html = '''
                 <html>
                 <body style="width:960px; margin: 20px auto;">
                 <h1>Magic Mirror Control</h1>
                 <p>Current GPU temperature is {}</p>
                 <p>Podcast: <a href="/play">Play</a> <a href="/stop">Stop</a></p>
                 <p>ARD Livestream: <a href="/ard">Play</a> <a href="/stop">Stop</a></p>
                 <p>Volume: <a href="/down">down</a> <a href="/up">up</a></p>
                 <p>System: <a href="/shutdown">Shutdown</a> <a href="/restart">Restart</a></p>
                 <div id="podcast-status"></div>
                 <script>
                     document.getElementById("podcast-status").innerHTML="{}";
                 </script>
                 </body>
                 </html>
              '''
              temp = os.popen("/opt/vc/bin/vcgencmd measure_temp").read()
              self.do_HEAD()
              status = ''
              if self.path=='/':
                  #GPIO.setmode(GPIO.BCM)
                  #GPIO.setwarnings(False)
                  #GPIO.setup(17, GPIO.IN)
                  status='nothing'
              elif self.path=='/play':
                  if proc=='':
                      my_file = Path("/home/pi/MagicMirror/video.mp4")
                      if my_file.is_file():
                          statinfo = os.stat('/home/pi/MagicMirror/video.mp4')
                          if statinfo.st_size > 0:
                              proc = subprocess.Popen(["omxplayer", "-o", "alsa:hw:ALSA", "--no-osd", "/home/pi/MagicMirror/video.mp4"], preexec_fn=os.setsid)
                              status='Playing Podcast'
                          else:
                              proc = subprocess.Popen(["omxplayer", "-o", "alsa:hw:ALSA", "--no-osd", "/home/pi/MagicMirror/Loading.mp4"], preexec_fn=os.setsid)
                              status='Not yet available'
                      else:
                          proc = subprocess.Popen(["omxplayer", "-o", "alsa:hw:ALSA", "--no-osd", "/home/pi/MagicMirror/Loading.mp4"], preexec_fn=os.setsid)
                          status='Not yet available'
                  else:
                      status='Stopping Podcast'
                      os.killpg(os.getpgid(proc.pid), signal.SIGTERM)
                      proc=''
              elif self.path=='/ard':
                  if proc=='':
                      proc = subprocess.Popen(["livestreamer", "hlsvariant://daserste_live-lh.akamaihd.net/i/daserste_de@91204/master.m3u8", "best", "-vnp", "omxplayer -o alsa:hw:ALSA --no-osd --timeout 20"], preexec_fn=os.setsid)
                      status='Playing ARD Livestream'
                  else:
                      status='Stopping Stream'
                      os.killpg(os.getpgid(proc.pid), signal.SIGTERM)
                      proc=''
              elif self.path=='/stop':
                  if proc!='':
                      status='Stopping Podcast'
                      os.killpg(os.getpgid(proc.pid), signal.SIGTERM)
                      proc=''
                  else:
                      status='Nothing to stop'
              elif self.path=='/shutdown':
                  status='Shutdown'
                  subprocess.Popen(["sudo", "shutdown", "-h", "now"], preexec_fn=os.setsid)
              elif self.path=='/restart':
                  status='Restart'
                  subprocess.Popen(["sudo", "reboot"], preexec_fn=os.setsid)
              elif self.path=='/down':
                  status='Volume down'
                  subprocess.Popen(["amixer", "set", "Master", "12%-"], preexec_fn=os.setsid)
              elif self.path=='/up':
                  status='Volume up'
                  subprocess.Popen(["amixer", "set", "Master", "12%+"], preexec_fn=os.setsid)
              self.wfile.write(html.format(temp[5:], status).encode("utf-8"))
      
      
      if __name__ == '__main__':
          http_server = HTTPServer((host_name, host_port), MyServer)
          print("Server Starts - %s:%s" % (host_name, host_port))
      
          try:
              http_server.serve_forever()
          except KeyboardInterrupt:
              http_server.server_close()
      
      
      posted in General Discussion
      Y
      yep_DD
    • RE: Strip Down Guide for BenQ 28" VA Monitor GC2870H

      @Adrien ah, okay I see… yes that might be a problem in my case it works just fine. I will see about the boot time tomorrow.

      posted in Hardware
      Y
      yep_DD
    • RE: Strip Down Guide for BenQ 28" VA Monitor GC2870H

      @Adrien No problem, I am pretty sure it should work but I have not tried it. I might in the future. I am working on a few other bugifxes as well (amplifier only turns on when sound is played and stuff like that). I also suggest to use the microwave / radar sensor instead of the PIR. it is much cleaner and can go behind the mirror.

      Regarding the OSD, instead of cutting wires to the backlight this seems like a valuable option. At the moment I can’t try this (I need a friend to help me take down the mirror as it is too heavy), but I will tomorrow: https://www.youtube.com/watch?v=y86AXOZwlgU (TL;DW: press menu button while turning monitor on and disable logo)

      posted in Hardware
      Y
      yep_DD
    • RE: Strip Down Guide for BenQ 28" VA Monitor GC2870H

      @adrien Hi Adrien, that was my initial plan but I use the two relays now for my speakers to avoid the initial crack sound when powering on the amplifier und I use one relay for the monitor power supply and one for the amplifier.

      posted in Hardware
      Y
      yep_DD
    • RE: Execute script (GPIO Relay) based on if sound is being played
      while sleep 1; do
        if grep -q 'RUNNING' '/proc/asound/card0/pcm0p/sub0/status';
        then
          echo "Running!"
        else
          echo "Not Running!"
        fi
      done
      

      this seems to work but the amplifier produces a too loud cracking sound when switching on, I have two spare relais und my MagicMirror, I will hook up the speakers to those and try again.

      posted in Troubleshooting
      Y
      yep_DD
    • Execute script (GPIO Relay) based on if sound is being played

      Hi guys, I want to monitor if audio is being played, e.g:

      cat /proc/asound/card*/pcm*/sub*/status
      

      And if any status contains running I want to execute a script (in my case turn on the amplifier). I want a simple solution and initially I thought it might be possible with udev or python or bash. Does any of you have a great and easy idea?

      Thanks

      posted in Troubleshooting
      Y
      yep_DD
    • RE: High CPU load of electron and MM freezes

      running your magic mirror in vertical mode? try horizontal and check again.

      posted in Troubleshooting
      Y
      yep_DD
    • RE: Updating problem: "commit your changes or stash them before you can merge" ???
      git stash //stash your changes and save them
      git pull //update to current version
      git stash pop //merge your stash back
      
      posted in Troubleshooting
      Y
      yep_DD
    • RE: Strip Down Guide for BenQ 28" VA Monitor GC2870H

      I am just going to follow up on that, I found a different solution. I am using a HUE Dimmer Switch that is controlled via FHEM and it controls a python script running on MagicMirror to play my podcast and change the volume:

      (I found that script somewhere on github and modified it a bit)

      #!/usr/bin/python3 -u
      
      host_name = '10.0.1.49' 
      host_port = 8000
      
      import RPi.GPIO as GPIO
      import os
      import subprocess
      import signal
      from subprocess import call
      from time import sleep
      from http.server import BaseHTTPRequestHandler, HTTPServer
      
      
      
      
      class MyServer(BaseHTTPRequestHandler):
      
          def do_HEAD(self):
              self.send_response(200)
              self.send_header('Content-type', 'text/html')
              self.end_headers()
      
          def do_GET(self):
              global proc
              html = '''
                 <html>
                 <body style="width:960px; margin: 20px auto;">
                 <h1>Magic Mirror Control</h1>
                 <p>Current GPU temperature is {}</p>
                 <p>Podcast: <a href="/play">Play</a> <a href="/stop">Stop</a></p>
                 <p>Volume: <a href="/down">down</a> <a href="/up">up</a></p>
                 <p>System: <a href="/shutdown">Shutdown</a> <a href="/restart">Restart</a></p>
                 <div id="podcast-status"></div>
                 <script>
                     document.getElementById("podcast-status").innerHTML="{}";
                 </script>
                 </body>
                 </html>
              '''
              temp = os.popen("/opt/vc/bin/vcgencmd measure_temp").read()
              self.do_HEAD()
              status = ''
              if self.path=='/':
                  status='nothing'
              elif self.path=='/play':
                  proc = subprocess.Popen(["omxplayer", "-o", "alsa:hw:ALSA", "--no-osd", "/tmp/video.mp4"], preexec_fn=os.setsid)
                  status='Playing Podcast'
              elif self.path=='/stop':
                  status='Stopping Podcast'
                  os.killpg(os.getpgid(proc.pid), signal.SIGTERM)
              elif self.path=='/shutdown':
                  status='Shutdown'
                  subprocess.Popen(["sudo", "shutdown", "-h", "now"], preexec_fn=os.setsid)
              elif self.path=='/restart':
                  status='Restart'
                  subprocess.Popen(["sudo", "reboot"], preexec_fn=os.setsid)
              elif self.path=='/down':
                  status='Volume down'
                  subprocess.Popen(["amixer", "set", "Master", "12%-"], preexec_fn=os.setsid)
              elif self.path=='/up':
                  status='Volume up'
                  subprocess.Popen(["amixer", "set", "Master", "12%+"], preexec_fn=os.setsid)
              self.wfile.write(html.format(temp[5:], status).encode("utf-8"))
      
      
      if __name__ == '__main__':
          http_server = HTTPServer((host_name, host_port), MyServer)
          print("Server Starts - %s:%s" % (host_name, host_port))
      
          try:
              http_server.serve_forever()
          except KeyboardInterrupt:
              http_server.server_close()
      
      
      posted in Hardware
      Y
      yep_DD
    • RE: Strip Down Guide for BenQ 28" VA Monitor GC2870H

      @madscientist you were right, it does not work well behind the mirror. I will keep the sensor anyway as the way it is designed it is easier to affix to my aluminum frame. I am now thinking of getting small black plexiglas casing to attach to the bottom part to control the mirror and make it look nice… let’s see.

      So this could be the plan:

      • Plexiglas with Cutout letters
        0_1536574392126_aa1bc4b3-c3ee-43b0-94b4-4379c7562c39-image.png

      • behind that translucent plexiglas

      • glue together

      • LED Strip on top of translucent glas to illuminate the cutout letters

      • enjoy?

      posted in Hardware
      Y
      yep_DD
    • RE: Strip Down Guide for BenQ 28" VA Monitor GC2870H

      @madscientist that is what I am afraid of as well, the metal coating sure does not help… but worst case I will put them on the aluminum frame below from the outside and a nice cover on top

      I got the mirror from here: Glas-star.de

      posted in Hardware
      Y
      yep_DD
    • RE: Strip Down Guide for BenQ 28" VA Monitor GC2870H

      Hi guys,

      just an update on the mirror. Finally the glas has arrived. I am very happy with the quality and the 50mm edge that has been painted black. There were a few stains on the backside which I had to clean manually.

      Overall I am pretty satisfied with the results, but I have to change a few things:

      What I am happy with:

      • quality of glass (polished and round edges)
      • Monitor appearance
      • aluminimum frame and design (even though it needs to be changed, see below)
      • sound quality
      • The quality of the double-sided tape (seems like this is minor, but it is so strong I have no doubt it will hold the glass)

      What needs to be changed:

      • I changed the PIR Sensor to a radar sensor (RCWL-0516) which works flawlessly behind the glass
      • The wooden white background reflects too much sunlight during daytime so I have to get a black one
      • The Nielsen frame is 50mm too large. The reason behind that is that they measure the inner length but since I put the mirror on the outside it is 50mm longer. It does look okay, but I want the frame to be more inset. So if anyone wants a Nielsen frame for their project. I give mine away for free or a few € whatever you feel is appropriate it measures 95cmx75cm and can be shipped in small pieces and has the high quality double sided tape attached. I could have also gotten a bigger mirror, but obviously that is too expensive
      • the cheap capacitive Sensors from amazon don’t work well behind the glas so I am now getting these MT0.1N-NR. The datasheet looks promising, of course 10x more expensive…

      A few impressions:

      The package came very well shipped:
      0_1536312840684_IMG_20180906_113432.jpg

      I initially fixed the monitor with duct tape to see if I was happy with the position, you can nicely see the 50mm painted edges:
      0_1536312849206_IMG_20180906_123831.jpg

      First test:
      0_1536312856211_IMG_20180906_131134.jpg
      0_1536312864820_IMG_20180906_131214.jpg

      I think the quality of the monitor at night is amazing:
      0_1536312879044_IMG_20180906_200323.jpg
      Even from a steeper angle the backlight is barely visible:
      0_1536312887122_IMG_20180906_200938.jpg

      posted in Hardware
      Y
      yep_DD
    • RE: Apple TV meets MagicMirror.

      @thejoaovitor cool, thank you. did you leave it at 1080p or did you use 720p? Would you mind sharing your conversion details? I tried 720p and it still did not play very smooth.

      posted in Showcase
      Y
      yep_DD
    • RE: Strip Down Guide for BenQ 28" VA Monitor GC2870H

      @madscientist my experience is that in portrait the performance is almost unusable since everything is copied and rotated and I now decided to go landscape.

      posted in Hardware
      Y
      yep_DD
    • RE: Strip Down Guide for BenQ 28" VA Monitor GC2870H

      @madscientist that is true… good idea, I have one 5V 40mm fan as spare. Just one question, are you using your MM in portrait or landscape mode?

      posted in Hardware
      Y
      yep_DD
    • RE: Apple TV meets MagicMirror.

      @rak

      have you tried this? (#ff0000 just for presentation)

      body {
        text-shadow: 1px 1px #ff0000;
      }
      
      posted in Showcase
      Y
      yep_DD
    • RE: Strip Down Guide for BenQ 28" VA Monitor GC2870H

      @madscientist good idea, I will do that as soon as I have the actual glass. I have a passive heatsink installed already and in landscape mode the pi usage is less than 25-30% at the moment

      posted in Hardware
      Y
      yep_DD
    • RE: Apple TV meets MagicMirror.

      @thejoaovitor very impressive, did you store your webm videos locally? If so how did you get MMM-htmlvideo to play all of those files?

      Greetings

      posted in Showcase
      Y
      yep_DD
    • RE: Strip Down Guide for BenQ 28" VA Monitor GC2870H

      @madscientist So, experiment done. This is the result of 24h continues running. You can see the temperature has not quiet stabilized but the trend is well below anything critical. My guess would be that with a glass cover instead of the wooden frame I used to insulate the power dissipation should be even better.
      0_1535897114327_temperature.png

      posted in Hardware
      Y
      yep_DD
    • RE: Strip Down Guide for BenQ 28" VA Monitor GC2870H

      @maros thank you, I really don’t know id it will all work out, I started this for fun as I was reading about the amazing magicmirror2 project and their community. Two days later I am taking apart a brand new monitor… and now I have been constantly working on it on my days off.

      posted in Hardware
      Y
      yep_DD
    • 1 / 1