From edb419718abd631b8a3e9b03da5f1b4d0560dac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Wiedemann?= Date: Tue, 17 Mar 2020 14:21:12 +0100 Subject: [PATCH] default tap_action is toggle for supported entities only --- src/button-card.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/button-card.ts b/src/button-card.ts index fd683c8..247fb84 100644 --- a/src/button-card.ts +++ b/src/button-card.ts @@ -22,6 +22,7 @@ import { secondsToDuration, durationToSeconds, createThing, + DOMAINS_TOGGLE, } from 'custom-card-helpers'; import { BUTTON_CARD_VERSION } from './version-const'; import { @@ -855,7 +856,6 @@ class ButtonCard extends LitElement { } template.state = mergedStateConfig; this.config = { - tap_action: { action: 'toggle' }, hold_action: { action: 'none' }, double_tap_action: { action: 'none' }, layout: 'vertical', @@ -870,6 +870,17 @@ class ButtonCard extends LitElement { show_live_stream: false, ...template, }; + if (this.config!.entity && DOMAINS_TOGGLE.has(computeDomain(this.config!.entity))) { + this.config = { + tap_action: { action: 'toggle' }, + ...this.config, + }; + } else { + this.config = { + tap_action: { action: 'more-info' }, + ...this.config, + }; + } this.config.lock = { enabled: false, duration: 5,