MagicMirror² v2.13.0 is available! For more information about this release, check out this topic.

Custom Commands in @MMM-Remote-Control

  • I am using a raspberry pi 4. I have a radio frequency transmitter attached to one of my GPIO pins and I am using running a python script through the terminal to send a command that will turn on/off and change the colour of my led lights. (See link below). I have said these files in my MagicMirror folder.

    Is it possible to use custom commands to do this? If so can you help me understand how. Attached are the shell files that are executable and work( when i double click the files in desktop mode - the lights change). How do i link this to MMM-Remote-Control or do the same action in MMM-Remote-Control?


    /* Magic Mirror Config Sample
     * By Michael Teeuw
     * MIT Licensed.
     * For more information on how you can configure this file
     * See
    var config = {
    	address: "", 	// Address to listen on, can be:
    	//address: "localhost", 	// Address to listen on, can be:
    							// - "localhost", "", "::1" to listen on loopback interface
    							// - another specific IPv4/6 to listen on a specific interface
    							// - "", "::" to listen on any interface
    							// Default, when address config is left out or empty, is "localhost"
    	port: 8080,
    	basePath: "/", 	// The URL path where MagicMirror is hosted. If you are using a Reverse proxy
    					// you must set the sub path here. basePath must end with a /
    	ipWhitelist: [], 	// Set [] to allow all IP addresses
    	//ipWhitelist: ["", "::ffff:", "::1"], 	// Set [] to allow all IP addresses														// or add a specific IPv4 of :
    															// ["", "::ffff:", "::1", "::ffff:"],
    															// or IPv4 range of --> use CIDR format :
    															// ["", "::ffff:", "::1", "::ffff:"],
    	useHttps: false, 		// Support HTTPS or not, default "false" will use HTTP
    	httpsPrivateKey: "", 	// HTTPS private key path, only require when useHttps is true
    	httpsCertificate: "", 	// HTTPS Certificate path, only require when useHttps is true
    	language: "en",
    	logLevel: ["INFO", "LOG", "WARN", "ERROR"],
    	timeFormat: 24,
    	units: "metric",
    	// serverOnly:  true/false/"local" ,
    	// local for armv6l processors, default
    	//   starts serveronly and then starts chrome browser
    	// false, default for all NON-armv6l devices
    	// true, force serveronly mode, because you want to.. no UI on this device
    	modules: [
    		    	module: 'MMM-Remote-Control',
    		    	// uncomment the following line to show the URL of the remote control on the mirror
    		     	position: 'bottom_right',
    		    	// you can hide this module afterwards from the remote control itself
    		    	config: {
    				customCommand: {},  // Optional, See "Using Custom Commands" below
    				showModuleApiMenu: true, // Optional, Enable the Module Controls menu
    				// uncomment any of the lines below if you're gonna use it
    				// customMenu: "custom_menu.json", // Optional, See "Custom Menu Items" below
    				// apiKey: "",         // Optional, See API/ for details
    			customCommand: {
    				monitorOnCommand: 'cd ./MagicMirror python3 -p 396 -t 1 11717633',
      			module: "MMM-Remote-Control-Repository",
    /*************** DO NOT EDIT THE LINE BELOW ***************/
    if (typeof module !== "undefined") {module.exports = config;}

    Shell Script

    cd ./MagicMirror
    python3 -p 396 -t 1 11717633

    #!/usr/bin/env python3
    import argparse
    import logging
    from rpi_rf import RFDevice
    logging.basicConfig(level=logging.INFO, datefmt='%Y-%m-%d %H:%M:%S',
                        format='%(asctime)-15s - [%(levelname)s] %(module)s: %(message)s',)
    parser = argparse.ArgumentParser(description='Sends a decimal code via a 433/315MHz GPIO device')
    parser.add_argument('code', metavar='CODE', type=int,
                        help="Decimal code to send")
    parser.add_argument('-g', dest='gpio', type=int, default=17,
                        help="GPIO pin (Default: 17)")
    parser.add_argument('-p', dest='pulselength', type=int, default=None,
                        help="Pulselength (Default: 350)")
    parser.add_argument('-t', dest='protocol', type=int, default=None,
                        help="Protocol (Default: 1)")
    parser.add_argument('-l', dest='length', type=int, default=None,
                        help="Codelength (Default: 24)")
    parser.add_argument('-r', dest='repeat', type=int, default=10,
                        help="Repeat cycles (Default: 10)")
    args = parser.parse_args()
    rfdevice = RFDevice(args.gpio)
    rfdevice.tx_repeat = args.repeat
    if args.protocol:
        protocol = args.protocol
        protocol = "default"
    if args.pulselength:
        pulselength = args.pulselength
        pulselength = "default"
    if args.length:
        length = args.length
        length = "default" +
                 " [protocol: " + str(protocol) +
                 ", pulselength: " + str(pulselength) +
                 ", length: " + str(length) +
                 ", repeat: " + str(rfdevice.tx_repeat) + "]")
    rfdevice.tx_code(args.code, args.protocol, args.pulselength, args.length)

    apt-get install python3-pip

    pip3 install rpi-rf

  • @gkchimz you use a curl command to send a request to the remote control api url

  • @sdetweil - thank you very much for your prompt response. I have not learned about curl commands yet ( although i know i have copied and pasted one during installation of modules.

    Are you able to point me towards an example or a good page that i may be able to lean the relevant things quickly please.

  • @gkchimz Google is your friend

    Also every command has help

    curl --help

  • Hello! Ezequiel here. customCommands should be inside the config of the Remote Control. You can raise a question in the issue page for further instructions. Cheers 😃

Log in to reply