From 66a0b3be73f9e9c85e2343ecbed1d5fffc9f7915 Mon Sep 17 00:00:00 2001 From: Donavan Becker Date: Wed, 24 Nov 2021 23:38:55 -0600 Subject: [PATCH] v1.2.4 (#119) ## [Version 1.2.4](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v1.2.4) (2021-11-24) ## What's Changed * Fixed Bug: Cannot read properties of undefined (reading 'updateCharacteristic'). **Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v1.2.3...v1.2.4 --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- src/devices/bots.ts | 16 ++++++++-------- src/devices/contact.ts | 12 ++++++------ src/devices/curtains.ts | 10 +++++----- src/devices/humidifiers.ts | 4 ++-- src/devices/plugs.ts | 11 ----------- src/irdevices/airconditioners.ts | 12 ++++++------ src/irdevices/airpurifiers.ts | 6 +++--- src/irdevices/cameras.ts | 2 +- src/irdevices/fans.ts | 6 +++--- src/irdevices/lights.ts | 2 +- src/irdevices/others.ts | 4 ++-- src/irdevices/tvs.ts | 4 ++-- src/irdevices/vacuumcleaners.ts | 2 +- src/irdevices/waterheaters.ts | 2 +- 17 files changed, 51 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a44119b..dfa2c823 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/) +## [Version 1.2.4](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v1.2.4) (2021-11-24) + +## What's Changed +* Fixed Bug: Cannot read properties of undefined (reading 'updateCharacteristic'). + +**Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v1.2.3...v1.2.4 + ## [Version 1.2.3](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v1.2.3) (2021-11-24) ## What's Changed diff --git a/package-lock.json b/package-lock.json index 78dbc12d..6e338dcc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@switchbot/homebridge-switchbot", - "version": "1.2.3", + "version": "1.2.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@switchbot/homebridge-switchbot", - "version": "1.2.3", + "version": "1.2.4", "funding": [ { "type": "Paypal", diff --git a/package.json b/package.json index a83e6daf..285fb039 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "displayName": "Homebridge SwitchBot", "name": "@switchbot/homebridge-switchbot", - "version": "1.2.3", + "version": "1.2.4", "description": "The [Homebridge](https://homebridge.io) SwitchBot plugin allows you to access your [SwitchBot](https://www.switch-bot.com) device(s) from HomeKit.", "author": "SwitchBot (https://github.com/SwitchBot)", "license": "ISC", diff --git a/src/devices/bots.ts b/src/devices/bots.ts index d31bb728..1478c78d 100644 --- a/src/devices/bots.ts +++ b/src/devices/bots.ts @@ -75,7 +75,7 @@ export class Bot { if (device.bot?.deviceType === 'switch') { // If outletService still pressent, then remove first if (this.outletService) { - this.platform.device(`Bot: ${this.accessory.displayName} Removing Leftover outletService first`); + this.platform.device(`Bot: ${accessory.displayName} Removing Leftover outletService first`); } this.outletService = this.accessory.getService(this.platform.Service.Outlet); accessory.removeService(this.outletService!); @@ -84,13 +84,13 @@ export class Bot { (this.switchService = accessory.getService(this.platform.Service.Switch) || accessory.addService(this.platform.Service.Switch)), `${accessory.displayName} Switch`; - this.platform.log.info(`Bot: ${this.accessory.displayName} Displaying as Switch`); + this.platform.log.info(`Bot: ${accessory.displayName} Displaying as Switch`); this.switchService?.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName); } else { // If switchService still pressent, then remove first if (this.switchService) { - this.platform.device(`Bot: ${this.accessory.displayName} Removing Leftover switchService first`); + this.platform.device(`Bot: ${accessory.displayName} Removing Leftover switchService first`); } this.switchService = this.accessory.getService(this.platform.Service.Switch); accessory.removeService(this.switchService!); @@ -99,7 +99,7 @@ export class Bot { (this.outletService = accessory.getService(this.platform.Service.Outlet) || accessory.addService(this.platform.Service.Outlet)), `${accessory.displayName} Outlet`; - this.platform.log.info(`Bot: ${this.accessory.displayName} Displaying as Outlet`); + this.platform.log.info(`Bot: ${accessory.displayName} Displaying as Outlet`); this.outletService?.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName); } @@ -444,9 +444,9 @@ export class Bot { this.platform.debug(`Bot: ${this.accessory.displayName} On: ${this.On}`); } else { if (this.device.bot?.deviceType === 'switch') { - this.switchService!.updateCharacteristic(this.platform.Characteristic.On, this.On); + this.switchService?.updateCharacteristic(this.platform.Characteristic.On, this.On); } else { - this.outletService!.updateCharacteristic(this.platform.Characteristic.On, this.On); + this.outletService?.updateCharacteristic(this.platform.Characteristic.On, this.On); } this.platform.device(`Bot: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`); } @@ -468,9 +468,9 @@ export class Bot { public apiError(e: any) { if (this.device.bot?.deviceType === 'switch') { - this.switchService!.updateCharacteristic(this.platform.Characteristic.On, e); + this.switchService?.updateCharacteristic(this.platform.Characteristic.On, e); } else { - this.outletService!.updateCharacteristic(this.platform.Characteristic.On, e); + this.outletService?.updateCharacteristic(this.platform.Characteristic.On, e); } if (this.device.ble) { this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e); diff --git a/src/devices/contact.ts b/src/devices/contact.ts index 09e002ec..0b8a3746 100644 --- a/src/devices/contact.ts +++ b/src/devices/contact.ts @@ -89,7 +89,7 @@ export class Contact { // see https://developers.homebridge.io/#/service/MotionSensor // Motion Sensor Service - if (this.device.contact?.hide_motionsensor) { + if (device.contact?.hide_motionsensor) { this.platform.device(`Contact Sensor: ${accessory.displayName} Removing Motion Sensor Service`); this.motionService = this.accessory.getService(this.platform.Service.MotionSensor); accessory.removeService(this.motionService!); @@ -106,7 +106,7 @@ export class Contact { } // Light Sensor Service - if (this.device.contact?.hide_lightsensor) { + if (device.contact?.hide_lightsensor) { this.platform.device(`Contact Sensor: ${accessory.displayName} Removing Light Sensor Service`); this.lightSensorService = this.accessory.getService(this.platform.Service.LightSensor); accessory.removeService(this.lightSensorService!); @@ -328,7 +328,7 @@ export class Contact { if (this.MotionDetected === undefined) { this.platform.debug(`Contact Sensor: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`); } else { - this.motionService!.updateCharacteristic(this.platform.Characteristic.MotionDetected, this.MotionDetected); + this.motionService?.updateCharacteristic(this.platform.Characteristic.MotionDetected, this.MotionDetected); this.platform.device(`Contact Sensor: ${this.accessory.displayName} updateCharacteristic MotionDetected: ${this.MotionDetected}`); } } @@ -336,7 +336,7 @@ export class Contact { if (this.CurrentAmbientLightLevel === undefined) { this.platform.debug(`Contact Sensor: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`); } else { - this.lightSensorService!.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.CurrentAmbientLightLevel); + this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.CurrentAmbientLightLevel); this.platform.device(`Contact Sensor: ${this.accessory.displayName}` + ` updateCharacteristic CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`); } @@ -360,10 +360,10 @@ export class Contact { public apiError(e: any) { this.service.updateCharacteristic(this.platform.Characteristic.ContactSensorState, e); if (!this.device.contact?.hide_motionsensor) { - this.motionService!.updateCharacteristic(this.platform.Characteristic.MotionDetected, e); + this.motionService?.updateCharacteristic(this.platform.Characteristic.MotionDetected, e); } if (!this.device.contact?.hide_lightsensor) { - this.lightSensorService!.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e); + this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e); } if (this.device.ble) { this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e); diff --git a/src/devices/curtains.ts b/src/devices/curtains.ts index 552fb6cd..ed2b87e9 100644 --- a/src/devices/curtains.ts +++ b/src/devices/curtains.ts @@ -123,7 +123,7 @@ export class Curtain { .onSet(this.TargetPositionSet.bind(this)); // Light Sensor Service - if (this.device.curtain?.hide_lightsensor) { + if (device.curtain?.hide_lightsensor) { this.platform.device(`Curtain: ${accessory.displayName} Removing Light Sensor Service`); this.lightSensorService = this.accessory.getService(this.platform.Service.LightSensor); accessory.removeService(this.lightSensorService!); @@ -573,7 +573,7 @@ export class Curtain { if (this.CurrentAmbientLightLevel === undefined || Number.isNaN(this.CurrentAmbientLightLevel)) { this.platform.debug(`Curtain: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`); } else { - this.lightSensorService!.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.CurrentAmbientLightLevel); + this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.CurrentAmbientLightLevel); this.platform.device(`Curtain: ${this.accessory.displayName}` + ` updateCharacteristic CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`); } @@ -599,11 +599,11 @@ export class Curtain { this.service.updateCharacteristic(this.platform.Characteristic.PositionState, e); this.service.updateCharacteristic(this.platform.Characteristic.TargetPosition, e); if (!this.device.curtain?.hide_lightsensor) { - this.lightSensorService!.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e); + this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e); } if (this.device.ble) { - this.batteryService!.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e); - this.batteryService!.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e); + this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e); + this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e); } } diff --git a/src/devices/humidifiers.ts b/src/devices/humidifiers.ts index dd894f1e..62c53359 100644 --- a/src/devices/humidifiers.ts +++ b/src/devices/humidifiers.ts @@ -595,7 +595,7 @@ export class Humidifier { if (this.CurrentTemperature === undefined) { this.platform.debug(`Humidifier: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`); } else { - this.temperatureservice!.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature); + this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature); this.platform.device(`Humidifier: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`); } } @@ -611,7 +611,7 @@ export class Humidifier { this.service.updateCharacteristic(this.platform.Characteristic.Active, e); this.service.updateCharacteristic(this.platform.Characteristic.RelativeHumidityHumidifierThreshold, e); if (!this.device.humidifier?.hide_temperature && !this.device.ble) { - this.temperatureservice!.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e); + this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e); } } diff --git a/src/devices/plugs.ts b/src/devices/plugs.ts index 5a1876c6..316018e2 100644 --- a/src/devices/plugs.ts +++ b/src/devices/plugs.ts @@ -12,7 +12,6 @@ export class Plug { // Characteristic Values On!: CharacteristicValue; - OutletInUse!: CharacteristicValue; // OpenAPI Others deviceStatus!: deviceStatusResponse; @@ -32,7 +31,6 @@ export class Plug { ) { // default placeholders this.On = false; - this.OutletInUse = true; // this is subject we use to track when we need to POST changes to the SwitchBot API this.doPlugUpdate = new Subject(); @@ -68,8 +66,6 @@ export class Plug { // create handlers for required characteristics this.service.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this)); - this.service.setCharacteristic(this.platform.Characteristic.OutletInUse, this.OutletInUse || true); - // Update Homekit this.updateHomeKitCharacteristics(); @@ -173,17 +169,10 @@ export class Plug { this.service.updateCharacteristic(this.platform.Characteristic.On, this.On); this.platform.device(`Plug: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`); } - if (this.OutletInUse === undefined) { - this.platform.debug(`Plug: ${this.accessory.displayName} OutletInUse: ${this.OutletInUse}`); - } else { - this.service.updateCharacteristic(this.platform.Characteristic.OutletInUse, this.OutletInUse); - this.platform.device(`Plug: ${this.accessory.displayName} updateCharacteristic OutletInUse: ${this.OutletInUse}`); - } } public apiError(e: any) { this.service.updateCharacteristic(this.platform.Characteristic.On, e); - this.service.updateCharacteristic(this.platform.Characteristic.OutletInUse, e); } private statusCode(push: AxiosResponse<{ statusCode: number; }>) { diff --git a/src/irdevices/airconditioners.ts b/src/irdevices/airconditioners.ts index aa4d1e6a..059d7bfc 100644 --- a/src/irdevices/airconditioners.ts +++ b/src/irdevices/airconditioners.ts @@ -168,39 +168,39 @@ export class AirConditioner { if (this.Active === undefined) { this.platform.debug(`Air Conditioner: ${this.accessory.displayName} Active: ${this.Active}`); } else { - this.service!.updateCharacteristic(this.platform.Characteristic.Active, this.Active); + this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active); this.platform.device(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`); } if (this.RotationSpeed === undefined) { this.platform.debug(`Air Conditioner: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`); } else { - this.service!.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed); + this.service?.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed); this.platform.device(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`); } if (this.CurrentTemperature === undefined) { this.platform.debug(`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`); } else { - this.service!.updateCharacteristic(this.platform.Characteristic.Active, this.CurrentTemperature); + this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.CurrentTemperature); this.platform.device(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`); } if (this.TargetHeaterCoolerState === undefined) { this.platform.debug(`Air Conditioner: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`); } else { - this.service!.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.TargetHeaterCoolerState); + this.service?.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.TargetHeaterCoolerState); this.platform.device(`Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`); } if (this.CurrentHeaterCoolerState === undefined) { this.platform.debug(`Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`); } else { - this.service!.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState); + this.service?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState); this.platform.device(`Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`); } if (this.HeatingThresholdTemperature === undefined) { this.platform.debug(`Air Conditioner: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`); } else { - this.service!.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.HeatingThresholdTemperature); + this.service?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.HeatingThresholdTemperature); this.platform.device(`Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`); } diff --git a/src/irdevices/airpurifiers.ts b/src/irdevices/airpurifiers.ts index 92c2c5d6..f8de4877 100644 --- a/src/irdevices/airpurifiers.ts +++ b/src/irdevices/airpurifiers.ts @@ -87,20 +87,20 @@ export class AirPurifier { if (this.Active === undefined) { this.platform.debug(`Air Purifier: ${this.accessory.displayName} Active: ${this.Active}`); } else { - this.service!.updateCharacteristic(this.platform.Characteristic.Active, this.Active); + this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active); this.platform.device(`Air Purifier: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`); } if (this.CurrentAirPurifierState === undefined) { this.platform.debug(`Air Purifier: ${this.accessory.displayName} CurrentAirPurifierState: ${this.CurrentAirPurifierState}`); } else { - this.service!.updateCharacteristic(this.platform.Characteristic.CurrentAirPurifierState, this.CurrentAirPurifierState); + this.service?.updateCharacteristic(this.platform.Characteristic.CurrentAirPurifierState, this.CurrentAirPurifierState); this.platform.device(`Air Purifier: ${this.accessory.displayName}` + ` updateCharacteristic CurrentAirPurifierState: ${this.CurrentAirPurifierState}`); } if (this.CurrentHeaterCoolerState === undefined) { this.platform.debug(`Air Purifier: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`); } else { - this.service!.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState); + this.service?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState); this.platform.device(`Air Purifier: ${this.accessory.displayName}` + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`); } diff --git a/src/irdevices/cameras.ts b/src/irdevices/cameras.ts index fe2e79bd..31d45afa 100644 --- a/src/irdevices/cameras.ts +++ b/src/irdevices/cameras.ts @@ -63,7 +63,7 @@ export class Camera { if (this.On === undefined) { this.platform.debug(`Camera: ${this.accessory.displayName} On: ${this.On}`); } else { - this.service!.updateCharacteristic(this.platform.Characteristic.On, this.On); + this.service?.updateCharacteristic(this.platform.Characteristic.On, this.On); this.platform.device(`Camera: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`); } } diff --git a/src/irdevices/fans.ts b/src/irdevices/fans.ts index 88060613..9d426953 100644 --- a/src/irdevices/fans.ts +++ b/src/irdevices/fans.ts @@ -126,19 +126,19 @@ export class Fan { if (this.Active === undefined) { this.platform.debug(`Fan: ${this.accessory.displayName} Active: ${this.Active}`); } else { - this.service!.updateCharacteristic(this.platform.Characteristic.Active, this.Active); + this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active); this.platform.device(`Fan: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`); } if (this.SwingMode === undefined) { this.platform.debug(`Fan: ${this.accessory.displayName} SwingMode: ${this.SwingMode}`); } else { - this.service!.updateCharacteristic(this.platform.Characteristic.SwingMode, this.SwingMode); + this.service?.updateCharacteristic(this.platform.Characteristic.SwingMode, this.SwingMode); this.platform.device(`Fan: ${this.accessory.displayName} updateCharacteristic SwingMode: ${this.SwingMode}`); } if (this.RotationSpeed === undefined) { this.platform.debug(`Fan: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`); } else { - this.service!.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed); + this.service?.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed); this.platform.device(`Fan: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`); } } diff --git a/src/irdevices/lights.ts b/src/irdevices/lights.ts index 7d1f060b..77069135 100644 --- a/src/irdevices/lights.ts +++ b/src/irdevices/lights.ts @@ -78,7 +78,7 @@ export class Light { if (this.On === undefined) { this.platform.debug(`Light: ${this.accessory.displayName} On: ${this.On}`); } else { - this.service!.updateCharacteristic(this.platform.Characteristic.On, this.On); + this.service?.updateCharacteristic(this.platform.Characteristic.On, this.On); this.platform.device(`Light: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`); } } diff --git a/src/irdevices/others.ts b/src/irdevices/others.ts index 5d08038b..2dd51f04 100644 --- a/src/irdevices/others.ts +++ b/src/irdevices/others.ts @@ -60,7 +60,7 @@ export class Others { if (this.Active === undefined) { this.platform.debug(`Other: ${this.accessory.displayName} Active: ${this.Active}`); } else { - this.service!.updateCharacteristic(this.platform.Characteristic.Active, this.Active); + this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active); this.platform.device(`Other: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`); } } @@ -175,6 +175,6 @@ export class Others { } public apiError(e: any) { - this.service!.updateCharacteristic(this.platform.Characteristic.Active, e); + this.service?.updateCharacteristic(this.platform.Characteristic.Active, e); } } diff --git a/src/irdevices/tvs.ts b/src/irdevices/tvs.ts index 43c4d96f..ef5756ea 100644 --- a/src/irdevices/tvs.ts +++ b/src/irdevices/tvs.ts @@ -214,13 +214,13 @@ export class TV { if (this.Active === undefined) { this.platform.debug(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`); } else { - this.service!.updateCharacteristic(this.platform.Characteristic.Active, this.Active); + this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active); this.platform.device(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`); } if (this.ActiveIdentifier === undefined) { this.platform.debug(`${this.device.remoteType}: ${this.accessory.displayName} ActiveIdentifier: ${this.ActiveIdentifier}`); } else { - this.service!.updateCharacteristic(this.platform.Characteristic.ActiveIdentifier, this.ActiveIdentifier); + this.service?.updateCharacteristic(this.platform.Characteristic.ActiveIdentifier, this.ActiveIdentifier); this.platform.device(`${this.device.remoteType}: ${this.accessory.displayName}` + ` updateCharacteristic ActiveIdentifier: ${this.ActiveIdentifier}`); } diff --git a/src/irdevices/vacuumcleaners.ts b/src/irdevices/vacuumcleaners.ts index a7940eae..b2977ed5 100644 --- a/src/irdevices/vacuumcleaners.ts +++ b/src/irdevices/vacuumcleaners.ts @@ -63,7 +63,7 @@ export class VacuumCleaner { if (this.On === undefined) { this.platform.debug(`Vacuum Cleaner: ${this.accessory.displayName} On: ${this.On}`); } else { - this.service!.updateCharacteristic(this.platform.Characteristic.On, this.On); + this.service?.updateCharacteristic(this.platform.Characteristic.On, this.On); this.platform.device(`Vacuum Cleaner: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`); } } diff --git a/src/irdevices/waterheaters.ts b/src/irdevices/waterheaters.ts index f07d4d30..7f435554 100644 --- a/src/irdevices/waterheaters.ts +++ b/src/irdevices/waterheaters.ts @@ -77,7 +77,7 @@ export class WaterHeater { if (this.Active === undefined) { this.platform.debug(`Water Heater: ${this.accessory.displayName} Active: ${this.Active}`); } else { - this.service!.updateCharacteristic(this.platform.Characteristic.Active, this.Active); + this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active); this.platform.device(`Water Heater: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`); } }