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

Bug and device fix #2357

Merged
merged 15 commits into from
Jan 12, 2025
2 changes: 1 addition & 1 deletion lib/binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class Binding {
await this.doBindUnbind(type, bind_source, bind_source_ep, 'coordinator', '1');
this.debug('Successfully ' + (type === 'bind' ? 'bound' : 'unbound') + ' Coordinator from ' + bind_source);
} catch (e) {
this.error(`Could not ${type} Coordinator from ${bind_source}: ${JSON.stringify(e)}`);
this.error(`Could not ${type} Coordinator from ${bind_source}: ${(e && e.message ? e.message : 'no error message')} ${(e && e.stack ? e.stack : 'no call stack')}`);
}
}
} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ class Commands {
return;
}
}
catch (e) {
this.error(JSON.stringify(e));
catch (error) {
this.error(`Pairing with code failed with: ${(error && error.message ? error.message : 'no error message')} ${(error && error.stack ? error.stack : 'no call stack')}`);
this.adapter.sendTo(
from, command,
{error: 'Exception when trying to add QR code'},
Expand Down
8 changes: 4 additions & 4 deletions lib/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
}

} catch (error) {
if (error) this.error(`getGroupMembersFromController: error is ${JSON.stringify(error)} ${JSON.stringify(new Error().stack)}`);
if (error) this.error(`getGroupMembersFromController: error is ${(error && error.message ? error.message : 'no error message')} ${(error && error.stack ? error.stack : 'no call stack')}`);

Check warning

Code scanning / CodeQL

Useless conditional Warning

This use of variable 'error' always evaluates to true.

Check warning

Code scanning / CodeQL

Useless conditional Warning

This use of variable 'error' always evaluates to true.
else this.error('unidentifed error in getGroupMembersFromController');
}
return members;
Expand Down Expand Up @@ -138,15 +138,15 @@
for (const gpid of groups[epid]) {
const gpidn = parseInt(gpid);
if (gpidn < 0) {
this.warn(`calling removeDevFromGroup with ${sysid}, ${-gpidn}, ${epid}` );
this.debug(`calling removeDevFromGroup with ${sysid}, ${-gpidn}, ${epid}` );
const response = await this.zbController.removeDevFromGroup(sysid, (-gpidn), epid);
if (response && response.error) {
errors.push(response.error);
this.error(`remove dev from group Error: ${JSON.stringify(response.error)}`);
}

} else if (gpidn > 0) {
this.warn(`calling addDevToGroup with ${sysid}, ${gpidn}, ${epid}` );
this.debug(`calling addDevToGroup with ${sysid}, ${gpidn}, ${epid}` );
const response = await this.zbController.addDevToGroup(sysid, (gpidn), epid);
if (response && response.error) {
errors.push(response.error);
Expand All @@ -158,7 +158,7 @@
}
}
} catch (e) {
this.warn('caught error ' + JSON.stringify(e) + ' in updateGroupMembership');
this.warn('caught error ' + (e && e.message ? e.message : 'no error message') + ' in updateGroupMembership');
this.adapter.sendTo(from, command, {error: e}, callback);
return;
}
Expand Down
10 changes: 5 additions & 5 deletions lib/statescontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
retainDeviceNames() {
clearTimeout(this.retTimeoutHandle);
this.retTimeoutHanlde = setTimeout(() => {
fs.writeFile(this.dev_names_fn, JSON.stringify(savedDeviceNamesDB, null, 2), err => {
if (err) {
this.error(`error saving device names: ${JSON.stringify(err)}`);
fs.writeFile(this.dev_names_fn, JSON.stringify(savedDeviceNamesDB, null, 2), error => {
if (error) {
this.error(`error saving device names: ${(error && error.message ? error.message : 'no error message')} ${(error && error.stack ? error.stack : 'no call stack')}`);
Dismissed Show dismissed Hide dismissed

Check warning

Code scanning / CodeQL

Useless conditional Warning

This use of variable 'error' always evaluates to true.
} else {
this.debug('saved device names');
}
Expand Down Expand Up @@ -109,7 +109,7 @@
}

if (this.checkDebugDevice(id))
this.warn(`ELEVATED O1: User state change of state ${id} with value ${state.val} (ack: ${state.ack}) from ${state.from}`);
this.warn(`ELEVATED O01: User state change of state ${id} with value ${state.val} (ack: ${state.ack}) from ${state.from}`);

this.debug(`User stateChange ${id} ${JSON.stringify(state)}`);
const devId = getAdId(this.adapter, id); // iobroker device id
Expand Down Expand Up @@ -211,7 +211,7 @@
this.debug(`Change state '${stateKey}' at device ${deviceId} type '${model}'`);
const elevated = this.checkDebugDevice(deviceId);

if (elevated) this.warn(`ELEVATED O2: Change state '${stateKey}' at device ${deviceId} type '${model}'`);
if (elevated) this.warn(`ELEVATED O02: Change state '${stateKey}' at device ${deviceId} type '${model}'`);

const devStates = await this.getDevStates(deviceId, model);
if (!devStates) {
Expand Down
2 changes: 1 addition & 1 deletion lib/zbDeviceAvailability.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class DeviceAvailability extends BaseExtension {
}
} catch (error) {
this.sendError(error);
this.debug(`Exception in readState of '${device.ieeeAddr}' - error : '${error}'`);
this.debug(`Exception in readState of '${device.ieeeAddr}' - error : '${(error && error.message ? error.message : 'no error message')}'`);
// intentionally empty: Just present to ensure we cause no harm
// when reading the state fails. => fall back on standard Ping function
}
Expand Down
Loading
Loading