The mmm-energy-saver
module is a MagicMirror addon.
This module requires MagicMirror version 2.5
or later.
This module works in conjunction with MMM-Pir-Sensor to automatically suspend & resume all your modules based on movement detection. Furthermore, this module allows you to specify times when all the modules are suspended and your HDMI-connected screen is turned off as well.
Please note that the movement detection will not work unless you have the MMM-Pir-Sensor module installed (and working).
By design, this module has fairly limited functionality - which is nice because it makes it very easy to set up & use. If you, however, want a lot more control over the individual modules including setting specific timers based on days or showing alerts, I'd recommend checking out the MMM-ModuleScheduler module instead.
- Installing the module
- Using the module
- General Configuration Options
- Cron Expressions
- Developer Notes
- Run
git clone https://github.com/michael5r/mmm-energy-saver.git
from inside yourMagicMirror/modules
folder. - Run
cd mmm-energy-saver
in the same terminal window, thennpm install
to install the required Node modules.
To use this module, simply add it to the modules
array in the MagicMirror config/config.js
file:
{
module: "mmm-energy-saver",
config: {
// ... whatever configuration options you want to use
}
},
Seeing that nothing is displayed on screen, there's no need to add a position
property.
Option | Type | Default | Description |
---|---|---|---|
timeoutInSeconds |
int |
300 |
When motion is triggered, how long to wait before going to sleep. Default is 5 minutes. |
triggerMonitor |
boolean |
true |
Whether the monitor should be turned on and off. |
monitorOn |
string |
00 30 7 * * * |
When to turn the monitor on. Default is 7:30 am. |
monitorOff |
string |
00 30 23 * * * |
When to turn the monitor off. Default is 11:30 pm. |
Both the monitorOn
and monitorOff
settings take valid cron
expressions as their arguments. If you're confused as to the syntax to use,
check out the Node-Cron documentation.
There are two ways of using this module's functionality inside other modules:
-
This module broadcasts a
MMM_ENERGY_SAVER
notification with the payload being eithersuspend
orresume
- you can listen for this notification in thenotificationReceived
method inside your own module and have your module update accordingly. -
Seeing that this module uses the standard MagicMirror
module.hide
andmodule.show
functions to hide/show modules which, in turn, automatically trigger thesuspend
&resume
methods, it's fairly trivial to extend these directly in your module - like this:
suspend: function() {
// this method is triggered when a module is hidden using this.hide()
// do something inside this module
},
resume: function() {
// this method is triggered when a module is shown using this.show()
// do something inside this module
},
I personally prefer method 2
- it's very clean and allows you to easily do stuff like temporarily pausing data updating when a module is suspended (aka hidden on the screen).
For more info, check out the MagicMirror Modules documentation.
For an example of how method 2
works, check out my mmm-nest-status module.