Skip to content

Commit

Permalink
Fixed undefined to uppercase crash
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleBoyer committed Jul 15, 2024
1 parent 2084d34 commit 4cf719f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions src/accessory/garage-learn-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/accessory/garage-light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/accessory/garage-lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/accessory/garage-pre-close-warning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4cf719f

Please sign in to comment.