Skip to content

Commit

Permalink
Prevent warning messages about missing characteristics.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Sowen committed Mar 13, 2021
1 parent 9be9e9c commit 131f606
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
Expand Down
8 changes: 3 additions & 5 deletions src/devices/HmIPContactSensor.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 4 additions & 6 deletions src/devices/HmIPGenericDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

0 comments on commit 131f606

Please sign in to comment.