From 131f606704fd2a86ea024a307e5d787d75da185d Mon Sep 17 00:00:00 2001 From: Marc Sowen Date: Sat, 13 Mar 2021 20:13:50 +0100 Subject: [PATCH] Prevent warning messages about missing characteristics. --- CHANGELOG.md | 6 ++++++ package.json | 2 +- src/devices/HmIPContactSensor.ts | 8 +++----- src/devices/HmIPGenericDevice.ts | 10 ++++------ src/settings.ts | 2 +- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be36bbc..64070aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.3.4 (2021-03-13) + +### Bugfix + +- **General**: Prevent warning messages about missing characteristics. + ## 0.3.3 (2021-03-13) ### Improvements diff --git a/package.json b/package.json index c18388e..fc6415b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-homematicip", - "version": "0.3.3", + "version": "0.3.4", "description": "Homematic IP plugin for homebridge", "license": "Apache-2.0", "author": "Marc Sowen ", diff --git a/src/devices/HmIPContactSensor.ts b/src/devices/HmIPContactSensor.ts index 795c493..bc842f2 100644 --- a/src/devices/HmIPContactSensor.ts +++ b/src/devices/HmIPContactSensor.ts @@ -1,4 +1,4 @@ -import {CharacteristicGetCallback, CharacteristicSetCallback, CharacteristicValue, PlatformAccessory, Service} from 'homebridge'; +import {CharacteristicGetCallback, PlatformAccessory, Service} from 'homebridge'; import {HmIPPlatform} from '../HmIPPlatform'; import {HmIPDevice, HmIPGroup, Updateable} from '../HmIPState'; @@ -51,11 +51,9 @@ export class HmIPContactSensor extends HmIPGenericDevice implements Updateable { this.service.getCharacteristic(this.platform.Characteristic.ContactSensorState) .on('get', this.handleContactSensorStateGet.bind(this)); - const doorCharacteristics = this.service.getCharacteristic(this.platform.Characteristic.CurrentDoorState); - - if (doorCharacteristics != undefined) { + if (this.service.testCharacteristic(this.platform.Characteristic.CurrentDoorState)) { this.platform.log.info("Removing obsolete current door state characteristic from %s", accessory.context.device.label); - this.service.removeCharacteristic(doorCharacteristics); + this.service.removeCharacteristic(this.service.getCharacteristic(this.platform.Characteristic.CurrentDoorState)); } this.updateDevice(accessory.context.device, platform.groups); diff --git a/src/devices/HmIPGenericDevice.ts b/src/devices/HmIPGenericDevice.ts index c921f30..9097207 100644 --- a/src/devices/HmIPGenericDevice.ts +++ b/src/devices/HmIPGenericDevice.ts @@ -79,16 +79,14 @@ export abstract class HmIPGenericDevice { this.batteryService.getCharacteristic(this.platform.Characteristic.StatusLowBattery) .on('get', this.handleStatusLowBatteryGet.bind(this)); - const batteryLevel = this.batteryService.getCharacteristic(this.platform.Characteristic.BatteryLevel); - if (batteryLevel != undefined) { + if (this.batteryService.testCharacteristic(this.platform.Characteristic.BatteryLevel)) { this.platform.log.info("Removing obsolete battery level characteristic from %s", accessory.context.device.label); - this.batteryService.removeCharacteristic(batteryLevel); + this.batteryService.removeCharacteristic(this.batteryService.getCharacteristic(this.platform.Characteristic.BatteryLevel)); } - const chargingState = this.batteryService.getCharacteristic(this.platform.Characteristic.ChargingState); - if (chargingState != undefined) { + if (this.batteryService.testCharacteristic(this.platform.Characteristic.ChargingState)) { this.platform.log.info("Removing obsolete charging state characteristic from %s", accessory.context.device.label); - this.batteryService.removeCharacteristic(chargingState); + this.batteryService.removeCharacteristic(this.batteryService.getCharacteristic(this.platform.Characteristic.ChargingState)); } } else { const batteryService = this.accessory.getService(this.platform.Service.Battery); diff --git a/src/settings.ts b/src/settings.ts index 2cb7c0d..97ab8dc 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -11,4 +11,4 @@ export const PLUGIN_NAME = 'homebridge-homematicip'; /** * Version to be used in protocol communication */ -export const PLUGIN_VERSION = '0.3.3'; +export const PLUGIN_VERSION = '0.3.4';