From 0b01fe6ddb620dd5c9d1b7df691bb4883a345ea6 Mon Sep 17 00:00:00 2001 From: Ian Craig Date: Sun, 24 Jul 2022 10:44:22 +1000 Subject: [PATCH 1/2] Remove action handler which was conflicting with tap handling --- src/xiaomi-fan-card.ts | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/xiaomi-fan-card.ts b/src/xiaomi-fan-card.ts index 204a15b..c205c0b 100644 --- a/src/xiaomi-fan-card.ts +++ b/src/xiaomi-fan-card.ts @@ -479,8 +479,7 @@ export class FanXiaomiCard extends LitElement { return html` @@ -591,10 +590,13 @@ export class FanXiaomiCard extends LitElement { Speed down ` - : html`
+ : html`
@@ -644,9 +646,9 @@ export class FanXiaomiCard extends LitElement {
`; } - private handleAction(ev: ActionHandlerEvent): void { - if (this.hass && this.config && ev.detail.action) { - handleAction(this, this.hass, this.config, ev.detail.action); + private onCardTitleClick(): void { + if (this.hass && this.config) { + handleAction(this, this.hass, this.config, "click"); } } @@ -682,8 +684,14 @@ export class FanXiaomiCard extends LitElement { private toggleSpeedLevel(): void { const currentLevel = this.getSpeedLevel(); - const newLevel = currentLevel >= this.supportedAttributes.speedLevels ? - (this.config.disable_animation ? (this.hass.states[this.config.entity].state === 'off' ? 1 : 0) : 1) : currentLevel + 1; + const newLevel = + currentLevel >= this.supportedAttributes.speedLevels + ? this.config.disable_animation + ? this.hass.states[this.config.entity].state === "off" + ? 1 + : 0 + : 1 + : currentLevel + 1; const newPercentage = (newLevel / this.supportedAttributes.speedLevels) * 100; this.hass.callService("fan", "set_percentage", { From cd42744711f02fbc81174d8e278ece331567f539 Mon Sep 17 00:00:00 2001 From: Ian Craig Date: Sun, 24 Jul 2022 10:52:08 +1000 Subject: [PATCH 2/2] Removing unused imports --- src/xiaomi-fan-card.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/xiaomi-fan-card.ts b/src/xiaomi-fan-card.ts index c205c0b..0912f0f 100644 --- a/src/xiaomi-fan-card.ts +++ b/src/xiaomi-fan-card.ts @@ -1,15 +1,8 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { LitElement, html, TemplateResult, css, PropertyValues, CSSResultGroup, HTMLTemplateResult } from "lit"; import { customElement, property, state } from "lit/decorators"; -import { - HomeAssistant, - hasConfigOrEntityChanged, - ActionHandlerEvent, - handleAction, - LovelaceCardEditor, -} from "custom-card-helpers"; // This is a community maintained npm module with common helper functions/types. https://github.com/custom-cards/custom-card-helpers - -import { actionHandler } from "./action-handler-directive"; +import { HomeAssistant, hasConfigOrEntityChanged, handleAction, LovelaceCardEditor } from "custom-card-helpers"; // This is a community maintained npm module with common helper functions/types. https://github.com/custom-cards/custom-card-helpers + import { FanXiaomiCardConfig, defaultConfig } from "./config"; // Add the card to the UI card picker dialog