@bobbythemoh Can you please post your pm2
log. You can optain it by executing pm2 log MagicMirror
if you are using pm2
.
I just detected some unhandled rejections which may cause the black screen.
@bobbythemoh Can you please post your pm2
log. You can optain it by executing pm2 log MagicMirror
if you are using pm2
.
I just detected some unhandled rejections which may cause the black screen.
@sdetweil Actualy JSON requires quotation of the key and of the value (if the value is a string)
Example of a JSON file:
{
"string": "This is a string",
"bool": true,
"int", 1,
"float": 3.14,
"arrayOfStrings": [
"string1",
"string2"
],
"arrayOfInts": [
1,
2
]
}
The same can be used in a Javascript file, but as an object. You can also throw away the quotation of the keys.
@sdetweil I don’t think that. The helper is running on your Raspberry Pi, the module is running in every browser instance you open.
You need to coordinate your “show image event” from the helper and send out a notification to the module what image to show.
The ViewManagement must be in the module, the image downloading, handling must be in the helper.
Note: You only have one helper, but you can have multiple modules!
@sdetweil A MagicMirror Module has two parts, the node_helper.js
and any other required
node.js modulewhich runs on your Raspberry Pi, the other part is just plain Javascript like in any Website running on the Browser (Electron in the default case).
There are many node.js websocket server modules: https://www.npmjs.com/search?q=Websocket
Your node_helper.js
is running the Websocket server and your other part is running a Websocket client. Follow this tutorial for the Websocket Client
The communication won’t be encrypted in any way, so don’t pass importand information over the Websocket!
@sdetweil I solved this problem by using this.sendSocketNotification
This allows me to communicate with the modules interface.
@sdetweil Wait, I think I misunderstoodyour question.
Do you want to have a class variable just in your node_helper.js
, or do you want to share a variable between node_helper.js
and your MMM-ModuleName.js
file?
@sdetweil Thats simply how to define a variable inside an object in node.js :grinning_face_with_smiling_eyes:
@brenj You definitely need some JSLint: https://www.jslint.com/
:winking_face:
@sdetweil If you want class variables you can do the following:
module.exports = NodeHelper.create({
variable1: true, // This is one way
start: function() {
this.variable2 = true // This is another way
// Both variables can be accessed via this.VARIABLE_NAME
}
});
@sdetweil You can establish a custom Websocket connection between your node_helper.js
, which is node.js and your other JS code which runs in a browser.