Skip to content

Commit

Permalink
2.5.3a
Browse files Browse the repository at this point in the history
  • Loading branch information
foxthefox committed Oct 15, 2023
1 parent 7287b7d commit f3e5d44
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 28 deletions.
4 changes: 2 additions & 2 deletions admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
$('#testd').click(testd);
$('#testg').click(testg);
$('#testt').click(testt);
//$('#tests').click(tests); //hier muß es eine Übergabe der ain geben
$('#tests').click(tests);
$('#testc').click(testc);
$('#testo').click(testo);
$('#testr').click(testr);
Expand Down Expand Up @@ -330,7 +330,7 @@ <h6 class="translate sub-title">FritzBox Adapter Debugging</h6>
<a id="testt" class="btn"><span class="translate">My Templates</span></a>
</div>
<div class="col s2">
<a id="testc" class="btn"><span class="translate">My Color</span></a>
<a id="tests" class="btn"><span class="translate">My Stats</span></a>
</div>
<div class="col s2">
<a id="testo" class="btn"><span class="translate">My Rights</span></a>
Expand Down
55 changes: 29 additions & 26 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ class Fritzdect extends utils.Adapter {
});

if (deviceswithstat && deviceswithstat.val) {
this.log.info('glob state ' + deviceswithstat.val);
this.log.debug('glob state ' + deviceswithstat.val);
let devstat = [].concat([], JSON.parse(String(deviceswithstat.val)));
for (let i = 0; i < devstat.length; i++) {
this.log.debug('updating device ' + devstat[i]);
this.log.debug('updating Stats of device ' + devstat[i]);
await this.updateStats(devstat[i], this.fritz);
}
}
Expand Down Expand Up @@ -1020,7 +1020,7 @@ class Fritzdect extends utils.Adapter {
// device.identifier = device.identifier.replace(/\s/g, '');
return device;
});
result = devices;
result.push(devices);
})
.then(async () => {
if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
Expand All @@ -1046,7 +1046,7 @@ class Fritzdect extends utils.Adapter {
// group.identifier = group.identifier.replace(/\s/g, '');
return group;
});
result = groups;
result.push(groups);
})
.then(async () => {
if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
Expand All @@ -1073,7 +1073,7 @@ class Fritzdect extends utils.Adapter {
// template.identifier = group.identifier.replace(/\s/g, '');
return template;
});
result = templates;
result.push(templates);
})
.then(async () => {
if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
Expand All @@ -1096,7 +1096,7 @@ class Fritzdect extends utils.Adapter {
trigger = [].concat((trigger.triggerlist || {}).trigger || []).map((trigger) => {
return trigger;
});
result = trigger;
result.push(trigger);
})
.then(async () => {
if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
Expand All @@ -1112,32 +1112,35 @@ class Fritzdect extends utils.Adapter {
wait = true;
break;
case 'statistic':
this.fritz
.getBasicDeviceStats(obj.message) //ain muß übergeben werden aus message
.then(function(statisticinfos) {
//obj.message should be ain of device requested
const devicestats = parser.xml2json(statisticinfos);
result = devicestats;
})
.then(async () => {
if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
})
.catch((e) => {
this.log.debug('error calling in msgbox');
throw {
msg: 'issue getting statistics',
function: 'onMessage',
error: e
};
});
const deviceswithstat = await this.getStateAsync('global.statdevices').catch((e) => {
this.log.warn('problem getting statdevices ' + e);
});
//let result = '';
if (deviceswithstat && deviceswithstat.val) {
this.log.debug('msg statistics ' + deviceswithstat.val);
let devstat = [].concat([], JSON.parse(String(deviceswithstat.val)));
for (let i = 0; i < devstat.length; i++) {
let stats = await this.fritz.getBasicDeviceStats(devstat[i]).catch((e) => {
this.log.debug('error calling in msgbox');
throw {
msg: 'issue getting statistics',
function: 'onMessage',
error: e
};
});
let statsobj = parser.xml2json(stats);
result.push(statsobj);
}
}
if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
wait = true;
break;
case 'color':
this.fritz
.getColorDefaults()
.then(function(colorinfos) {
let colors = parser.xml2json(colorinfos);
result = colors;
result.push(colors);
})
.then(async () => {
if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
Expand All @@ -1157,7 +1160,7 @@ class Fritzdect extends utils.Adapter {
.getUserPermissions()
.then(function(rights) {
const permission = parser.xml2json(rights);
result = permission;
result.push(permission);
})
.then(async () => {
if (obj.callback) this.sendTo(obj.from, obj.command, result, obj.callback);
Expand Down

0 comments on commit f3e5d44

Please sign in to comment.