hI @ianperrin
It Works !!!
Nice explanations.
My mistake is when i launched a webpage to write the url i stoped the MM by Ctrl+Q. Now with MM start and a webpage opened. Everything is alright
Thanks for your help
hI @ianperrin
It Works !!!
Nice explanations.
My mistake is when i launched a webpage to write the url i stoped the MM by Ctrl+Q. Now with MM start and a webpage opened. Everything is alright
Thanks for your help
ok thanks ianperrin for your help
Step 2 is ok because on magic mirror, i have the link on magic mirror : client unauthorized see /MMM-Strava/auth/
but now in step 5, i make:
in webpage, and magic mirror starting i put
http://192.128.1.99:8080/MMM-Strava/Oauth/
but nothing happen. The webpage says:
host unreachable
ERR_CONNECTION_REFUSED
have you an idea?
Hi everybody,
I posted in troubleshooting section but i don’t know if it’s visible. That’s why i post here. I don’t understand the step 2 and the step 5 in Tutorial about MMM-Strava. I have a ID and a secret but i don’t know what i write in case:
APi Name
Category
Club
WebSite
Description
and Callback domain
In Website and Callback domain what i write?
In callback domain, i put my IP to my magic mirror like 192.128.1.99:8080 but nothing happen
Can anybody help me please?
Hi nothing use this module?
Anybody can help me please?
Hi everybody
I try to install MMM-Strava on my magic mirror but i have problem with authorization.
Installation is ok because when i restarted the Magic Mirror i had a message like “check authorization”
i followed explanation about installation but i have problem in step 2:
Make sure the callback domain matches the IP address (or URL) used to access the MagicMirror.
I don’t know what i write in this case
On Strava APi application i must complete:
APi Name
Category
Club
WebSite
Description
and Callback domain
Can anybody help me please to write the good things ?
After this, i’ don’t understand the step 5
Authenticate the module to allow access to the Strava API.
Browse to the Strava authentication page: http://localhost:8080/MMM-Strava/auth/ - the exact URL may vary depending on your configuration.
Select the module you wish to authenticate (e.g. module_4_MMM-Strava) and click/tap Authorise -The number of the modules will vary depending on your configuration.
On the Strava Authorisation page, select the level of access you wish to give to the Magic Mirror, and click/tap Authorize - the module requires at least View data about your public profile and View data about your activities but it’s up to you whether you want to allow access to private activities.
Once the successful authorisation message appears, restart your Magic Mirror.
What is the good authenticate url ?
Thanks for your help
@sdetweil i send you a personal mail with my domoticz module and config.js.
Thanks for your help
hi @sdetweil , sorry for this late answer, i’m very busy at this moment
I applied your programe line and now, in the console i have:
:8080/modules/fabio/domoticz//domoticz.js:142 Uncaught TypeError: Cannot read property ‘0’ of undefined
at Class.processJson (:8080/modules/fabio/domoticz//domoticz.js:142)
at XMLHttpRequest.domoRequest.onreadystatechange (:8080/modules/fabio/domoticz//domoticz.js:128)
and this:
domoticz.js:142 Uncaught TypeError: Cannot read property ‘0’ of undefined
at Class.processJson (domoticz.js:142)
at XMLHttpRequest.domoRequest.onreadystatechange (domoticz.js:128)
processJson @ domoticz.js:142
domoRequest.onreadystatechange @ domoticz.js:128
XMLHttpRequest.send (async)
updateDomo @ domoticz.js:136
(anonymous) @ domoticz.js:170
and the js script below
/* global Module */
/* Magic Mirror
* Module: Domoticz
*
* By Mathias Arvidsson
*/
Module.register("domoticz",{
defaults: {
units: config.units,
updateInterval: 50,
animationSpeed: 0,
timeFormat: config.timeFormat,
lang: config.language,
initialLoadDelay: 0,
retryDelay: 2500,
apiBase: "http://1xx.1xx.x.xx", // IP domoticz
apiPort: "xxxx", // Port
sensors: [
{
idx: "1",
symbolon: "fa fa-user",
symboloff: "fa fa-user-o",
hiddenon: false,
hiddenoff: false,
customTitle: "",
},
],
},
firstEvent: false,
getStyles: function() {
return ['font-awesome.css'];
},
// Define required scripts.
getScripts: function() {
return ["moment.js"];
},
// Define start sequence.
start: function() {
Log.info("Starting module: " + this.name);
// Set locale.
moment.locale(config.language);
this.loaded = false;
this.status1 = false;
this.title = "Loading...";
this.scheduleUpdate(this.config.initialLoadDelay);
this.sensors = [];
for (var c in this.config.sensors) {
var sensor = this.config.sensors[c];
var newSensor = {idx:sensor.idx, symbolon:sensor.symbolon, symboloff:sensor.symboloff, hiddenon:sensor.hiddenon, hiddenoff:sensor.hiddenoff, customTitle:sensor.customTitle, status:"", sname:"",type:""};
Log.log(sensor.idx);
this.sensors.push(newSensor);
}
Log.log(this.sensors);
},
// Override dom generator.
getDom: function() {
var wrapper = document.createElement("div");
if (!this.loaded) {
wrapper.innerHTML = "Loading...";
wrapper.className = "dimmed light small";
return wrapper;
}
var tableWrap = document.createElement("table");
tableWrap.className = "small";
for (var c in this.sensors) {
var sensor = this.sensors[c];
if((sensor.status=="On" && sensor.hiddenon)||(sensor.status=="Off" && sensor.hiddenoff)) continue;
var sensorWrapper = document.createElement("tr");
sensorWrapper.className = "normal";
var symbolTD = document.createElement('td');
symbolTD.className = "symbol";
var symbol = document.createElement('i');
var symbolClass = sensor.symboloff
if(sensor.status=="On") symbolClass = sensor.symbolon
symbol.className = symbolClass;
symbolTD.appendChild(symbol);
sensorWrapper.appendChild(symbolTD);
var titleTD = document.createElement('td');
titleTD.className = "title bright";
if(sensor.status=="Off") titleTD.className = "title light";
titleTD.innerHTML = sensor.sname;
if(typeof sensor.customTitle !== 'undefined') titleTD.innerHTML = sensor.customTitle;
sensorWrapper.appendChild(titleTD);
var statusTD = document.createElement('td');
statusTD.className = "time light";
statusTD.innerHTML = sensor.status;
sensorWrapper.appendChild(statusTD);
tableWrap.appendChild(sensorWrapper);
}
wrapper.appendChild(tableWrap);
return wrapper;
},
updateDomo: function() {
var i = 0;
for (var c in this.sensors) {
Log.log("this is c: " + c);
var sensor = this.sensors[c];
var url = this.config.apiBase + ":" + this.config.apiPort + "/json.htm?type=devices&rid=" + sensor.idx;
var self = this;
var domoRequest = new XMLHttpRequest();
domoRequest.open("GET", url, true);
domoRequest.onreadystatechange = function() {
if (this.readyState === 4) {
if (this.status === 200) {
self.processJson(JSON.parse(this.response));
Log.log("Loaded data");
} else {
Log.error(self.name + ": Could not load data. request status="+this.status);
Log.log("Did not load data");
}
}
};
domoRequest.send();
i++;
}
},
processJson: function(data) {
Log.log("****Parsing data: " + c + " " + data.result[0].Name);
if (!data) {
// Did not receive usable new data.
// Maybe this needs a better check?
return;
}
for (var c in this.sensors) {
var sensor = this.sensors[c];
if(sensor.idx == data.result[0].idx){
this.sensors[c].sname = data.result[0].Name;
this.sensors[c].status = data.result[0].Data;
this.sensors[c].type = data.result[0].Type;
}
}
this.loaded = true;
this.updateDom(this.config.animationSpeed);
},
scheduleUpdate: function(delay) {
Log.log("Updating..");
var nextLoad = this.config.updateInterval;
if (typeof delay !== "undefined" && delay >= 0) {
nextLoad = delay;
}
var self = this;
setInterval(function() {
self.updateDomo();
}, 500 );
}
});
for your information, the module seems to work but i have this error.
Have you a solution?
thanks a lot
@sdetweil said in MMM-Domoticz Cannot read property '0' of undefined:
this is not set correctly if called in the domoRequest.onreadystatechange = function() {}
u should be using self… ‘this’ is context sensitive, means ‘inside this function’
hi @sdetweil, i replace conole.log by Log.log and now i have error in the console
Could not load data.
refered to line 131.
Sorry but i don’t unerstand your last post about this and self. Can you show me the good syntax or do you need the entire program?
thanks for your help
Hi everybody
I update my magic mirror from 2.6 to 2.8 and also npm to the latest version and now i have error on console (ctrl+ maj+i) with MMM-Domoticz:
domoticz.js:150 Uncaught TypeError: Cannot read property ‘0’ of undefined
at Class.processJson (domoticz.js:150)
at XMLHttpRequest.domoRequest.onreadystatechange (domoticz.js:128)
you see below the domoticz.js short program:
line 115: updateDomo: function() {
var i = 0;
for (var c in this.sensors) {
//console.log("this is c: " + c);
var sensor = this.sensors[c];
var url = this.config.apiBase + ":" + this.config.apiPort + "/json.htm?type=devices&rid=" + sensor.idx;
var self = this;
var domoRequest = new XMLHttpRequest();
domoRequest.open("GET", url, true);
domoRequest.onreadystatechange = function() {
if (this.readyState === 4) {
if (this.status === 200) {
line 128: self.processJson(JSON.parse(this.response));
//console.log("Loaded data");
} else {
Log.error(self.name + ": Could not load data.");
//console.log("Did not load data");
}
}
};
domoRequest.send();
i++;
}
},
processJson: function(data) {
//console.log("****Parsing data: " + c + " " + data.result[0].Name);
if (!data) {
// Did not receive usable new data.
// Maybe this needs a better check?
return;
}
for (var c in this.sensors) {
var sensor = this.sensors[c];
line 150: if(sensor.idx == data.result[0].idx){
this.sensors[c].sname = data.result[0].Name;
this.sensors[c].status = data.result[0].Data;
this.sensors[c].type = data.result[0].Type;
}
}
and also i have also a problem with console.log (to mm2.6 also) the error message is:
console.log is not a function.
I post this because i’m noob in js script. My intenet searching for this problem is a failure.
Can anyboby help me please?
thanls for next answers
thanks @mumblebaj you’re awesome !!!. Git reset --hard work fine
Update MM2.8 is ok.