Skip to content

Commit

Permalink
fix(dingz): fix variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
johannrichard committed Nov 19, 2020
1 parent 901c051 commit f1fae16
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/dingzAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
WindowCoveringId,
WindowCoveringTimer,
WindowCoveringState,
WindowCoveringPosition,
} from './util/dingzTypes';
import {
ButtonAction,
Expand Down Expand Up @@ -706,11 +707,11 @@ export class DingzDaAccessory extends EventEmitter {
// Sensors
this.dingzStates.Temperature = state.sensors.room_temperature;
this.dingzStates.Brightness = state.sensors.brightness;
this.platform.eb.emit(DingzEvent.STATE_UPDATE);
} else {
this.dingzStates.Reachable = false;
this.platform.log.error('Can`t get device state');
}
this.platform.eb.emit(DingzEvent.STATE_UPDATE);
});
}

Expand Down Expand Up @@ -750,37 +751,29 @@ export class DingzDaAccessory extends EventEmitter {
// Update State
this.platform.eb.on(
DingzEvent.STATE_UPDATE,
this.updateDimmerState.bind(this, index, output, newService, id),
this.updateDimmerState.bind(this, index, output, newService),
);
return newService;
}

private updateDimmerState(
index: number,
output: string | undefined,
newService: Service,
id: string,
service: Service,
) {
if (index !== null) {
// index set
const state = this.dingzStates.Dimmers[index];
// Check that "state" is valid
if (state) {
if (output && output !== 'non_dimmable') {
newService
service
.getCharacteristic(this.platform.Characteristic.Brightness)
.updateValue(state.value);
}
newService
service
.getCharacteristic(this.platform.Characteristic.On)
.updateValue(state.on);
} else {
this.platform.log.warn(
'We have an issue here: state should be non-empty but is undefined.',
'Continue here, not killing myself anymore.',
`For the records, device: ${this.device.address} - id: ${id}, index: ${index} and output is: `,
JSON.stringify(this.dingzStates),
);
}
}
}
Expand Down

0 comments on commit f1fae16

Please sign in to comment.