Read the statement by Michael Teeuw here.
Enabling MM-QR Code to read the output of MM-Remote Control
-
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
-
@cheapdad you would have to write some code in the qr module…
do you think the pi address will change?
-
@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. -
@cheapdad iphone is irrelevant to this…
-
@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 startthis works for ipV4… haven’t tried with ipV6 network
the grep "inet " filters out the v6 address “inet6” would select just that addressdocs 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
-
@sdetweil did the start up script work alone to make the qr code work with mmm-remotecontrol
address? sorry little confused -
@integria92 the qrcode module creates the qr… it takes a hard coded url
but if u don’t know the value, its hardso 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…
-
@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 -
@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-QRCodeand 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 expectedremember, until mm starts, the config.js is a useless text file