@@ -711,26 +678,15 @@ export class FanXiaomiCard extends LitElement {
* the fan when animations/fanbox is disabled.
*/
private toggleSpeedLevel(): void {
- const speedLevel = this.getSpeedLevel();
+ const currentLevel = this.getSpeedLevel();
- let newSpeed: string | 0;
- if (this.config.use_standard_speeds || this.config.platform === "default") {
- newSpeed =
- speedLevel >= this.supportedAttributes.speedList.length ? 0 : this.supportedAttributes.speedList[speedLevel];
- } else {
- newSpeed = speedLevel >= this.supportedAttributes.speedLevels ? 0 : `Level ${speedLevel + 1}`;
- }
+ const newLevel = currentLevel >= this.supportedAttributes.speedLevels ? 0 : currentLevel + 1;
+ const newPercentage = (newLevel / this.supportedAttributes.speedLevels) * 100;
- if (newSpeed === 0) {
- this.hass.callService("fan", "turn_off", {
- entity_id: this.config.entity,
- });
- } else {
- this.hass.callService("fan", "set_speed", {
- entity_id: this.config.entity,
- speed: newSpeed,
- });
- }
+ this.hass.callService("fan", "set_percentage", {
+ entity_id: this.config.entity,
+ percentage: newPercentage,
+ });
}
private increaseSpeed() {