Skip to content

Commit

Permalink
fix(accessory): 🐛 additional checks for temperature capability
Browse files Browse the repository at this point in the history
implement additional checks to ensure valid temperature values
fix a bug introduced with implementation of zero switches
improve some debugging related to switch versions

Fixes #562
  • Loading branch information
johannrichard committed Dec 30, 2022
1 parent bc998b4 commit a3b40b7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/myStromSwitchAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ export class MyStromSwitchAccessory extends DingzDaBaseAccessory {
.on(CharacteristicEventTypes.GET, this.getOutletInUse.bind(this)); // GET - bind to the `getOn` method below

// Only EU and CH v2 Switches have temperature sensor
if (this.device.model !== 'Zero' && this.device.model !== undefined) {
if (
this.device.model !== 'Zero' &&
this.device.model !== 'CH v1' &&
this.device.model !== undefined
) {
// Switch has a temperature sensor, make it available here
this.temperatureService =
this.accessory.getService(this.platform.Service.TemperatureSensor) ??
Expand Down Expand Up @@ -134,7 +138,11 @@ export class MyStromSwitchAccessory extends DingzDaBaseAccessory {
break;
}

if (this.temperatureService) {
if (
this.temperatureService &&
this.outletState.temperature !== null &&
this.outletState.temperature !== undefined
) {
this.temperatureService
.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
.updateValue(this.outletState.temperature);
Expand Down

0 comments on commit a3b40b7

Please sign in to comment.