Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.5.0.d #431

Merged
merged 1 commit into from
Sep 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ class Fritzdect extends utils.Adapter {
this.log.error('error in permission xml2json ' + error);
}
}
this.log.info('start creating global values ');
await this.createGlobal();
this.log.info('finished creating global values');
this.log.info('start creating devices/groups');
await this.createDevices(this.fritz).catch((e) => this.errorHandlerAdapter(e));
this.log.info('finished creating devices/groups (if any)');
Expand All @@ -196,9 +199,6 @@ class Fritzdect extends utils.Adapter {
this.log.info('start creating routines ');
await this.createRoutines(this.fritz).catch((e) => this.errorHandlerAdapter(e));
this.log.info('finished creating routines (if any) ');
this.log.info('start creating global values ');
await this.createGlobal();
this.log.info('finished creating global values');
this.log.info('start initial updating devices/groups');
await this.updateDevices(this.fritz).catch((e) => this.errorHandlerAdapter(e));
this.log.info('finished initial updating devices/groups');
Expand Down Expand Up @@ -1479,7 +1479,7 @@ class Fritzdect extends utils.Adapter {
}
async updateStats(identifier, fritz) {
this.log.debug('update Stats objects ' + identifier);
let devstat = await this.fritz.getBasicDeviceStats().catch((e) => this.errorHandlerApi(e));
let devstat = await this.fritz.getBasicDeviceStats(identifier).catch((e) => this.errorHandlerApi(e));
let statsobj = parser.xml2json(devstat);
await Promise.all(
Object.entries(statsobj.devicetstats).map(async ([ key, obj ]) => {
Expand Down Expand Up @@ -2492,12 +2492,13 @@ class Fritzdect extends utils.Adapter {
await Promise.all(
Object.keys(device.powermeter).map(async (key) => {
//await this.asyncForEach(Object.keys(device.powermeter), async (key) => {
let oldarr = await this.getStateAsync('global.statsdevices').catch((e) => {
// if powermeter then there is a stat available
let oldarr = await this.getStateAsync('global.statdevices').catch((e) => {
this.log.warn('problem getting statdevices ' + e);
});
if (oldarr && oldarr.val) {
var newarray = JSON.parse(String(oldarr.val));
await this.setStateAsync('global.statsdevices', {
await this.setStateAsync('global.statdevices', {
val: JSON.stringify(newarray.push(identifier)),
ack: true
});
Expand Down