• 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
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Add JS Code to the Mirror

Scheduled Pinned Locked Moved Solved Troubleshooting
33 Posts 5 Posters 9.7k Views 5 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
    stro
    last edited by stro Aug 5, 2019, 9:32 AM Aug 4, 2019, 9:38 PM

    i have the following problem, i want to show the current playing song from mopidy, so i install the MMM-MPD module, but it shows me only a play button, nothing else. So i try another way and i found this code in the web:

    https://pastebin.com/7e40507n

    Now my problem is, when i open the file:

    file:///home/pi/MagicMirror/modules/test/mopidy.html
    

    it shows exactly that output i want to see.
    But if i open:

    localhost:8080/modules/test/mopidy.html
    

    or try to put the code in the index.html it shows me nothing. Can anyone help me to find out, what is blocking the code? Thanks!

    1 Reply Last reply Reply Quote 0
    • S Offline
      stro
      last edited by Aug 4, 2019, 9:51 PM

      This post is deleted!
      1 Reply Last reply Reply Quote 0
      • S Offline
        stro
        last edited by Aug 4, 2019, 10:00 PM

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • S Offline
          sdetweil
          last edited by Aug 4, 2019, 10:38 PM

          So, u need to change the HTML returned by MMM-MPD to look like the HTML in the file. But only the section that is your real user interface.

          See the getDom() function which would build the html.

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • S Offline
            stro
            last edited by Aug 5, 2019, 6:08 AM

            No, i want to show the current playing Track from mopidy.

            Either by MMM-MPD (i didn‘t get to work)
            Or by the Code i found on the web ( i didn‘t get to work)

            S 1 Reply Last reply Aug 5, 2019, 12:46 PM Reply Quote 0
            • S Offline
              sdetweil @stro
              last edited by Aug 5, 2019, 12:46 PM

              @stro MagicMirror is a web page.
              It displays html. The modules generate a small section matching their requirements, and mm injects that onto the page in the configured position.

              The module can get it’s data from anywhere. API, file system, database.

              You have an API, which returns data, not html. Some code has to convert the data into displayable html

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              1 Reply Last reply Reply Quote 1
              • S Offline
                stro
                last edited by Aug 5, 2019, 5:51 PM

                @sdetweil thanks for helping me.

                I have the code (pastebin) who put the data, i‘m looking for, in a HTML Output. If i open the html file like this

                file:///home/pi/MagicMirror/modules/test/mopidy.html
                

                everything is okay.

                But if open this HTML File with the Mirrorpath like this:

                localhost:8080/modules/test/mopidy.html
                

                It shows me nothing. And i wonder why.

                S 1 Reply Last reply Aug 5, 2019, 5:54 PM Reply Quote 0
                • S Offline
                  sdetweil @stro
                  last edited by Aug 5, 2019, 5:54 PM

                  @stro open the developers window, ctrl-shift-i, select the console tab and scroll up to see any errors

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    stacywebb
                    last edited by Aug 11, 2019, 11:25 PM

                    Check your

                    mopidy.conf

                    located at:

                    ~/.config/mopidy/mopidy.conf
                    

                    Look for this section:

                    [http]
                    enabled = true
                    hostname = 127.0.0.1
                    port = 6680
                    static_dir =
                    zeroconf = Mopidy HTTP server on $hostname
                    allowed_origins =
                    csrf_protection = true
                    

                    Take note of the hostname part.
                    If your’s looks like the above instead of using localhost in the url, use the ip address or host name of the mirror.

                    Examples:
                    mirror.local:8080/modules/test/mopidy.html
                    or
                    10.x.x.x:8080/modules/test/mopidy.html

                    I tested the code you posted on pastebin and it works as expected for me.
                    Only tested using the hostname of the Mirror from external browser. Not locally on the machine.

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      stro
                      last edited by stro Aug 14, 2019, 3:37 PM Aug 14, 2019, 3:35 PM

                      I was able to solve that problem.
                      MPD port was double busy. Apparently 2 instances of Mopidy were running.

                      Now the module MMM-MPD runs under a few specials:

                      During the installation the folder name has to be changed according to the config file.
                      The config file value maxRows must not be 0!
                      The display will only update after a song change!

                      It was hard to find this specifics, but I thank everyone for the help!

                      1 Reply Last reply Reply Quote 0
                      • 1
                      • 2
                      • 3
                      • 4
                      • 1 / 4
                      1 / 4
                      • First post
                        1/33
                        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