-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton.ts
More file actions
147 lines (126 loc) · 3.2 KB
/
Copy pathbutton.ts
File metadata and controls
147 lines (126 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/**
* The button card allows you to add buttons to perform tasks.
*
* For more information, see [button card documentation](https://www.home-assistant.io/lovelace/button/).
*
* @example
* ```
* // Basic example:
* type: button
* entity: light.living_room
*
* // Button card with a button name and a script that runs when card is tapped:
* type: button
* name: Turn Off Lights
* show_state: false
* tap_action:
* action: call-service
* service: script.turn_on
* data:
* entity_id: script.turn_off_lights
* ```
*
* 
*/
export type ButtonCardConfig = {
/**
* The entity ID the card interacts with, for example, light.living_room.
*/
entity?: string;
/**
* The button name that is displayed on the card. It defaults to the entity name only if the card interacts with an entity.
* Otherwise, if not configured, no name is displayed.
*/
name?: string;
/**
* The icon that is displayed on the card. It defaults to the entity domain icon only if the card interacts with an entity.
* Otherwise, if not configured, no icon is displayed.
*/
icon?: string;
/**
* If false, the button name is not shown on the card.
*/
show_name?: boolean;
/**
* If false, the icon is not shown on the card.
*/
show_icon?: boolean;
/**
* Show state.
*/
show_state?: boolean;
/**
* The height of the icon. Any CSS value may be used.
*/
icon_height?: string;
/**
* If false, the icon does not change color when the entity is active.
*/
state_color?: boolean;
/**
* The action taken on card tap.
*/
tap_action?: ActionConfig;
/**
* The action taken on card tap and hold.
*/
hold_action?: ActionConfig;
/**
* The action taken on card double-tap.
*/
double_tap_action?: ActionConfig;
/**
* Override the used theme for this card with any loaded theme.
*/
theme?: string;
/**
* Override the default action name for a button row.
*/
action_name?: string;
};
/**
* The configuration for actions taken when interacting with the card via tap, hold, or double-tap.
*
* @example
* ```
* action: toggle
* ```
*
* @example
* ```
* action: call-service
* service: script.turn_on
* service_data:
* entity_id: script.turn_off_lights
* ```
*/
export type ActionConfig = {
/**
* The type of action to perform.
*/
action: 'none' | 'more-info' | 'navigate' | 'url' | 'toggle' | 'call-service' | 'fire-dom-event';
/**
* The service to call when `action` is set to `call-service`.
*/
service?: string;
/**
* The service data to include when `action` is set to `call-service`.
*/
service_data?: { [key: string]: any };
/**
* The URL to navigate to when `action` is set to `navigate` or `url`.
*/
url_path?: string;
/**
* The navigation path to navigate to when `action` is set to `navigate`.
*/
navigation_path?: string;
/**
* The additional data to include when `action` is set to `fire-dom-event`.
*/
event?: string;
/**
* The browser device ID to target when `action` is set to `fire-dom-event`.
*/
device_id?: string;
};