Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly handle single speed fans #6

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/controllers/fan-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class FanController extends Controller {
}

get _step(): number {
return this.stateObj.attributes.percentage_step;
return this.hasSlider ? this.stateObj.attributes.percentage_step : 1;
}

get label(): string {
Expand All @@ -53,9 +53,14 @@ export class FanController extends Controller {

get iconRotateSpeed(): string {
let speed = 0;
if (this.percentage > 0) {
speed = 3 - ((this.percentage / 100) * 2);
if (this.hasSlider) {
if (this.percentage > 0) {
speed = 3 - ((this.percentage / 100) * 2);
}
} else {
speed = this._value
}

return `${speed}s`
}

Expand Down