MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    Enabling MM-QR Code to read the output of MM-Remote Control

    Troubleshooting
    3
    9
    398
    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.
    • C
      CheapDad last edited by

      Hi all! After taking a coding break to physically assemble my mirror, I’m doing the final coding to wrap this project up. For context, it is for my college-aged child who is NOT a CS major.

      I think MM-Remote Control is very useful, but all it displays is a hyperlink to the mirror. I’d like to use MM-QR Code to display that hyperlink in QR form.

      I’ve found that I can add a source for the QR code:

      {
            module: "MMM-QRCode",
            position: "middle",
            config: {
                 text: "http://cnn.com"
            }
      }
      

      Rather than display static text, how can I get it to display the output of MM-Remote Control?

      CheapDad

      S 1 Reply Last reply Reply Quote 0
      • S
        sdetweil @CheapDad last edited by

        @cheapdad you would have to write some code in the qr module…

        do you think the pi address will change?

        Sam

        Create a working config
        How to add modules

        C 1 Reply Last reply Reply Quote 0
        • C
          CheapDad @sdetweil last edited by

          @sdetweil
          Unfortunately, yes, when she returns to college. To make things worse, I don’t know how often the college’s dhcp will get her a new iPhone address.

          S 1 Reply Last reply Reply Quote 0
          • S
            sdetweil @CheapDad last edited by

            @cheapdad iphone is irrelevant to this…

            Sam

            Create a working config
            How to add modules

            S 1 Reply Last reply Reply Quote 0
            • S
              sdetweil @sdetweil last edited by sdetweil

              @sdetweil you could make the MM start script fix the config entry

              here is a little script you can use to modify the config when MM is started

              #!/bin/bash
              #
              # get the active adapter name
              #
              adapter=$(ip link show | grep mtu | grep -v lo | grep up | grep -v -i docker | grep "state UP" | awk -F: '{print $2}' | awk '{print $1}')
              #
              # use the adapter name to get the assigned IP address
              #
              address=$(ifconfig $adapter | grep "inet " | awk '{print $2}')
              #
              # use for debugging
              # echo address for  adapter $adapter  is $address
              #
              # use the address in sed replace of the line that starts with text:"http:/
              # -i means update file in place
              # file at the end needs the path   (~/MagicMirror/config/config.js
              #
              sed -i "/text:\"http:/ c \    \"text\"\:\"http://$address:8080/modules/remoteControl.html\","  config.js
              

              u could add this to the mm.sh used to start MM on boot,etc…
              I don’t know the end of the remotecontrol link… so that has to be fixed too…
              just have something in config.js when this runs , this should run before npm start

              this works for ipV4… haven’t tried with ipV6 network
              the grep "inet " filters out the v6 address “inet6” would select just that address

              docs says

              Because IPv6 addresses contain colons, they cannot be directly used in URLs because the colons would conflict with both the protocol declaration (http:// or https://) and port numbers. Therefore, when a literal IPv6 address is used, it is encased in a bracket, like http://[2001:db8::1]:80.
              

              so that would be a tiny change to the sed string

              Sam

              Create a working config
              How to add modules

              1 Reply Last reply Reply Quote 0
              • I
                Integria92 last edited by

                @sdetweil did the start up script work alone to make the qr code work with mmm-remotecontrol
                address? sorry little confused

                S 1 Reply Last reply Reply Quote 0
                • S
                  sdetweil @Integria92 last edited by

                  @integria92 the qrcode module creates the qr… it takes a hard coded url
                  but if u don’t know the value, its hard

                  so the text above added to the mm.sh can update the config.js for the QRCode module before MM starts and all will be well…

                  Sam

                  Create a working config
                  How to add modules

                  I 1 Reply Last reply Reply Quote 0
                  • I
                    Integria92 @sdetweil last edited by

                    @sdetweil Interesting. Thanks for the quick response. so in the example above; for the qrcode config… What would the text =
                    to find the output from the script?
                    again, thanks a lot for your help

                    S 1 Reply Last reply Reply Quote 0
                    • S
                      sdetweil @Integria92 last edited by sdetweil

                      @integria92 the qrcode takes some text and makes it available to the scanner

                      it can be anything

                      IF the text is a url, the client app offers to open it

                      so, you config the module with a dummy url
                      https://github.com/evghenix/MMM-QRCode

                      and the the script additions change it to the machine IP address at the time mm starts.

                      which the op’s daughter in college would not generally know.

                      if the machine was powered off for a day/week, it’s ip address would likely change, and so a hard coded ip address would be bad.

                      this code handles any dhcp address
                      change and then the qrcode launches remote controls expected

                      remember, until mm starts, the config.js is a useless text file

                      Sam

                      Create a working config
                      How to add modules

                      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 Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy