Skip to content

Commit

Permalink
Removed obsolete battery services and characteristics.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Sowen committed Mar 13, 2021
1 parent 337b18c commit 9be9e9c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 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.3 (2021-03-13)

### Improvements

- **General**: Removed obsolete battery services and characteristics.

## 0.3.2 (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.2",
"version": "0.3.3",
"description": "Homematic IP plugin for homebridge",
"license": "Apache-2.0",
"author": "Marc Sowen <[email protected]>",
Expand Down
18 changes: 18 additions & 0 deletions src/devices/HmIPGenericDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@ export abstract class HmIPGenericDevice {
this.batteryService = this.accessory.getService(this.platform.Service.Battery) || this.accessory.addService(this.platform.Service.Battery)!;
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) {
this.platform.log.info("Removing obsolete battery level characteristic from %s", accessory.context.device.label);
this.batteryService.removeCharacteristic(batteryLevel);
}

const chargingState = this.batteryService.getCharacteristic(this.platform.Characteristic.ChargingState);
if (chargingState != undefined) {
this.platform.log.info("Removing obsolete charging state characteristic from %s", accessory.context.device.label);
this.batteryService.removeCharacteristic(chargingState);
}
} else {
const batteryService = this.accessory.getService(this.platform.Service.Battery);
if (batteryService != undefined) {
this.platform.log.info("Removing obsolete battery service from %s", accessory.context.device.label);
this.accessory.removeService(batteryService);
}
}
}

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.2';
export const PLUGIN_VERSION = '0.3.3';

0 comments on commit 9be9e9c

Please sign in to comment.