Skip to content

Commit

Permalink
default tap_action is toggle for supported entities only
Browse files Browse the repository at this point in the history
  • Loading branch information
RomRider committed Mar 17, 2020
1 parent ce093da commit edb4197
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/button-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
secondsToDuration,
durationToSeconds,
createThing,
DOMAINS_TOGGLE,
} from 'custom-card-helpers';
import { BUTTON_CARD_VERSION } from './version-const';
import {
Expand Down Expand Up @@ -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',
Expand All @@ -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,
Expand Down

0 comments on commit edb4197

Please sign in to comment.