diff --git a/package-lock.json b/package-lock.json index ff05d70..18b702b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "homebridge-blaq", - "version": "0.2.7", + "version": "0.2.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "homebridge-blaq", - "version": "0.2.7", + "version": "0.2.8", "license": "Apache-2.0", "dependencies": { "bonjour-service": "^1.2.1", diff --git a/package.json b/package.json index 413bc9d..d2bd61b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "private": false, "displayName": "Konnected BlaQ", "name": "homebridge-blaq", - "version": "0.2.7", + "version": "0.2.8", "description": "Control and view your garage door(s) remotely with real-time updates using Konnected's BlaQ hardware", "license": "Apache-2.0", "type": "module", diff --git a/src/accessory/garage-learn-mode.ts b/src/accessory/garage-learn-mode.ts index 79e9d0b..2289d0e 100644 --- a/src/accessory/garage-learn-mode.ts +++ b/src/accessory/garage-learn-mode.ts @@ -127,9 +127,9 @@ export class BlaQGarageLearnModeAccessory implements BaseBlaQAccessory { try { const stateInfo = JSON.parse(stateEvent.data) as StateUpdateRecord; if (['switch-learn'].includes(stateInfo.id)) { - const buttonEvent = stateInfo as BlaQButtonEvent & { state: 'ON' | 'OFF' }; - if(['OFF', 'ON'].includes(buttonEvent.state.toUpperCase())){ - this.setIsOn(buttonEvent.state.toUpperCase() === 'ON'); + const buttonEvent = stateInfo as BlaQButtonEvent & { state?: 'ON' | 'OFF' }; + if(['OFF', 'ON'].includes(buttonEvent.state?.toUpperCase() || '')){ + this.setIsOn(buttonEvent.state?.toUpperCase() === 'ON'); } } else if (['text_sensor-esphome_version', 'text_sensor-firmware_version'].includes(stateInfo.id)) { const b = stateInfo as BlaQTextSensorEvent; diff --git a/src/accessory/garage-light.ts b/src/accessory/garage-light.ts index cac3575..9497bb1 100644 --- a/src/accessory/garage-light.ts +++ b/src/accessory/garage-light.ts @@ -131,10 +131,10 @@ export class BlaQGarageLightAccessory implements BaseBlaQAccessory { try { const stateInfo = JSON.parse(stateEvent.data) as StateUpdateRecord; if (['light-garage_light', 'light-light'].includes(stateInfo.id)) { - const buttonEvent = stateInfo as BlaQButtonEvent & { state: 'ON' | 'OFF' }; + const buttonEvent = stateInfo as BlaQButtonEvent & { state?: 'ON' | 'OFF' }; this.lightType = stateInfo.id.split(LIGHT_PREFIX).pop() as GarageLightType; - if(['OFF', 'ON'].includes(buttonEvent.state.toUpperCase())){ - this.setPowerState(buttonEvent.state.toUpperCase() === 'ON'); + if(['OFF', 'ON'].includes(buttonEvent.state?.toUpperCase() || '')){ + this.setPowerState(buttonEvent.state?.toUpperCase() === 'ON'); } } else if (['text_sensor-esphome_version', 'text_sensor-firmware_version'].includes(stateInfo.id)) { const b = stateInfo as BlaQTextSensorEvent; diff --git a/src/accessory/garage-lock.ts b/src/accessory/garage-lock.ts index f69a8e2..ed747fd 100644 --- a/src/accessory/garage-lock.ts +++ b/src/accessory/garage-lock.ts @@ -145,10 +145,10 @@ export class BlaQGarageLockAccessory implements BaseBlaQAccessory { try { const stateInfo = JSON.parse(stateEvent.data) as StateUpdateRecord; if (['lock-lock', 'lock-lock_remotes'].includes(stateInfo.id)) { - const buttonEvent = stateInfo as BlaQButtonEvent & { state: 'ON' | 'OFF' }; + const buttonEvent = stateInfo as BlaQButtonEvent & { state?: 'ON' | 'OFF' }; this.lockType = stateInfo.id.split(LOCK_PREFIX).pop() as GarageLockType; - if(['UNLOCKED', 'LOCKED'].includes(buttonEvent.state.toUpperCase())){ - this.setLockState(buttonEvent.state.toUpperCase() === 'LOCKED'); + if(['UNLOCKED', 'LOCKED'].includes(buttonEvent.state?.toUpperCase() || '')){ + this.setLockState(buttonEvent.state?.toUpperCase() === 'LOCKED'); } } else if (['text_sensor-esphome_version', 'text_sensor-firmware_version'].includes(stateInfo.id)) { const b = stateInfo as BlaQTextSensorEvent; diff --git a/src/accessory/garage-pre-close-warning.ts b/src/accessory/garage-pre-close-warning.ts index 39b2f97..62a4101 100644 --- a/src/accessory/garage-pre-close-warning.ts +++ b/src/accessory/garage-pre-close-warning.ts @@ -126,9 +126,9 @@ export class BlaQGaragePreCloseWarningAccessory implements BaseBlaQAccessory { try { const stateInfo = JSON.parse(stateEvent.data) as StateUpdateRecord; if (['button-pre-close_warning'].includes(stateInfo.id)) { - const buttonEvent = stateInfo as BlaQButtonEvent & { state: 'ON' | 'OFF' }; - if(['OFF', 'ON'].includes(buttonEvent.state.toUpperCase())){ - this.setIsOn(buttonEvent.state.toUpperCase() === 'ON'); + const buttonEvent = stateInfo as BlaQButtonEvent & { state?: 'ON' | 'OFF' }; + if(['OFF', 'ON'].includes(buttonEvent.state?.toUpperCase() || '')){ + this.setIsOn(buttonEvent.state?.toUpperCase() === 'ON'); } } else if (['text_sensor-esphome_version', 'text_sensor-firmware_version'].includes(stateInfo.id)) { const b = stateInfo as BlaQTextSensorEvent;