purifier-card 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +6 -1
- package/README.md +11 -10
- package/dist/purifier-card.js +2 -2
- package/package.json +12 -4
- package/rollup.config.js +46 -31
- package/src/config.ts +26 -0
- package/src/declarations.d.ts +5 -0
- package/src/editor.css +19 -0
- package/src/editor.ts +166 -0
- package/src/{localize.js → localize.ts} +19 -15
- package/src/{purifier-card.js → purifier-card.ts} +138 -152
- package/src/styles.css +2 -1
- package/src/translations/bg.json +4 -4
- package/src/translations/ca.json +4 -4
- package/src/translations/cs.json +4 -7
- package/src/translations/de.json +4 -4
- package/src/translations/en.json +4 -7
- package/src/translations/fr.json +4 -4
- package/src/translations/it.json +4 -4
- package/src/translations/nb.json +4 -4
- package/src/translations/nl.json +4 -7
- package/src/translations/pl.json +5 -5
- package/src/translations/ru.json +4 -4
- package/src/translations/tr.json +4 -4
- package/src/translations/uk.json +4 -4
- package/src/translations/zh-CN.json +4 -4
- package/src/translations/zh-TW.json +4 -4
- package/src/types.ts +65 -0
- package/tsconfig.json +21 -0
- package/src/purifier-card-editor.js +0 -200
package/src/translations/ru.json
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"off": "Выкл."
|
|
11
11
|
},
|
|
12
12
|
"preset_mode": {
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
13
|
+
"auto": "Автоматическая",
|
|
14
|
+
"silent": "Тихая",
|
|
15
|
+
"favorite": "Предпочтительная",
|
|
16
|
+
"fan": "Максимальная"
|
|
17
17
|
},
|
|
18
18
|
"error": {
|
|
19
19
|
"missing_entity": "Требуется указать сущность!"
|
package/src/translations/tr.json
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"off": "Kapalı"
|
|
11
11
|
},
|
|
12
12
|
"preset_mode": {
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
13
|
+
"auto": "Otomatik",
|
|
14
|
+
"silent": "Sessiz",
|
|
15
|
+
"favorite": "Favori",
|
|
16
|
+
"fan": "Fan"
|
|
17
17
|
},
|
|
18
18
|
"error": {
|
|
19
19
|
"missing_entity": "Varlığı belirtmeniz gereklidir!"
|
package/src/translations/uk.json
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"off": "Вимкнений"
|
|
11
11
|
},
|
|
12
12
|
"preset_mode": {
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
13
|
+
"auto": "Авто",
|
|
14
|
+
"silent": "Тихий",
|
|
15
|
+
"favorite": "Улюблений",
|
|
16
|
+
"fan": "Вентилятор"
|
|
17
17
|
},
|
|
18
18
|
"error": {
|
|
19
19
|
"missing_entity": "Сутність є обов’язковим полем!"
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HassEntityAttributeBase,
|
|
3
|
+
HassEntityBase,
|
|
4
|
+
} from 'home-assistant-js-websocket';
|
|
5
|
+
import { TemplateResult, nothing } from 'lit';
|
|
6
|
+
|
|
7
|
+
export * from 'home-assistant-js-websocket';
|
|
8
|
+
|
|
9
|
+
export type TemplateNothing = typeof nothing;
|
|
10
|
+
export type Template = TemplateResult | TemplateNothing;
|
|
11
|
+
|
|
12
|
+
export type PurifierEntityState = 'on' | 'off' | 'unavailable' | 'unknown';
|
|
13
|
+
|
|
14
|
+
export interface PurifierEntityAttributes extends HassEntityAttributeBase {
|
|
15
|
+
preset_mode?: string;
|
|
16
|
+
preset_modes?: string[];
|
|
17
|
+
percentage?: number;
|
|
18
|
+
percentage_step?: number;
|
|
19
|
+
supported_features?: number;
|
|
20
|
+
use_time?: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface PurifierEntity extends HassEntityBase {
|
|
24
|
+
attributes: PurifierEntityAttributes;
|
|
25
|
+
state: PurifierEntityState;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface PurifierAQI {
|
|
29
|
+
entity_id?: string;
|
|
30
|
+
attribute?: string;
|
|
31
|
+
unit?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface PurifierCardStat {
|
|
35
|
+
entity_id?: string;
|
|
36
|
+
attribute?: string;
|
|
37
|
+
value_template?: string;
|
|
38
|
+
unit?: string;
|
|
39
|
+
subtitle?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface PurifierCardShortcut {
|
|
43
|
+
name?: string;
|
|
44
|
+
icon?: string;
|
|
45
|
+
service?: string;
|
|
46
|
+
service_data?: Record<string, unknown>;
|
|
47
|
+
percentage?: number;
|
|
48
|
+
preset_mode?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface PurifierCardConfig {
|
|
52
|
+
entity: string;
|
|
53
|
+
show_name: boolean;
|
|
54
|
+
show_state: boolean;
|
|
55
|
+
show_preset_mode: boolean;
|
|
56
|
+
show_toolbar: boolean;
|
|
57
|
+
compact_view: boolean;
|
|
58
|
+
aqi: PurifierAQI;
|
|
59
|
+
stats: PurifierCardStat[];
|
|
60
|
+
shortcuts: PurifierCardShortcut[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface SliderValue {
|
|
64
|
+
value: number;
|
|
65
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2017",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"lib": ["es2017", "dom", "dom.iterable"],
|
|
7
|
+
"noEmit": true,
|
|
8
|
+
"noUnusedParameters": true,
|
|
9
|
+
"noImplicitReturns": true,
|
|
10
|
+
"noFallthroughCasesInSwitch": true,
|
|
11
|
+
"strict": true,
|
|
12
|
+
"noImplicitAny": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"resolveJsonModule": true,
|
|
15
|
+
"experimentalDecorators": true,
|
|
16
|
+
"allowSyntheticDefaultImports": true,
|
|
17
|
+
"esModuleInterop": true,
|
|
18
|
+
"allowJs": false,
|
|
19
|
+
"typeRoots": ["./node_modules/@types", "./src/declarations.d.ts"]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { LitElement, html, css, nothing } from 'lit';
|
|
2
|
-
import { fireEvent } from 'custom-card-helpers';
|
|
3
|
-
import localize from './localize';
|
|
4
|
-
|
|
5
|
-
export class PurifierCardEditor extends LitElement {
|
|
6
|
-
static get properties() {
|
|
7
|
-
return {
|
|
8
|
-
hass: Object,
|
|
9
|
-
_config: Object,
|
|
10
|
-
_toggle: Boolean,
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
setConfig(config) {
|
|
15
|
-
this._config = config;
|
|
16
|
-
|
|
17
|
-
if (!this._config.entity) {
|
|
18
|
-
this._config.entity = this.getEntitiesByType('fan')[0] || '';
|
|
19
|
-
fireEvent(this, 'config-changed', { config: this._config });
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
get _entity() {
|
|
24
|
-
if (this._config) {
|
|
25
|
-
return this._config.entity || '';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return '';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
get _show_name() {
|
|
32
|
-
if (this._config) {
|
|
33
|
-
return this._config.show_name || true;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return '';
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
get _show_state() {
|
|
40
|
-
if (this._config) {
|
|
41
|
-
return this._config.show_state || true;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return '';
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
get _show_toolbar() {
|
|
48
|
-
if (this._config) {
|
|
49
|
-
return this._config.show_toolbar || true;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
get _compact_view() {
|
|
56
|
-
if (this._config) {
|
|
57
|
-
return this._config.compact_view || false;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
getEntitiesByType(type) {
|
|
64
|
-
return Object.keys(this.hass.states).filter(
|
|
65
|
-
(eid) => eid.substr(0, eid.indexOf('.')) === type
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
render() {
|
|
70
|
-
if (!this.hass) {
|
|
71
|
-
return nothing;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const fanEntities = this.getEntitiesByType('fan');
|
|
75
|
-
|
|
76
|
-
return html`
|
|
77
|
-
<div class="card-config">
|
|
78
|
-
<paper-dropdown-menu
|
|
79
|
-
label="${localize('editor.entity')}"
|
|
80
|
-
@value-changed=${this._valueChanged}
|
|
81
|
-
.configValue=${'entity'}
|
|
82
|
-
>
|
|
83
|
-
<paper-listbox
|
|
84
|
-
slot="dropdown-content"
|
|
85
|
-
.selected=${fanEntities.indexOf(this._entity)}
|
|
86
|
-
>
|
|
87
|
-
${fanEntities.map((entity) => {
|
|
88
|
-
return html` <paper-item>${entity}</paper-item> `;
|
|
89
|
-
})}
|
|
90
|
-
</paper-listbox>
|
|
91
|
-
</paper-dropdown-menu>
|
|
92
|
-
|
|
93
|
-
<p class="option">
|
|
94
|
-
<ha-switch
|
|
95
|
-
aria-label=${localize(
|
|
96
|
-
this._compact_view
|
|
97
|
-
? 'editor.compact_view_aria_label_off'
|
|
98
|
-
: 'editor.compact_view_aria_label_on'
|
|
99
|
-
)}
|
|
100
|
-
.checked=${this._compact_view !== false}
|
|
101
|
-
.configValue=${'compact_view'}
|
|
102
|
-
@change=${this._valueChanged}
|
|
103
|
-
>
|
|
104
|
-
</ha-switch>
|
|
105
|
-
${localize('editor.compact_view')}
|
|
106
|
-
</p>
|
|
107
|
-
|
|
108
|
-
<p class="option">
|
|
109
|
-
<ha-switch
|
|
110
|
-
aria-label=${localize(
|
|
111
|
-
this._show_name
|
|
112
|
-
? 'editor.show_name_aria_label_off'
|
|
113
|
-
: 'editor.show_name_aria_label_on'
|
|
114
|
-
)}
|
|
115
|
-
.checked=${this._show_name !== false}
|
|
116
|
-
.configValue=${'show_name'}
|
|
117
|
-
@change=${this._valueChanged}
|
|
118
|
-
>
|
|
119
|
-
</ha-switch>
|
|
120
|
-
${localize('editor.show_name')}
|
|
121
|
-
</p>
|
|
122
|
-
|
|
123
|
-
<p class="option">
|
|
124
|
-
<ha-switch
|
|
125
|
-
aria-label=${localize(
|
|
126
|
-
this._show_state
|
|
127
|
-
? 'editor.show_state_aria_label_off'
|
|
128
|
-
: 'editor.show_state_aria_label_on'
|
|
129
|
-
)}
|
|
130
|
-
.checked=${this._show_state !== false}
|
|
131
|
-
.configValue=${'show_state'}
|
|
132
|
-
@change=${this._valueChanged}
|
|
133
|
-
>
|
|
134
|
-
</ha-switch>
|
|
135
|
-
${localize('editor.show_state')}
|
|
136
|
-
</p>
|
|
137
|
-
|
|
138
|
-
<p class="option">
|
|
139
|
-
<ha-switch
|
|
140
|
-
aria-label=${localize(
|
|
141
|
-
this._show_name
|
|
142
|
-
? 'editor.show_toolbar_aria_label_off'
|
|
143
|
-
: 'editor.show_toolbar_aria_label_on'
|
|
144
|
-
)}
|
|
145
|
-
.checked=${this._show_toolbar !== false}
|
|
146
|
-
.configValue=${'show_toolbar'}
|
|
147
|
-
@change=${this._valueChanged}
|
|
148
|
-
>
|
|
149
|
-
</ha-switch>
|
|
150
|
-
${localize('editor.show_toolbar')}
|
|
151
|
-
</p>
|
|
152
|
-
|
|
153
|
-
<strong>
|
|
154
|
-
${localize('editor.code_only_note')}
|
|
155
|
-
</strong>
|
|
156
|
-
</div>
|
|
157
|
-
`;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
_valueChanged(ev) {
|
|
161
|
-
if (!this._config || !this.hass) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const target = ev.target;
|
|
165
|
-
if (this[`_${target.configValue}`] === target.value) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
if (target.configValue) {
|
|
169
|
-
if (target.value === '') {
|
|
170
|
-
delete this._config[target.configValue];
|
|
171
|
-
} else {
|
|
172
|
-
this._config = {
|
|
173
|
-
...this._config,
|
|
174
|
-
[target.configValue]:
|
|
175
|
-
target.checked !== undefined ? target.checked : target.value,
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
fireEvent(this, 'config-changed', { config: this._config });
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
static get styles() {
|
|
183
|
-
return css`
|
|
184
|
-
.card-config paper-dropdown-menu {
|
|
185
|
-
width: 100%;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
.option {
|
|
189
|
-
display: flex;
|
|
190
|
-
align-items: center;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
.option ha-switch {
|
|
194
|
-
margin-right: 10px;
|
|
195
|
-
}
|
|
196
|
-
`;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
customElements.define('purifier-card-editor', PurifierCardEditor);
|