Skip to content

Commit

Permalink
Merge pull request #2357 from asgothian/master
Browse files Browse the repository at this point in the history
Bug and device fix
  • Loading branch information
asgothian authored Jan 12, 2025
2 parents 2f5bb8d + 375cdcf commit 99e52f0
Show file tree
Hide file tree
Showing 7 changed files with 235 additions and 167 deletions.
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 @@ class Groups {
}

} 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')}`);
else this.error('unidentifed error in getGroupMembersFromController');
}
return members;
Expand Down Expand Up @@ -138,15 +138,15 @@ class Groups {
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 @@ class Groups {
}
}
} 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 @@ class StatesController extends EventEmitter {
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')}`);
} else {
this.debug('saved device names');
}
Expand Down Expand Up @@ -109,7 +109,7 @@ class StatesController extends EventEmitter {
}

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 @@ class StatesController extends EventEmitter {
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

0 comments on commit 99e52f0

Please sign in to comment.