Skip to content

Commit

Permalink
improve error handling on deleteing devices and channels
Browse files Browse the repository at this point in the history
  • Loading branch information
foxriver76 committed Feb 24, 2021
1 parent fd8468c commit b7c9f9f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ by ioBroker, when you have a running 'dummy' program on the CCU which depends on
Placeholder for the next version (at the beginning of the line):
### __WORK IN PROGRESS__
-->

__WORK IN PROGRESS__
* (foxriver76) error handling improved when deleting obsolete devices/channels

### 1.14.35 (2021-02-13)
* (foxriver76) virtual devices now support ping, so use it, else it can be that instance won't register at CCU again (fixes #308)

Expand Down
16 changes: 12 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1001,11 +1001,19 @@ async function initRpcServer() {
if (val.ADDRESS.indexOf(':') !== -1) {
const address = val.ADDRESS.replace(':', '.').replace(FORBIDDEN_CHARS, '_');
const parts = address.split('.');
adapter.deleteChannel(parts[parts.length - 2], parts[parts.length - 1]);
adapter.log.info(`obsolete channel ${address} ${JSON.stringify(address)} deleted`);
try {
await adapter.deleteChannelAsync(parts[parts.length - 2], parts[parts.length - 1]);
adapter.log.info(`obsolete channel ${address} ${JSON.stringify(address)} deleted`);
} catch (e) {
adapter.log.error(`Could not delete obsolete channel ${address} ${JSON.stringify(address)}: ${e.message}`);
}
} else {
adapter.deleteDevice(val.ADDRESS);
adapter.log.info(`obsolete device ${val.ADDRESS} deleted`);
try {
await adapter.deleteDeviceAsync(val.ADDRESS);
adapter.log.info(`obsolete device ${val.ADDRESS} deleted`);
} catch (e) {
adapter.log.error(`Could not delete obsolete device ${val.ADDRESS}: ${e.message}`);
}
}
}
} else {
Expand Down

0 comments on commit b7c9f9f

Please sign in to comment.