Skip to content

Commit

Permalink
Fix #175
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasloven committed Mar 13, 2021
1 parent f7f63ec commit 3865b00
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion slider-entity-row.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 6 additions & 11 deletions src/controllers/fan-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@ import { Controller } from "./controller";

export class FanController extends Controller {
_min;
_max;

get _value() {
return this.stateObj.state !== "off"
? this.stateObj.attributes.speed_list.indexOf(
this.stateObj.attributes.speed
)
? this.stateObj.attributes.percentage
: 0;
}

set _value(value) {
if (value in this.stateObj.attributes.speed_list) {
this._hass.callService("fan", "turn_on", {
if (value > 0) {
this._hass.callService("fan", "set_percentage", {
entity_id: this.stateObj.entity_id,
speed: this.stateObj.attributes.speed_list[value],
percentage: value,
});
} else {
this._hass.callService("fan", "turn_off", {
Expand All @@ -35,11 +34,7 @@ export class FanController extends Controller {
return false;
}

get _max() {
return this.stateObj.attributes.speed_list.length - 1;
}

get _step() {
return 1;
return this.stateObj.attributes.percentage_step;
}
}

0 comments on commit 3865b00

Please sign in to comment.