Skip to content

Commit bc57806

Browse files
author
veeck
committed
Merge branch 'master' into vitepress
2 parents 5eb6bc4 + 15352be commit bc57806

File tree

13 files changed

+582
-741
lines changed

13 files changed

+582
-741
lines changed

.github/workflows/pr-check.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Check Pull Request
2+
on:
3+
pull_request:
4+
types:
5+
- opened
6+
- synchronize
7+
- reopened
8+
branches:
9+
- master
10+
11+
concurrency:
12+
group: pr-check-${{ github.event.pull_request.number }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
test:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout Repository
21+
uses: actions/checkout@v5
22+
23+
- name: Install Node.js
24+
uses: actions/setup-node@v6
25+
with:
26+
node-version: current
27+
28+
- name: Install Dependencies
29+
run: npm ci --ignore-scripts
30+
31+
- name: Run Tests
32+
run: npm run test

.vuepress/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export default {
7070
"/module-development/introduction.md",
7171
"/module-development/core-module-file.md",
7272
"/module-development/node-helper.md",
73+
"/module-development/rendering.md",
7374
"/module-development/helper-methods.md",
7475
"/module-development/logger.md",
7576
"/module-development/notifications.md",
@@ -118,4 +119,3 @@ export default {
118119
}),
119120
],
120121
};
121-

configuration/introduction.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ The following properties can be configured, place them above the modules item:
5959
| `electronOptions` | An optional array of Electron (browser) options. This allows configuration of e.g. the browser screen size and position (example: `electronOptions: { fullscreen: false, width: 800, height: 600 }`). Kiosk mode can be enabled by setting `kiosk: true`, `autoHideMenuBar: false` and `fullscreen: false`. More options can be found [here](https://github.com/electron/electron/blob/master/docs/api/browser-window.md). This will most likely be used in advanced installations, below. | [] |
6060
| `electronSwitches` | An optional array of Electron switches. This allows configuration of electron app itself. <br> This properties will not affect the `serveronly` mode. Usually normal `MM` users don't need this property, but if you are a hard-core hacker, you might need this to handle Electron itself over `MagicMirror` provides. More options can be found [here](https://www.electronjs.org/docs/latest/api/command-line-switches) (Not all available switches are described there.)<br>example:`electronSwitches:["enable-transparent-visuals", "disable-gpu"];` | [] |
6161
| `customCss` | The path of the `custom.css` stylesheet. The default is `css/custom.css`. | `css/custom.css` |
62+
| `watchTargets` | An optional array of file paths to monitor when using `node --run server:watch`. When any of these files change, the server automatically restarts and connected browsers reload. Particularly useful when frequently modifying `config.js`, `custom.css`, or module files during development or setup. Example: `watchTargets: ["config/config.js", "css/custom.css", "modules/MMM-MyModule/MMM-MyModule.js"]`. See [Development Mode](/core-development/debugging.html#development-mode-with-auto-reload) for more details. | `undefined` |
6263

6364
After the above options, you will then add modules. See
6465
[module configuration](/modules/configuration.md) for more information.
@@ -74,7 +75,7 @@ are:
7475
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
7576
| MM_CONFIG_FILE | This specifies an alternate configuration file for the system. This is useful when running multiple mirrors on the same device. This does not work with the template option below. NOTE: this file **_MUST_** be located in a directory within the MagicMirror directory. Ideally, place any config file in the config subdirectory. |
7677
| MM_PORT | This specifies an alternate TCP/IP port, overriding "port" item within the config file. This is useful for testing to see if the product will run using another port. |
77-
| mmFetchTimeout | time in milliseconds for fetch timeout. default (30000) <br><br>this value can be used to adjust the nodejs fetch function timeout value (default 10 seconds) for all node_helper modules that use fetch() |
78+
| mmFetchTimeout | time in milliseconds for fetch timeout. default (30000) <br><br>this value can be used to adjust the nodejs fetch function timeout value for all node_helper modules that use fetch() |
7879

7980
#### Examples of use
8081

configuration/raspberry.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
# Raspberry Specific
22

3-
This information here is based on the latest release of
4-
[Raspberry Pi OS](https://www.raspberrypi.com/software/operating-systems/) ("Trixie") from October 1st 2025.
3+
This information here is based on the latest release of
4+
[Raspberry Pi OS](https://www.raspberrypi.com/software/operating-systems/)
5+
("Trixie") from October 1st 2025.
56

67
## Adding colored icons
78

8-
Raspberry Pi OS does not come with colored emoji icons by default. To add them, install the following package:
9+
Raspberry Pi OS does not come with colored emoji icons by default. To add them,
10+
install the following package:
911

1012
```shell
1113
sudo apt install fonts-noto-color-emoji
1214
```
1315

1416
## Rotating the screen
1517

16-
See the [official documentation](https://www.raspberrypi.com/documentation/computers/configuration.html#set-resolution-and-rotation)
18+
See the
19+
[official documentation](https://www.raspberrypi.com/documentation/computers/configuration.html#set-resolution-and-rotation)
1720

18-
In case you still run an older version of the Raspberry Pi OS, you can follow these instructions:
21+
In case you still run an older version of the Raspberry Pi OS, you can follow
22+
these instructions:
1923

2024
https://pimylifeup.com/raspberry-pi-rotate-screen/

core-development/debugging.md

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,57 @@ Developer consoles in browsers and the Electron app (typically CTRL+SHIFT+I to
3030
toggle open/close) can be used to set client-side breakpoints, step through
3131
scripts and inspect variables.
3232

33+
## Watch Mode with Auto-Reload
34+
35+
For active development, MagicMirror² provides a `server:watch` script that
36+
automatically restarts the server and reloads connected browsers when files
37+
change:
38+
39+
```sh
40+
node --run server:watch
41+
```
42+
43+
This mode monitors files specified in your `config.js` under the `watchTargets`
44+
property:
45+
46+
```js
47+
let config = {
48+
watchTargets: [
49+
"config/config.js",
50+
"css/custom.css",
51+
"modules/MMM-MyModule/MMM-MyModule.js",
52+
"modules/MMM-MyModule/node_helper.js",
53+
],
54+
// ... rest of config
55+
};
56+
```
57+
58+
When any monitored file changes:
59+
60+
1. The server automatically restarts
61+
2. Waits for the port to become available
62+
3. Sends a reload notification to all connected browsers via Socket.io
63+
4. Browsers automatically refresh to show the changes
64+
65+
This creates a seamless development experience where you can edit code, save,
66+
and see the results within seconds without manual restarts.
67+
68+
**Note:** If `watchTargets` is empty or undefined, the watcher starts but
69+
monitors nothing.
70+
3371
## Logging
3472

3573
While there are no log files produced by the server, info is reported in two
3674
different places:
3775

38-
- The console when running from `npm run start` or `npm run server`.
76+
- The console when running from `node --run start`, `node --run server`, or
77+
`node --run server:watch`.
3978
- This is separated into two streams, `console.log()` is output as the
4079
`stdout` stream, and
4180
- `console.error()` is output as the `stderr` stream.
4281
- These can be redirected to files when starting the server. `>` will redirect
4382
`stdout`, and `2>` will redirect `stderr`. `2>&1` will combine both streams:
44-
`npm run start > out.log 2>&1`
83+
`node --run start > out.log 2>&1`
4584
- The browser's developer console (typically CTRL+SHIFT+I to toggle open/close)
4685
will have output from scripts that run on the browser.
4786

@@ -113,5 +152,5 @@ script, such as `start:dev`:
113152
Or when running from the command line (Linux example):
114153

115154
```sh
116-
TZ=Europe/Madrid npm run start:dev
155+
TZ=Europe/Madrid node --run start:dev
117156
```

cspell.config.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"version": "0.2",
33
"language": "en",
44
"words": [
5-
"Deepwiki",
65
"anyfileorfolder",
76
"apikey",
87
"Autorestart",
@@ -12,6 +11,8 @@
1211
"custommodules",
1312
"dateheaders",
1413
"datetype",
14+
"Deepwiki",
15+
"endfor",
1516
"envcanada",
1617
"exploader",
1718
"feelslike",
@@ -34,6 +35,7 @@
3435
"newpos",
3536
"newsfeed",
3637
"nohup",
38+
"noto",
3739
"oenstrom",
3840
"onecall",
3941
"openmeteo",
@@ -59,9 +61,9 @@
5961
"Teeuw",
6062
"Termine",
6163
"timeformat",
64+
"Trixie",
6265
"trunc",
6366
"tympanus",
64-
"ukmetoffice",
6567
"ukmetofficedatahub",
6668
"UKMO",
6769
"updatenotification",

getting-started/installation.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,33 @@ the install specific instructions below
2727
2. Check if `git` is installed on your machine by executing `git` (should show
2828
usage), otherwise install it
2929
3. Clone the repository:
30+
3031
```shell
31-
git clone https://github.com/MagicMirrorOrg/MagicMirror
32+
git clone https://github.com/MagicMirrorOrg/MagicMirror.git
3233
```
33-
4. Enter the repository:
34+
35+
4. Enter the repository:
36+
3437
```shell
35-
cd MagicMirror
38+
cd MagicMirror
3639
```
40+
3741
5. Install the application: ``
42+
3843
```shell
39-
node --run install-mm
44+
node --run install-mm
4045
```
46+
4147
6. Make a copy of the config sample file:
48+
4249
```shell
43-
cp config/config.js.sample config/config.js
50+
cp config/config.js.sample config/config.js
4451
```
52+
4553
7. Start the application:
54+
4655
```shell
47-
node --run start
56+
node --run start
4857
```
4958

5059
::: warning NOTE

module-development/core-module-file.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ starts, or because your module asked a refresh using `this.updateDom()`), the
205205
system calls the getDom method. This method should therefore return a dom
206206
object.
207207

208+
Read more about Rendering Components
209+
[in the Rendering Component documentation](./rendering.md).
210+
208211
**Example:**
209212

210213
```js
@@ -228,6 +231,9 @@ data to the template with `getTemplateData`.
228231
An example of a default module that uses this method is
229232
[newsfeed](https://github.com/MagicMirrorOrg/MagicMirror/blob/master/modules/default/newsfeed/newsfeed.js).
230233

234+
Read more about Rendering Components
235+
[in the Rendering Component documentation](./rendering.md).
236+
231237
**Example:**
232238

233239
```js

module-development/rendering.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Rendering Component
2+
3+
There are two main approaches to rendering your component. Procedurally
4+
generating a Dom object with `getDom`, or using the built in Nunjucks templating
5+
engine.
6+
7+
With both approaches, rendering is first triggered when the module is first
8+
loaded. When your module's data changes, you can call
9+
[`this.updateDom()`](/module-development/core-module-file.md#thisupdatedomsspeed)
10+
to trigger a re-render.
11+
12+
## Using `getDom`
13+
14+
The `getDom` method is called by MagicMirror whenever it needs to update
15+
information on the screen. This method should return an HTML
16+
[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element) which
17+
contains all the information you would like to display.
18+
19+
**Example:**
20+
21+
```js
22+
getDom: function() {
23+
const wrapper = document.createElement("div");
24+
wrapper.innerHTML = 'Hello world!';
25+
return wrapper;
26+
}
27+
```
28+
29+
## Using Nunjucks Templates
30+
31+
If `getDom` is not overridden, MagicMirror will try and render a
32+
[Nunjucks](https://mozilla.github.io/nunjucks/) template from `getTemplate`.
33+
34+
Nunjucks is a templating language for JavaScript. You can read more about the
35+
syntax in the
36+
[Nunjucks Documentation](https://mozilla.github.io/nunjucks/templating.html).
37+
38+
### Templates and Data
39+
40+
Templates are rendered by calling `getTemplate` to get the path to the template
41+
and `getTemplateData` to get the data used in the template.
42+
43+
**Example:**
44+
45+
`MMM-MyModule.js`
46+
47+
```js
48+
getTemplate: function() {
49+
return "MMM-MyModule.njk";
50+
},
51+
52+
getTemplateData: function() {
53+
return {
54+
list: ["item 1", "item 2", "item 3"],
55+
};
56+
}
57+
```
58+
59+
`MMM-MyModule.njk`
60+
61+
```nunjucks
62+
<ul>
63+
{% for item in list %}
64+
<li>{{ item }}</li>
65+
{% endfor %}
66+
</ul>
67+
```
68+
69+
Rendered HTML:
70+
71+
```html
72+
<ul>
73+
<li>item 1</li>
74+
<li>item 2</li>
75+
<li>item 3</li>
76+
</ul>
77+
```
78+
79+
### Filters
80+
81+
[Nunjucks Filters](https://mozilla.github.io/nunjucks/templating.html#filters)
82+
are functions added to Nunjucks that can be applied to variables passed to the
83+
template.
84+
85+
#### `translate` filter
86+
87+
MagicMirror provides a `translate` filter which can be used to access the same
88+
functionality available in the
89+
[`this.translate` module instance method](/module-development/core-module-file.md#thistranslateidentifier).
90+
91+
```nunjucks
92+
{{ "INFO" | translate }}
93+
```
94+
95+
#### Adding filters
96+
97+
You can add your own filters by accessing the Nunjucks environment via
98+
`this.nunjucksEnvironment()`
99+
100+
```js
101+
this.nunjucksEnvironment().addFilter("space", function (str) {
102+
return str.split("").join(" ");
103+
});
104+
```
105+
106+
For filter examples see the
107+
[`weather` module](https://github.com/MagicMirrorOrg/MagicMirror/blob/master/modules/default/weather/weather.js#L221).

modules/compliments.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The following properties can be configured:
3434
| `fadeSpeed` | Speed of the update animation. (Milliseconds) <br><br> **Possible values:**`0` - `5000` <br> **Default value:** `4000` (4 seconds) |
3535
| `compliments` | The list of compliments. <br><br> **Possible values:** An object with four arrays: `morning`, `afternoon`, `evening` and `anytime`. See _compliment configuration_ below. <br> **Default value:** See _compliment configuration_ below. |
3636
| `remoteFile` | External file from which to load the compliments <br><br> **Possible values:** Path or URL (starting with `http://` or `https://`) to a JSON file containing compliments, configured as per the value of the _compliments configuration_ (see below). An json object {} with at least one of the arrays: `morning`, `afternoon`, `evening`, `anytime`, `datetype` and/or `crontype`. - `compliments.json` <br> **Default value:** `null` (Do not load from file) |
37-
| `remoteFileRefreshInterval` | How often to reload the remote file, if remoteFile is specified. in ms <br> **Default value:** 0 <br> **Minimum value:** 15 minutes (15\*60\*60\*1000) |
37+
| `remoteFileRefreshInterval` | How often to reload the remote file, if remoteFile is specified. in ms <br> **Default value:** 0 <br> **Minimum value:** 15 minutes (15\*60\*1000) |
3838
| `classes` | Override the CSS classes of the div showing the compliments <br><br> **Default value:** `thin xlarge bright` |
3939
| `morningStartTime` | Time in hours (in 24 format), after which the mode of "morning" will begin <br> **Possible values:** `0` - `24` <br><br> **Default value:** `3` |
4040
| `morningEndTime` | Time in hours (in 24 format), after which the mode of "morning" will end <br> **Possible values:** `0` - `24` <br><br> **Default value:** `12` |

0 commit comments

Comments
 (0)