Home Remote Control Custom Menu
Post
Cancel

Remote Control Custom Menu

Overview

The mirror command line utilities can be integrated into a custom MMM-Remote-Control menu. In this way the MMM-Remote-Control module can be extended to perform many additional actions including taking a screenshot, rotating the display, and controlling playback of video. This can, for example, allow you to use your phone to control the MagicMirror while standing in front of the mirror, away from your computer. Particularly handy for taking screenshots.

The MMM-Remote-Control module provides some documentation on creating a custom menu but it is currently incomplete. To add custom commands to MMM-Remote-Control using the mirror command:

  • Install the MirrorCommand utilities
  • Create a custom JSON configuration file in the MagicMirror config folder
  • Modify the config section of the MMM-Remote-Control module entry in the MagicMirror config.js

Custom JSON

Below is an example custom JSON MMM-Remote-Control configuration file. Create a file like this and copy it to your MagicMirror config folder. You can name it anything you like but the default naming convention is custom_menu.json.

This file creates the additional custom menu entries that MMM-Remote-Control will use. The current documentation for the syntax of this file only shows how to add NOTIFICATION actions. Integration with the Mirror Command Line requires custom COMMAND actions. Use the following as a guide to create a custom MMM-Remote-Control menu or simply copy it in its entirety, unmodified, as it is ready to be used in conjunction with the mirror command.

For each COMMAND menu entry, specify the action as “COMMAND” and the content as “command”: “someUniqueStringYouMakeUp”. The command string you use for the action must be unique and the command it represents will be defined in the MagicMirror config.js described in the next section.

Example Custom JSON

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
{
   "id": "custom",
   "type": "menu",
   "icon": "id-card-o",
   "text": "Mirror Command Line",
   "items": [{
         "id": "screenshot",
         "type": "item",
         "icon": "dot-circle-o",
         "text": "Screenshot",
         "action": "COMMAND",
         "content": {
            "command": "screenshotCommand"
         }
      },
      {
         "id": "rotate",
         "type": "menu",
         "menu": "custom",
         "icon": "bars",
         "text": "Rotate Screen",
         "items": [{
               "id": "rotate-right",
               "type": "item",
               "icon": "dot-circle-o",
               "text": "Rotate Screen Right",
               "action": "COMMAND",
               "content": {
                  "command": "rotateScreenRight"
               }
            },
            {
               "id": "rotate-left",
               "type": "item",
               "icon": "dot-circle-o",
               "text": "Rotate Screen Left",
               "action": "COMMAND",
               "content": {
                  "command": "rotateScreenLeft"
               }
            },
            {
               "id": "rotate-normal",
               "type": "item",
               "icon": "dot-circle-o",
               "text": "Rotate Screen Normal",
               "action": "COMMAND",
               "content": {
                  "command": "rotateScreenNormal"
               }
            },
            {
               "id": "rotate-inverted",
               "type": "item",
               "icon": "dot-circle-o",
               "text": "Rotate Screen Inverted",
               "action": "COMMAND",
               "content": {
                  "command": "rotateScreenInverted"
               }
            }
         ]
      },
      {
         "id": "video",
         "type": "menu",
         "menu": "custom",
         "icon": "bars",
         "text": "Video Playback",
         "items": [{
               "id": "play-video",
               "type": "item",
               "icon": "dot-circle-o",
               "text": "Play Video",
               "action": "COMMAND",
               "content": {
                  "command": "playVideo"
               }
            },
            {
               "id": "pause-video",
               "type": "item",
               "icon": "dot-circle-o",
               "text": "Pause Video",
               "action": "COMMAND",
               "content": {
                  "command": "pauseVideo"
               }
            },
            {
               "id": "replay-video",
               "type": "item",
               "icon": "dot-circle-o",
               "text": "Replay Video",
               "action": "COMMAND",
               "content": {
                  "command": "replayVideo"
               }
            },
            {
               "id": "next-video",
               "type": "item",
               "icon": "dot-circle-o",
               "text": "Next Video",
               "action": "COMMAND",
               "content": {
                  "command": "nextVideo"
               }
            },
            {
               "id": "hide-video",
               "type": "item",
               "icon": "dot-circle-o",
               "text": "Hide Video",
               "action": "COMMAND",
               "content": {
                  "command": "hideVideo"
               }
            },
            {
               "id": "show-video",
               "type": "item",
               "icon": "dot-circle-o",
               "text": "Show Video",
               "action": "COMMAND",
               "content": {
                  "command": "showVideo"
               }
            }
         ]
      }
   ]
}

MMM-Remote-Control config

Add the following to the MMM-Remote-Control module config in the MagicMirror config folder’s config.js. If you have configured an API Key for MMM-Remote-Control then modify the apiKey setting with your key. The customCommand settings correspond to the command settings used for the actions in the custom_menu.json file described above. Modify these to match those used in your custom_menu.json file. If you used the sample JSON as provided above then no further modifications to this config section will be necessary.

Add the following to the MMM-Remote-Control module entry in MagicMirror/config/config.js:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
    config: {
        apiKey: 'xxxx_Your-API-Key-Here_xxxx',
        customCommand: {
            shutdownCommand: '/usr/local/bin/shutdown',
            rebootCommand: '/usr/local/bin/reboot',
            monitorOnCommand: 'vcgencmd display_power 1',
            monitorOffCommand: 'vcgencmd display_power 0',
            screenshotCommand: '/usr/local/bin/mirror screenshot',
            rotateScreenRight: '/usr/local/bin/mirror rotate right',
            rotateScreenLeft: '/usr/local/bin/mirror rotate left',
            rotateScreenNormal: '/usr/local/bin/mirror rotate normal',
            rotateScreenInverted: '/usr/local/bin/mirror rotate inverted',
            playVideo: '/usr/local/bin/mirror playvideo',
            pauseVideo: '/usr/local/bin/mirror pausevideo',
            replayVideo: '/usr/local/bin/mirror replayvideo',
            nextVideo: '/usr/local/bin/mirror nextvideo',
            hideVideo: '/usr/local/bin/mirror hidevideo',
            showVideo: '/usr/local/bin/mirror showvideo',
        },
        showModuleApiMenu: true,
        secureEndpoints: true,
        customMenu: "custom_menu.json",
    }

Restart MagicMirror and open http://YourMagicMirrorIP:8080/remote.html in a browser. You should see a “Mirror Command Line” menu entry in the main MMM-Remote-Control menu (or whatever you set the top-level custom menu “text” property to in the JSON above). Clicking on this entry should bring up the custom menus defined in your custom_menu.json file.

This post is licensed under CC BY 4.0 by the author.

-

Mirror Voice Commands with Google Assistant