Skip to content

Commit 5ea6df6

Browse files
committed
Now using module.identifier to handle multiple instances of the same module.
1 parent 0153cc1 commit 5ea6df6

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

MMM-MyTTC.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ Module.register('MMM-MyTTC', {
5454

5555
Log.info('Starting module: ' + this.name);
5656

57-
this.UNIQUE_STRING = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5);
58-
5957
this.loaded = false;
6058
this.ttcData = null;
6159

@@ -69,12 +67,12 @@ Module.register('MMM-MyTTC', {
6967
},
7068

7169
getData: function() {
72-
this.sendSocketNotification("MMM-MYTTC-GET", {unique: this.UNIQUE_STRING, config:this.config});
70+
this.sendSocketNotification("MMM-MYTTC-GET", {instanceId: this.identifier, config: this.config});
7371
},
7472

7573
socketNotificationReceived: function(notification, payload) {
7674
//only update if a data set is returned. Otherwise leave stale data on the screen.
77-
if ( notification === 'MMM-MYTTC-RESPONSE' + this.UNIQUE_STRING && payload != null) {
75+
if ( notification === 'MMM-MYTTC-RESPONSE' + this.identifier && payload != null) {
7876
this.ttcData = payload;
7977

8078
//only fade in tye module after the first data pull

node_helper.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ module.exports = NodeHelper.create({
4141
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) { //good
4242

4343
var processedData = self.processJSON(xmlHttp.responseText, payload.config);
44-
self.sendSocketNotification('MMM-MYTTC-RESPONSE' + payload.unique, processedData);
44+
self.sendSocketNotification('MMM-MYTTC-RESPONSE' + payload.instanceId, processedData);
4545

4646
} else if (xmlHttp.readyState == 4) { //bad...
47-
self.sendSocketNotification('MMM-MYTTC-RESPONSE' + payload.unique, {data:null});
47+
self.sendSocketNotification('MMM-MYTTC-RESPONSE' + payload.instanceId, {data:null});
4848
}
4949
}
5050
xmlHttp.open("GET", builtURL, true); // true for asynchronous

0 commit comments

Comments
 (0)