This is a module for the MagicMirror².
Send MagicMirror simple On/Off commands from any home automation device supporting Wemos devices through the fauxmojs
Node.js module. No AWS, microphones, buttons, or 3rd-Party hubs required.
I am not actively working on this project at the moment since I don't use it on my MagicMirrors. I am currently using NodeRED and the API provided by MMM-Remote-Control to control my mirrors. I'm not going to be able to perform any direct troubleshooting, but I will accept any PRs to correct identified issues.
Assumptions: This module assumes that you have a stand-alone home automation device, such as an Amazon Echo, Echo Dot, Google Home Hub, etc. This module receives commands from these devices over your WiFi and, using dsandor's fauxmojs Fake Wemos module, translates them into commands for the MagicMirror.
This module also does not control anything on it's own by design. There are plenty of Modules out there to turn on/off the monitor, switch profiles, show/hide modules etc. This module simply rebroadcasts commands when received as notifications to other modules.
-
Install the module in your Mirror:
cd ~/MagicMirror/modules git clone https://github.com/shbatm/MMM-AlexaOnOff.git cd MMM-AlexaOnOff/ npm install
-
Setup the configuration using the details below.
-
Discover devices on your home automation system of choice.
- For Amazon Alexa devices, simply say "Alexa, discover my devices"
-
For each device you have configured, you can say "Alexa, turn [device name] on", or "off".
- These
on
andoff
commands will send the notifications you have configured to the different modules.
- These
To use this module, add the following configuration block to the modules array in the config/config.js
file:
var config = {
modules: [
{
module: 'MMM-AlexaOnOff',
config: {
// See below for configurable options
}
}
]
}
Option | Description |
---|---|
devices |
Required devices accepts a mixed array of strings with device names (e.g. "Magic Mirror" ) or objects of the form:{ name: "Device Name", on: { notification: "NOTIFICATION_TITLE", payload: "NOTIFICATION PAYLOAD" }, off: { notification: "NOTIFICATION_TITLE", payload: "NOTIFICATION PAYLOAD" }, } In addition to a single notification, on: or off: can also accept an array of notifications to send. See example below.Note: If you provide only string names, or don't provide details on the on or off notification you want to send, a generic "MMM-AlexaOnOff_ACTION_RECEIVED" notification will be sent with the device name and action in the payload. While not useful by itself, you could have a module that watched for this and did something. |
netInterface |
Optional Network interface you are using Default: wlan0 for WiFi. If your mirror uses wired ethernet, use eth0 . |
netProtocol |
Optional Network protocol you are using Default: IPv4 , change only if you use IPv6 exclusively. |
startPort |
Optional Starting network port to use. Each device you create will be given its own port in a series starting with this one. |
The MMM-OnScreenMenu module allows for controlling your mirror from notifications sent by other modules.
To use:
- Start MagicMirror with configuration included below.
- Say "Alexa, discover my devices."
- Alexa should find a new device called "Magic Mirror"
- Say "Alexa, turn off magic mirror."
- This module will receive the command, find an "off" notification to send.
- The MMM-OnScreenMenu module will recieve a "ONSCREENMENU_PROCESS_ACTION" notification telling it to turn off the monitor.
Turn on or off the monitor using MMM-OnScreenMenu module:
{
module: 'MMM-OnScreenMenu',
position: 'bottom_right',
},
{
module: 'MMM-AlexaOnOff',
config: {
devices: [{
name: "Magic Mirror",
on: {
notification: "ONSCREENMENU_PROCESS_ACTION",
payload: { actionName:'monitorOn' }
},
off: {
notification: "ONSCREENMENU_PROCESS_ACTION",
payload: { actionName:'monitorOff' }
},
}]
}
}
Show or hide a module using the MMM-RemoteControl module: (see here for specifics on the module identifier needed)
{
module: 'MMM-AlexaOnOff',
config: {
devices: [{
name: "Clock Module",
on: {
notification: "REMOTE_ACTION",
payload: { action: "SHOW", module: "module_3_clock" }
},
off: {
notification: "REMOTE_ACTION",
payload: { action: "HIDE", module: "module_3_clock" }
},
}]
}
}
Sending multiple notifications with one device: Config section to do this with MMM-Remote-Control (see here for specifics on the module identifier needed):
{
module: 'MMM-AlexaOnOff',
config: {
devices: [{
name: "Calendar",
on: [
{
notification: "REMOTE_ACTION",
payload: { action: "SHOW", module: "module_4_calendar" }
},
{
notification: "REMOTE_ACTION",
payload: { action: "HIDE", module: "module_3_clock" }
}
],
off: [
{
notification: "REMOTE_ACTION",
payload: { action: "HIDE", module: "module_4_calendar" }
},
{
notification: "REMOTE_ACTION",
payload: { action: "SHOW", module: "module_3_clock" }
}
],
}]
}
}