Dear Magic Mirror Pros,
I’ve encountered a problem that’s currently preventing the progress of my major project. Let me provide some background:
Here’s my setup:
I’m using a Windows 10 operating system.
MagicMirror² and Alexa are installed on this Windows machine.
I’ve also set up Fauxmo, MMM-pages, and MMM-AlexaControl modules.
So, everything is operating well in the basic configuration of MagicMirror² on my Windows 10 system. Additionally, I have Alexa configured on the same Windows 10 device, ensuring both MagicMirror and Alexa are always on the same WiFi network. I’ve configured the Calendar and have successfully used voice commands via Alexa to create new calendar entries.
However, I’ve hit a roadblock: I’m unable to switch pages using voice commands or the Alexa app. I am able to control the FAUXMO simulated devices, namely “Seite 1”, “Seite 2”, etc. For example, when I turn them on, they switch to 1 and to 0 when I turn them off. Despite this, I’m really struggling with page-switching—I just can’t get it to work, and I can’t identify the problem.
To add to the confusion, there seems to be varying opinions about whether the pages module is necessary at all: some suggest it’s possible to manage without Pages, while others disagree. Lastly, I should mention that I’m not a developer—I have some basic knowledge of server and cloud services, but that’s about it.
So, I really need your help to solve this problem. I appreciate any suggestions or guidance you can provide.
The MM Config:
/* MagicMirror² Config Sample
*
* By Michael Teeuw https://michaelteeuw.nl
* MIT Licensed.
*
* For more information on how you can configure this file
* see https://docs.magicmirror.builders/configuration/introduction.html
* and https://docs.magicmirror.builders/modules/configuration.html
*
* You can use environment variables using a `config.js.template` file instead of `config.js`
* which will be converted to `config.js` while starting. For more information
* see https://docs.magicmirror.builders/configuration/introduction.html#enviromnent-variables
*/
let config = {
address: "localhost", // Address to listen on, can be:
// - "localhost", "127.0.0.1", "::1" to listen on loopback interface
// - another specific IPv4/6 to listen on a specific interface
// - "0.0.0.0", "::" to listen on any interface
// Default, when address config is left out or empty, is "localhost"
port: 8080,
basePath: "/", // The URL path where MagicMirror² is hosted. If you are using a Reverse proxy
// you must set the sub path here. basePath must end with a /
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], // Set [] to allow all IP addresses
// or add a specific IPv4 of 192.168.1.5 :
// ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.1.5"],
// or IPv4 range of 192.168.3.0 --> 192.168.3.15 use CIDR format :
// ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.3.0/28"],
useHttps: false, // Support HTTPS or not, default "false" will use HTTP
httpsPrivateKey: "", // HTTPS private key path, only require when useHttps is true
httpsCertificate: "", // HTTPS Certificate path, only require when useHttps is true
language: "en",
locale: "en-US",
logLevel: ["INFO", "LOG", "WARN", "ERROR"], // Add "DEBUG" for even more logging
timeFormat: 24,
units: "metric",
modules: [
{
module: "alert",
},
{
module: 'MMM-pages',
config: {
modules:
[[ "clock", "updatenotification", "MMM-AlexaControl", "newsfeed"],
[ "compliments", "calendar", "MMM-AlexaControl"]],
fixed: ["MMM-AlexaControl"],
}
},
{
module: "MMM-AlexaControl",
position: "middle_center",
config: {
image: true,
height: 265,
width: 265,
devices: [
{
name: "Seite 1",
port: 11100,
handler: 'PAGE_CHANGED',
payload: function(payload) {
return { 'page': 0 };
}
},
{
name: "Seite 2",
port: 11101,
handler: 'PAGE_CHANGED',
payload: function(payload) {
return { 'page': 1 };
}
}
],
startPort: 11000,
refresh: true,
restart: true,
stop: true,
reboot: false,
shutdown: false,
pm2ProcessName: "pm2",
monitorToggle: true,
vcgencmd: true,
usb: false
}
},
.... and so on
The MMM-AlexaControl JS:
/**
* Magic Mirror
* Module: MMM-AlexaControl
*
* By JoChef2
* MIT Licensed.
*/
Module.register("MMM-AlexaControl",{
defaults:{
image: true,
height: 265,
width: 265,
pages: 3,
devices: {
"Seite 1": {
port: 11100,
handler: 'PAGE_CHANGED',
payload: function(payload) {
return { 'page': 0 };
}
},
"Seite 2": {
port: 11101,
handler: 'PAGE_CHANGED',
payload: function(payload) {
return { 'page': 1 };
}
},
}
notifications: [], // empty array for your notification devices
commands: [], // empty array for your command devices
startPort: 11000, // the lowest used port
refresh: true, // refresh your Mirror
restart: true, // restart your Mirror with pm2
stop: true, // stops your Mirror with pm2
reboot: false, // reboot your pi
shutdown: false, // shutdown your pi
pm2ProcessName: "mm", // name of your pm2 process
monitorToggle: true, // switch your monitor on and off
vcgencmd: 'vcgencmd', // command you use for monitor toggle
cecAddress: "0.0.0.0", // Address for the cec-client
usb: false // toggle usb power of your pi
},
getTranslations: function(){ // add more translations
return {
en: "translations/en.json",
de: "translations/de.json"
}
},
start: function(){
Log.log('Starting module: ' + this.name);
// send all translations to node_helper
this.sendSocketNotification('TRANSLATIONS', {"monitor": this.translate("MONITOR"), "shutdown": this.translate("SHUTDOWN"), "reboot": this.translate("REBOOT"), "page": this.translate("PAGE"), "refresh": this.translate("REFRESH"), "restart": this.translate("RESTART"), "stop": this.translate("STOP"), "usb": this.translate("USB"), "deviceName":this.translate(this.config.deviceName)});
this.sendSocketNotification('SET_DEVICE', this.config); // send the config to node_helper
},
getDom: function(){ // returns only an image or an empty div (necessary for MMM-Pages)
if(this.config.image){
let img = document.createElement("img");
img.classList = "img";
img.src = "MMM-AlexaControl/AlexaLogoGrey.png";
img.height = this.config.height;
img.width = this.config.width;
return img;
}else{
return document.createElement("div");
}
},
socketNotificationReceived: function(notification, payload) {
if(notification === "PAGE_CHANGED"){ // change pages of MMM-Pages
this.sendNotification("PAGE_CHANGED", payload);
}
if(notification === "ACTION"){ // refresh the Mirror
if(payload === "refresh"){
window.location.reload(true);
}
}
if(notification === "CUSTOM"){
this.sendNotification(payload[0], payload[1]); // send any notification to any module
}
if(notification =='MONITOR_ACTION'){
Log.log('RECEIVE monitor NOTIFICATION='+payload)
this.sendNotification(notification,payload)
}
}
});
Node Fauxmo index.js:
'use strict';
const FauxMo = require('node-fauxmo');
let fauxMo = new FauxMo(
{
devices: [
{
name: 'Seite 1',
port: 11000,
handler: function(action) {
console.log('Seite 1:', action);
}
},
{
name: 'Seite 2',
port: 11001,
handler: function(action) {
console.log('Seite 2:', action);
}
},
{
name: 'Seite 3',
port: 11002,
handler: function(action) {
console.log('Seite 3:', action);
}
}]
});
And the MMM-Pages is basically untouched… so default Config entrys in there.
Any hints what i am doing wrong?
Best Regards
The Noob :)