From 08aa0eaf13b790e3622016e751459126ee05bfe7 Mon Sep 17 00:00:00 2001 From: dgreif Date: Sun, 2 Oct 2022 08:12:11 -0700 Subject: [PATCH] fix(homebridge): prevent undefined brightness for alarms Closes #1057 --- homebridge/brightness-only.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/homebridge/brightness-only.ts b/homebridge/brightness-only.ts index d63b6ed4..e1eed729 100644 --- a/homebridge/brightness-only.ts +++ b/homebridge/brightness-only.ts @@ -16,13 +16,16 @@ export class BrightnessOnly extends BaseDeviceAccessory { const { Characteristic, Service } = hap, { context } = accessory - if ('brightness' in device.data && !isNaN(device.data.brightness!)) { + if ( + device.data.brightness !== undefined && + !isNaN(device.data.brightness) + ) { this.registerLevelCharacteristic({ characteristicType: Characteristic.Brightness, serviceType: Service.Lightbulb, getValue: (data) => { if (!data.brightness || isNaN(data.brightness)) { - return undefined + return 0 } // store the brightness so that we can set it again if light is turned off then back on