• 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.

[MMM-Remote-Control](v2-dev) Extensible REST API, Dynamic Menus, and Socket Communications, plus other updates

Scheduled Pinned Locked Moved Development
76 Posts 13 Posters 46.4k Views 13 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
    shbatm Module Developer
    last edited by shbatm Jan 1, 2019, 8:52 PM Dec 21, 2018, 12:51 PM

    Description

    I created an updated version of @Jopyth’s excellent MMM-Remote-Control module with an extensible REST API for controlling everything about your mirror, as well as an upgrade of the /remote.html tool to use the module’s node_helper socket connection for communication back and forth–instead of get/post calls.

    Example REST Calls:

    Turn on the monitor

    GET /api/monitor/on  (curl -X GET 'http://magicmirror:8080/api/monitor/on')
    

    Hide All Modules

    GET /api/modules/all/hide (curl -X GET 'http://magicmirror:8080/api/modules/all/hide')
    

    Here’s the link to the API README and API Documentation. The API also includes the ability to automatically interpret other modules’ anticipated notifications to create a “guessed” API to control it (created from MMM-API). Modules’ can also send a notification to this module to explicitly declare their own API actions.

    This is still in testing, and I’m still adding a few features, but I wanted to share in case anyone is interested in testing as well.

    Inspiration

    I’ve now written several modules and end up constantly including similar functions into my code (things like monitor control, module switching, etc.) for the different modules and I wanted to start migrating to a “One Remote to Rule Them All”-style module. @Jopyth’s module is an awesome base with a lot of the functions needed already built in, but I also wanted to have a better RESTful interface (inspired by @juzim’s MMM-API module natively incorporated) so I could control the mirror from my home automation devices. Eventually, I’ll scrub my other modules like MMM-OnScreenMenu and MMM-KeyBindings to just call the functions from this module and keep them focused on their own key features.

    Download

    [card:shbatm/MMM-Remote-Control]
    Recommend using the Develop Branch for most recent changes.

    Key Features and Changes

    Added:

    • REST API interface for controlling all aspects of the MagicMirror from HTTP RESTful-style GET and POST calls, based on principles from MMM-Api
      • Full API Documentation at API/README.md
      • Extensible Actions – Interprets other modules’ notifications to “guess” an API, but also allows a module to explicitly provide API actions to use.
    • Live daily updates of modules.json from the MagicMirror wiki, based on @eouia’s MMM-Remote-Control-Repository.
    • Incorporated some features found in MMM-OnScreenMenu that were not originally in this module.
      • Monitor (Connected Screen) On-Off Status and Toggle
      • If using Electron: Open Dev Tools, Minimize, Toggle Fullscreen
    • Configuration Option to send custom shell commands to use. Currently, only custom monitor on/off/status commands are supported. Addresses PR #99.

    Changed:

    • Updates to remote.html and the node_helper.js to use direct SocketIO communication back and forth instead of separate HTTP calls.
      • Future framework for following PM2 logs and more live update options.
    • General clean-up and standardization of status reporting for GET and POST calls, to original URLs and to new API URLs.
    • Updated to ES2015 (ES Version 6) function calls in most locations.
    • Added USER_PRESENCE controls from AgP42, PR #84
    • Added translations from BKeyport, PR #103
    • Added SHOW/HIDE/TOGGLE ALL modules option per request from Rene1709, Issue #101
    N C 2 Replies Last reply Jan 9, 2019, 4:39 AM Reply Quote 4
    • S Offline
      shbatm Module Developer
      last edited by shbatm Jan 2, 2019, 12:49 AM Jan 1, 2019, 8:51 PM

      Additional Features Added:

      • Dynamic Module Control menu – uses the new API to create a Module Control menu on the remote page to control other modules via notifications.
      • Custom Menu – ability to specify your own custom menu items from a file (for advanced users)
      • Use PM2 API to control restarts/stops of MM. Can also support starting/stopping other PM2 scripts by passing processName: “scriptToUse” in the query payload.

      Example Dynamic Menu for MMM-Carousel w/ Navigation

      0_1546390145459_ModuleMenuExample.png

      N 1 Reply Last reply Apr 13, 2024, 2:11 PM Reply Quote 1
      • N Offline
        nobita @shbatm
        last edited by Jan 9, 2019, 4:39 AM

        @shbatm
        The first time I Install MMM-Remote-Control (by Jopyth ) before
        If I would like to use your MMM-Remote-Control (by shbatm)
        question
        I have to Remove from jopyth or not

        Thank so much

        S 1 Reply Last reply Jan 9, 2019, 7:45 AM Reply Quote 0
        • S Offline
          shbatm Module Developer @nobita
          last edited by Jan 9, 2019, 7:45 AM

          @nobita said in [MMM-Remote-Control](v2-dev) Extensible REST API, Dynamic Menus, and Socket Communications, plus other updates:

          I have to Remove from jopyth or not

          You can checkout my fork/branch without removing @Jopyth’s by adding a remote:

          $ cd ~/MagicMirror/modules/MMM-Remote-Control
          $ git remote add shbatm https://github.com/shbatm/MMM-Remote-Control.git
          $ git fetch shbatm
          $ git checkout -b shbatm-develop shbatm/develop
          $ npm install
          

          After that you can switch back and forth using git checkout master and git checkout shbatm-develop

          N S 2 Replies Last reply Jan 9, 2019, 7:46 AM Reply Quote 0
          • N Offline
            nobita @shbatm
            last edited by Jan 9, 2019, 7:46 AM

            @shbatm
            Thanks again

            1 Reply Last reply Reply Quote 0
            • D Offline
              dazza120
              last edited by Jan 9, 2019, 8:22 PM

              Can this also update modules like MMM-Remote-Control-Repositories, in just this one module?

              S 1 Reply Last reply Jan 9, 2019, 10:19 PM Reply Quote 0
              • S Offline
                shbatm Module Developer @dazza120
                last edited by Jan 9, 2019, 10:19 PM

                @dazza120 said in [MMM-Remote-Control](v2-dev) Extensible REST API, Dynamic Menus, and Socket Communications, plus other updates:

                Can this also update modules like MMM-Remote-Control-Repositories, in just this one module?

                Yes. This version pulls the list of modules from the Wiki and updates the modules.json file when its started (at most 1x per day).

                D C 2 Replies Last reply Jan 10, 2019, 8:15 PM Reply Quote 0
                • D Offline
                  dazza120 @shbatm
                  last edited by Jan 10, 2019, 8:15 PM

                  @shbatm cheers I’ve looked through the read me and I am completely lost, it’s not just like doing a git clone and then putting stuff in the config file 🧠😁

                  S 1 Reply Last reply Feb 2, 2019, 5:55 PM Reply Quote 0
                  • C Offline
                    Cr4z33 @shbatm
                    last edited by Feb 2, 2019, 3:17 PM

                    This post is deleted!
                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      shbatm Module Developer @dazza120
                      last edited by Feb 2, 2019, 5:55 PM

                      @dazza120 Sorry, I’ve been away. What are you lost with? Can I help point you in the right direction?

                      If you’re just looking to install this version, see a couple posts up. For the most part it functions just like the other version, but adds a lot of advanced control features on top–like controlling your mirror from a browser or home automation controller (via API) or adding module control menus to the existing “/remote.html” page.

                      Cr4z33C 1 Reply Last reply Feb 7, 2019, 2:19 PM Reply Quote 0
                      • 1
                      • 2
                      • 3
                      • 4
                      • 5
                      • 6
                      • 7
                      • 8
                      • 1 / 8
                      • First post
                        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