Skip to content

Commit

Permalink
Fix: Made method async to fix promise warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Okonetchnikov authored and okonet committed Jan 4, 2020
1 parent 8fbf288 commit d9fe7dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions bulbs/bulb.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class YeeBulb {
.updateValue(this.power);
}

setPower(power) {
async setPower(power) {
if (this.power === power) {
return Promise.resolve(power);
}
Expand All @@ -97,9 +97,8 @@ class YeeBulb {
method: 'set_power',
params: [state, 'smooth', transition],
};
return this.sendCmd(req).then(() => {
this._power = power;
});
await this.sendCmd(req);
this._power = power;
}

connect() {
Expand Down
4 changes: 2 additions & 2 deletions bulbs/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ const Color = Device => {
super.updateStateFromProp(prop, value);
}

setColor(hv, sv) {
async setColor(hv, sv) {
hue = isInteger(hue) ? hue : hv;
sat = isInteger(sat) ? sat : sv;
if (!isInteger(hue) || !isInteger(sat)) return Promise.resolve();

const { color: transition = 1500 } = this.config.transitions || {};
this.setPower(1);
await this.setPower(1); // TODO: Why do we need to switch on the lamp here?
const req = {
method: 'set_hsv',
params: [hue, sat, 'smooth', transition],
Expand Down

0 comments on commit d9fe7dc

Please sign in to comment.