Skip to content

Commit

Permalink
fix(accessory): 🐛 remove spurious sensors
Browse files Browse the repository at this point in the history
make sure we remove spurious temperature sensors for v1 and zero switches

Fixes #562
  • Loading branch information
johannrichard committed Dec 30, 2022
1 parent 7f4d36c commit 054e3c6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/myStromSwitchAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ export class MyStromSwitchAccessory extends DingzDaBaseAccessory {
this.temperatureService
.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
.on(CharacteristicEventTypes.GET, this.getTemperature.bind(this));
} else {
// Make sure spurious temperature services (e.g. from Zero and CH v1) don't remain in the system
const temperatureService: Service | undefined = this.accessory.getService(
this.platform.Service.TemperatureSensor,
);
if (temperatureService !== undefined) {
this.platform.log.warn('Removing spurious temperature service');
this.accessory.removeService(temperatureService);
}
}
}

Expand Down

0 comments on commit 054e3c6

Please # to comment.