-
-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy patheditor.js
123 lines (116 loc) · 5.52 KB
/
editor.js
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
import { html } from "lit";
export function renderClimateEditor(editor){
if (
editor._config.card_type === "climate" &&
!editor.climateSubButtonsAdded &&
editor._config.entity
) {
const shouldAddHVACModes = editor.hass.states[editor._config.entity]?.attributes?.hvac_modes;
if (!editor._config.sub_button || editor._config.sub_button.length === 0) {
editor._config.sub_button = [
shouldAddHVACModes ? {
name: 'HVAC modes menu',
select_attribute: 'hvac_modes',
state_background: false,
show_arrow: false
} : null
].filter(Boolean);
}
editor.climateSubButtonsAdded = true;
}
return html`
<div class="card-config">
${editor.makeDropdown("Card type", "card_type", editor.cardTypeList)}
<ha-form
.hass=${editor.hass}
.data=${editor._config}
.schema=${[
{ name: "entity",
label: "Entity",
selector: { entity: {domain:["climate"]} },
},
]}
.computeLabel=${editor._computeLabelCallback}
@value-changed=${editor._valueChanged}
></ha-form>
<ha-expansion-panel outlined>
<h4 slot="header">
<ha-icon icon="mdi:cog"></ha-icon>
Climate settings
</h4>
<div class="content">
<ha-textfield
label="Optional - Name"
.value="${editor._config?.name || ''}"
.configValue="${"name"}"
@input="${editor._valueChanged}"
></ha-textfield>
${editor.makeDropdown("Optional - Icon", "icon")}
${editor.makeShowState()}
${editor.hass.states[editor._config.entity]?.attributes?.target_temp_low ? html`
<ha-formfield .label="Optional - Hide target temp low">
<ha-switch
aria-label="Optional - Hide target temp low"
.checked=${editor._config.hide_target_temp_low}
.configValue="${"hide_target_temp_low"}"
@change=${editor._valueChanged}
></ha-switch>
<div class="mdc-form-field">
<label class="mdc-label">Optional - Hide target temp low</label>
</div>
</ha-formfield>
` : ''}
${editor.hass.states[editor._config.entity]?.attributes?.target_temp_high ? html`
<ha-formfield .label="Optional - Hide target temp high">
<ha-switch
aria-label="Optional - Hide target temp high"
.checked=${editor._config.hide_target_temp_high}
.configValue="${"hide_target_temp_high"}"
@change=${editor._valueChanged}
></ha-switch>
<div class="mdc-form-field">
<label class="mdc-label">Optional - Hide target temp high</label>
</div>
</ha-formfield>
` : ''}
<ha-formfield .label="Optional - Constant background color when ON">
<ha-switch
aria-label="Optional - Constant background color when ON"
.checked=${editor._config.state_color === true}
.configValue="${"state_color"}"
@change=${editor._valueChanged}
></ha-switch>
<div class="mdc-form-field">
<label class="mdc-label">Optional - Constant background color when ON</label>
</div>
</ha-formfield>
</div>
</ha-expansion-panel>
<ha-expansion-panel outlined>
<h4 slot="header">
<ha-icon icon="mdi:gesture-tap"></ha-icon>
Tap action on icon
</h4>
<div class="content">
${editor.makeActionPanel("Tap action")}
${editor.makeActionPanel("Double tap action")}
${editor.makeActionPanel("Hold action")}
</div>
</ha-expansion-panel>
<ha-expansion-panel outlined>
<h4 slot="header">
<ha-icon icon="mdi:palette"></ha-icon>
Styling options
</h4>
<div class="content">
${editor.makeLayoutOptions()}
${editor.makeStyleEditor()}
</div>
</ha-expansion-panel>
${editor.makeSubButtonPanel()}
${editor.makeModulesEditor()}
<ha-alert alert-type="info">This card allows you to control your climate entities. You can also add a sub-button that display a select menu for your climate modes (check if you have "Select menu" available when you create a new sub-button).</ha-alert>
${editor.makeVersion()}
</div>
`;
}