Skip to content

Commit

Permalink
fix(dingz): fix (another) crash on empty / undefined sn
Browse files Browse the repository at this point in the history
- catches another edge case w/  `undefined` serial number
- fixes #116, bug is (also) upstream homebridge/HAP-NodeJS#824
- 🙈
  • Loading branch information
johannrichard committed Dec 8, 2020
1 parent 6a41816 commit 795dea2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/dingzAccessory.ts
Expand Up @@ -207,9 +207,12 @@ export class DingzAccessory extends DingzDaBaseAccessory {
`Attempting to set SerialNumber (which can not be empty) -> front_sn: <${this.dingzDeviceInfo.front_sn}>`,
);
const serialNumber: string =
this.dingzDeviceInfo.front_sn === ''
? this.device.mac // MAC will always be defined for a correct device
: this.dingzDeviceInfo.front_sn;
!this.dingzDeviceInfo.front_sn || '' === this.dingzDeviceInfo.front_sn
? this.device.mac
: this.dingzDeviceInfo.front_sn; // MAC will always be defined for a correct device
this.log.debug(
`Setting SerialNumber (which can not be empty) -> : <${serialNumber}>`,
);
this.accessory
.getService(this.platform.Service.AccessoryInformation)!
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'iolo AG')
Expand Down

0 comments on commit 795dea2

Please sign in to comment.