From 795dea26978cd2e238447132cae9c0296ccd6a26 Mon Sep 17 00:00:00 2001 From: Johann Richard <189003+johannrichard@users.noreply.github.com> Date: Tue, 8 Dec 2020 17:59:27 +0100 Subject: [PATCH] fix(dingz): fix (another) crash on empty / undefined sn - catches another edge case w/ `undefined` serial number - fixes #116, bug is (also) upstream homebridge/HAP-NodeJS#824 - :see_no_evil: --- src/dingzAccessory.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/dingzAccessory.ts b/src/dingzAccessory.ts index 0e4a81d..ba809b7 100644 --- a/src/dingzAccessory.ts +++ b/src/dingzAccessory.ts @@ -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')