Skip to content

Commit

Permalink
fix crash cases on unknown push updates
Browse files Browse the repository at this point in the history
- if no id_v1 is existing
  • Loading branch information
foxriver76 committed Jun 14, 2023
1 parent 361527f commit 90b8967
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ In den Adapter-Settings muss die IP der Hue Bridge sowie ein Username konfigurie
Placeholder for the next version (at the beginning of the line):
### __WORK IN PROGRESS__
-->

### __WORK IN PROGRESS__
* (foxriver76) fix crash cases on unknown push updates (closes #417)

### 3.9.2 (2023-06-13)
* (foxriver76) fix sensor converting (closes #415)

Expand Down
4 changes: 4 additions & 0 deletions build/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/main.js.map

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface BridgeUpdate {
/** The UUID which is used by Hue API v2 */
id: string;
/** The old Hue API v1 id */
id_v1: `/${string}/${number}`;
id_v1?: `/${string}/${number}`;
owner: { rid: string; rtype: string };
type:
| 'grouped_light'
Expand Down Expand Up @@ -1097,6 +1097,11 @@ class Hue extends utils.Adapter {
async handleUpdate(update: BridgeUpdate): Promise<void> {
this.log.debug(`New push connection update: ${JSON.stringify(update)}`);

if (!update.id_v1) {
this.log.debug('Ignore push connection update, because property "id_v1" is missing');
return;
}

const id = parseInt(update.id_v1.split('/')[2]);

if (update.type === 'light') {
Expand Down

0 comments on commit 90b8967

Please sign in to comment.