Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposed v2.0.0-dev] Extensible REST API, Dynamic Menus, and Socket Communications, plus other updates #104

Merged
merged 46 commits into from Feb 20, 2019

Conversation

shbatm
Copy link
Contributor

@shbatm shbatm commented Dec 21, 2018

I hope you don't mind the intrusion, but I really like your module and I've been working on an updated version to truly make it "THE" remote for MagicMirror. If you don't want to incorporate my changes to the original channel, that's fine... I just wanted to share.

Description

I created an updated version 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.

Inspiration

I've now written several modules and end of 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 incorporated in natively 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.

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 Added commands for alternate method of turning on and off monitor for when TVService fails. #99

Changed:

Varguit and others added 30 commits December 8, 2017 15:34
Spanish translation
- Moved monitor controls into their own function and added toggle and status

- Bug fixes for incorrect responses and hung responses on bad GET calls.
Incorporate new translations from Varguit
@Jopyth
Copy link
Owner

Jopyth commented Dec 21, 2018

This looks awesome.

@Jopyth
Copy link
Owner

Jopyth commented Dec 21, 2018

Hopefully I will find a few hours until the end of this year to merge this.

@shbatm
Copy link
Contributor Author

shbatm commented Dec 22, 2018

Thanks! I had a good base to start from, though...
I'm still adding some features from my list, so no hurry to merge, but I could certainly use some extra eyes for testing.

The last big thing I wanted to add is custom remote menu items, dynamically loaded from the "guessed" API functions. This will allow for tap and send notifications, and, as long as the other module developer follows the standard notification conventions, you don't have to specifically "add" support for other modules to control them. Item's can also be loaded from a user's config or json file.

shbatm and others added 2 commits December 23, 2018 06:54
-  Automatically generated from the API to control the different modules you have installed, based on their `notificationReceived` function.
@shbatm shbatm changed the title [Proposed v2.0.0-dev] Extensible REST API and Socket Communications, plus other updates [Proposed v2.0.0-dev] Extensible REST API, Dynamic Menus, and Socket Communications, plus other updates Dec 24, 2018
@shbatm
Copy link
Contributor Author

shbatm commented Dec 24, 2018

@Jopyth OK -- I'm done adding major features for now, if you have any questions when you get around to looking at the changes, please let me know.

The last feature set I added was for Dynamic Menus --

  1. Custom Menu - Allows a user to specify a custom menu in a JSON file (sample provided)
  2. Module Controls - Waits for the API "discovery"/"guessing" of other modules' notificationReceived functions and then creates a dynamic menu to call each modules' functions.

Both of these are in the spirit of expanding control to other modules, but do so in a way that this module doesn't have to be manually updated to support everyone else's modules individually.

I have a few more ideas that I'll implement and push at a later date (such as live module position changes without a restart, and the ability to enter text for a Module Controls menu item (most likely something like a long-press to open the alert form).

Example of Dynamic Menu:
modulemenuexample

shbatm added a commit to shbatm/MMM-Carousel that referenced this pull request Jan 1, 2019
This was referenced Jan 10, 2019
@Jopyth Jopyth self-assigned this Feb 19, 2019
@Jopyth Jopyth merged commit 48deb44 into Jopyth:develop Feb 20, 2019
@shbatm shbatm deleted the upstream_pr branch October 5, 2022 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants