How overfl0w11/mmm-netatmo-thermostat works
Main Components
• MagicMirror Core: Represent the overall MagicMirror framework that loads modules.
• MMM-Netatmo-Thermostat Module:
• Frontend/UI Component – indicated by the MMM-Netatmo-Thermostat.js file and the accompanying CSS (MMM-Netatmo-Thermostat.css). This part is responsible for rendering thermostat information (temperature and heating status) on the MagicMirror display.
• Node Helper/Backend Component – represented by node_helper.js which is used for backend API calls. This file handles interactions with Netatmo (such as requesting data using credentials) and communicating results back to the frontend part.
• External Netatmo API: This is the external service where thermostat data is fetched using your client credentials (clientId, clientSecret, and refreshToken).
• Supporting Utilities:
• Translations (translations folder with multiple language JSON files) to support internationalization.
• Utility scripts (e.g., String.format.js) for string formatting.
• Configuration & Build:
• Configuration files (package.json, Gruntfile.js, .eslintrc.json, .stylelintrc) that help in building, linting, and packaging the module.
• CHANGELOG.md and LICENSE.txt, which while not part of runtime, help define versioning and usage rights.
Relationships and Data Flow
• MagicMirror loads the MMM-Netatmo-Thermostat module as one of its built-in modules.
• Initialization: The MagicMirror core instructs the module to render.
• API Trigger: The module (or its node_helper) initiates an API call to the external Netatmo service using credentials provided in the configuration (clientId, clientSecret, refreshToken).
• The node_helper.js fetches thermostat data from the Netatmo API at defined update intervals.
• Additionally, the translations utilize the language JSONs from the translations folder to render locale-specific text if necessary.
• The build tools (Gruntfile.js) and ESLint/Stylelint configuration files ensure the module’s quality but do not directly affect runtime architecture.
Architectural Patterns and Principles
• Separation of Concerns: The module cleanly separates the UI (MMM-Netatmo-Thermostat.js) from the backend/API logic (node_helper.js).
• Modular Design: Serving as a plug-in to MagicMirror, it follows a component-based architecture, making it easy to update or replace either part.