vacuum-card 2.2.7 → 2.3.2
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 +1 -2
- package/.github/workflows/release.yml +21 -9
- package/.github/workflows/validate.yml +32 -0
- package/README.md +25 -0
- package/dist/vacuum-card.js +3 -676
- package/package.json +16 -8
- package/rollup.config.js +19 -1
- package/src/localize.js +37 -34
- package/src/styles.css +274 -0
- package/src/translations/cn.json +67 -0
- package/src/vacuum-card-editor.js +2 -1
- package/src/vacuum-card.js +26 -34
- package/src/vacuum.svg +1 -0
- package/.github/workflows/build.yml +0 -14
- package/src/styles.js +0 -278
- package/src/vacuum.png +0 -0
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vacuum-card",
|
|
3
|
-
"version": "2.2
|
|
3
|
+
"version": "2.3.2",
|
|
4
4
|
"description": "Vacuum cleaner card for Home Assistant Lovelace UI",
|
|
5
5
|
"main": "dist/vacuum-card.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"postpublish": "git push --follow-tags",
|
|
8
7
|
"start": "rollup -c --watch",
|
|
9
|
-
"compile": "rollup -c",
|
|
10
8
|
"lint": "eslint src",
|
|
11
9
|
"lint:fix": "eslint src --fix",
|
|
12
10
|
"format": "prettier --write .",
|
|
13
|
-
"build": "
|
|
11
|
+
"build": "rollup -c",
|
|
12
|
+
"test": "npm run lint && npm run build"
|
|
14
13
|
},
|
|
15
14
|
"keywords": [
|
|
16
15
|
"home-assistant",
|
|
@@ -36,17 +35,26 @@
|
|
|
36
35
|
"@rollup/plugin-json": "^4.0.3",
|
|
37
36
|
"@rollup/plugin-node-resolve": "^7.1.3",
|
|
38
37
|
"@semantic-release/git": "^9.0.0",
|
|
39
|
-
"eslint": "^
|
|
40
|
-
"eslint-config-prettier": "^6.
|
|
41
|
-
"eslint-plugin-import": "^2.
|
|
38
|
+
"eslint": "^8.9.0",
|
|
39
|
+
"eslint-config-prettier": "^6.15.0",
|
|
40
|
+
"eslint-plugin-import": "^2.25.4",
|
|
42
41
|
"husky": "^4.2.5",
|
|
43
42
|
"lint-staged": "^10.2.2",
|
|
43
|
+
"postcss": "^8.4.6",
|
|
44
|
+
"postcss-preset-env": "^7.4.1",
|
|
44
45
|
"prettier": "^2.0.5",
|
|
45
46
|
"rollup": "^2.7.6",
|
|
47
|
+
"rollup-plugin-minify-html-literals": "^1.2.6",
|
|
48
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
49
|
+
"rollup-plugin-postcss-lit": "^2.0.0",
|
|
46
50
|
"rollup-plugin-serve": "^1.0.1",
|
|
47
51
|
"rollup-plugin-terser": "^5.3.0",
|
|
48
52
|
"semantic-release": "^17.3.7"
|
|
49
53
|
},
|
|
54
|
+
"browserslist": [
|
|
55
|
+
"last 2 versions",
|
|
56
|
+
"not dead"
|
|
57
|
+
],
|
|
50
58
|
"husky": {
|
|
51
59
|
"hooks": {
|
|
52
60
|
"pre-commit": "lint-staged"
|
|
@@ -54,7 +62,7 @@
|
|
|
54
62
|
},
|
|
55
63
|
"lint-staged": {
|
|
56
64
|
"*.js": "eslint --fix",
|
|
57
|
-
"
|
|
65
|
+
"*.{js,json,css,yml,md}": "prettier --write"
|
|
58
66
|
},
|
|
59
67
|
"release": {
|
|
60
68
|
"plugins": [
|
package/rollup.config.js
CHANGED
|
@@ -4,7 +4,11 @@ import nodeResolve from '@rollup/plugin-node-resolve';
|
|
|
4
4
|
import json from '@rollup/plugin-json';
|
|
5
5
|
import babel from '@rollup/plugin-babel';
|
|
6
6
|
import image from '@rollup/plugin-image';
|
|
7
|
+
import postcss from 'rollup-plugin-postcss';
|
|
8
|
+
import postcssPresetEnv from 'postcss-preset-env';
|
|
9
|
+
import postcssLit from 'rollup-plugin-postcss-lit';
|
|
7
10
|
import { terser } from 'rollup-plugin-terser';
|
|
11
|
+
import minifyLiterals from 'rollup-plugin-minify-html-literals';
|
|
8
12
|
import serve from 'rollup-plugin-serve';
|
|
9
13
|
|
|
10
14
|
const IS_DEV = process.env.ROLLUP_WATCH;
|
|
@@ -30,10 +34,24 @@ export default {
|
|
|
30
34
|
commonjs(),
|
|
31
35
|
json(),
|
|
32
36
|
babel({
|
|
37
|
+
babelHelpers: 'bundled',
|
|
33
38
|
exclude: 'node_modules/**',
|
|
34
39
|
}),
|
|
40
|
+
postcss({
|
|
41
|
+
plugins: [postcssPresetEnv()],
|
|
42
|
+
extract: false,
|
|
43
|
+
}),
|
|
44
|
+
postcssLit({
|
|
45
|
+
importPackage: 'lit-element',
|
|
46
|
+
}),
|
|
35
47
|
image(),
|
|
36
48
|
IS_DEV && serve(serverOptions),
|
|
37
|
-
!IS_DEV &&
|
|
49
|
+
!IS_DEV && minifyLiterals(),
|
|
50
|
+
!IS_DEV &&
|
|
51
|
+
terser({
|
|
52
|
+
output: {
|
|
53
|
+
comments: false,
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
38
56
|
],
|
|
39
57
|
};
|
package/src/localize.js
CHANGED
|
@@ -1,56 +1,59 @@
|
|
|
1
1
|
// Borrowed from:
|
|
2
2
|
// https://github.com/custom-cards/boilerplate-card/blob/master/src/localize/localize.ts
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
import * as
|
|
6
|
-
import * as
|
|
4
|
+
// Sorted alphabetically
|
|
5
|
+
import * as ca from './translations/ca.json';
|
|
6
|
+
import * as cn from './translations/cn.json';
|
|
7
|
+
import * as cs from './translations/cs.json';
|
|
8
|
+
import * as da from './translations/da.json';
|
|
7
9
|
import * as de from './translations/de.json';
|
|
8
|
-
import * as
|
|
9
|
-
import * as pl from './translations/pl.json';
|
|
10
|
-
import * as it from './translations/it.json';
|
|
11
|
-
import * as ru from './translations/ru.json';
|
|
10
|
+
import * as en from './translations/en.json';
|
|
12
11
|
import * as es from './translations/es.json';
|
|
13
|
-
import * as
|
|
14
|
-
import * as
|
|
12
|
+
import * as fi from './translations/fi.json';
|
|
13
|
+
import * as fr from './translations/fr.json';
|
|
15
14
|
import * as he from './translations/he.json';
|
|
16
|
-
import * as
|
|
15
|
+
import * as hu from './translations/hu.json';
|
|
16
|
+
import * as it from './translations/it.json';
|
|
17
|
+
import * as ko from './translations/ko.json';
|
|
18
|
+
import * as lt from './translations/lt.json';
|
|
17
19
|
import * as nb from './translations/nb.json';
|
|
20
|
+
import * as nl from './translations/nl.json';
|
|
18
21
|
import * as nn from './translations/nn.json';
|
|
19
|
-
import * as
|
|
20
|
-
import * as
|
|
21
|
-
import * as
|
|
22
|
-
import * as
|
|
22
|
+
import * as pl from './translations/pl.json';
|
|
23
|
+
import * as pt from './translations/pt.json';
|
|
24
|
+
import * as ro from './translations/ro.json';
|
|
25
|
+
import * as ru from './translations/ru.json';
|
|
26
|
+
import * as sv from './translations/sv.json';
|
|
23
27
|
import * as tw from './translations/tw.json';
|
|
28
|
+
import * as uk from './translations/uk.json';
|
|
24
29
|
import * as vi from './translations/vi.json';
|
|
25
|
-
import * as lt from './translations/lt.json';
|
|
26
|
-
import * as ro from './translations/ro.json';
|
|
27
|
-
import * as pt from './translations/pt.json';
|
|
28
30
|
|
|
29
31
|
var languages = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
ca,
|
|
33
|
+
cn,
|
|
34
|
+
cs,
|
|
35
|
+
da,
|
|
33
36
|
de,
|
|
34
|
-
|
|
35
|
-
pl,
|
|
36
|
-
it,
|
|
37
|
-
ru,
|
|
37
|
+
en,
|
|
38
38
|
es,
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
fi,
|
|
40
|
+
fr,
|
|
41
41
|
he,
|
|
42
|
-
|
|
42
|
+
hu,
|
|
43
|
+
it,
|
|
44
|
+
ko,
|
|
45
|
+
lt,
|
|
43
46
|
nb,
|
|
47
|
+
nl,
|
|
44
48
|
nn,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
pl,
|
|
50
|
+
pt,
|
|
51
|
+
ro,
|
|
52
|
+
ru,
|
|
53
|
+
sv,
|
|
49
54
|
tw,
|
|
55
|
+
uk,
|
|
50
56
|
vi,
|
|
51
|
-
lt,
|
|
52
|
-
ro,
|
|
53
|
-
pt,
|
|
54
57
|
};
|
|
55
58
|
|
|
56
59
|
const DEFAULT_LANG = 'en';
|
package/src/styles.css
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex: 1;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
ha-card {
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
flex: 1;
|
|
10
|
+
position: relative;
|
|
11
|
+
padding: 0px;
|
|
12
|
+
border-radius: 4px;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.preview {
|
|
17
|
+
background: var(--primary-color);
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
position: relative;
|
|
21
|
+
text-align: center;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.preview.not-available {
|
|
25
|
+
filter: grayscale(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.map {
|
|
29
|
+
max-width: 95%;
|
|
30
|
+
image-rendering: crisp-edges;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@keyframes cleaning {
|
|
34
|
+
0% {
|
|
35
|
+
transform: rotate(0) translate(0);
|
|
36
|
+
}
|
|
37
|
+
5% {
|
|
38
|
+
transform: rotate(0) translate(0, -10px);
|
|
39
|
+
}
|
|
40
|
+
10% {
|
|
41
|
+
transform: rotate(0) translate(0, 5px);
|
|
42
|
+
}
|
|
43
|
+
15% {
|
|
44
|
+
transform: rotate(0) translate(0);
|
|
45
|
+
}
|
|
46
|
+
/* Turn left */
|
|
47
|
+
20% {
|
|
48
|
+
transform: rotate(30deg) translate(0);
|
|
49
|
+
}
|
|
50
|
+
25% {
|
|
51
|
+
transform: rotate(30deg) translate(0, -10px);
|
|
52
|
+
}
|
|
53
|
+
30% {
|
|
54
|
+
transform: rotate(30deg) translate(0, 5px);
|
|
55
|
+
}
|
|
56
|
+
35% {
|
|
57
|
+
transform: rotate(30deg) translate(0);
|
|
58
|
+
}
|
|
59
|
+
40% {
|
|
60
|
+
transform: rotate(0) translate(0);
|
|
61
|
+
}
|
|
62
|
+
/* Turn right */
|
|
63
|
+
45% {
|
|
64
|
+
transform: rotate(-30deg) translate(0);
|
|
65
|
+
}
|
|
66
|
+
50% {
|
|
67
|
+
transform: rotate(-30deg) translate(0, -10px);
|
|
68
|
+
}
|
|
69
|
+
55% {
|
|
70
|
+
transform: rotate(-30deg) translate(0, 5px);
|
|
71
|
+
}
|
|
72
|
+
60% {
|
|
73
|
+
transform: rotate(-30deg) translate(0);
|
|
74
|
+
}
|
|
75
|
+
70% {
|
|
76
|
+
transform: rotate(0deg) translate(0);
|
|
77
|
+
}
|
|
78
|
+
/* Staying still */
|
|
79
|
+
100% {
|
|
80
|
+
transform: rotate(0deg);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@keyframes returning {
|
|
85
|
+
0% {
|
|
86
|
+
transform: rotate(0);
|
|
87
|
+
}
|
|
88
|
+
25% {
|
|
89
|
+
transform: rotate(10deg);
|
|
90
|
+
}
|
|
91
|
+
50% {
|
|
92
|
+
transform: rotate(0);
|
|
93
|
+
}
|
|
94
|
+
75% {
|
|
95
|
+
transform: rotate(-10deg);
|
|
96
|
+
}
|
|
97
|
+
100% {
|
|
98
|
+
transform: rotate(0);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.vacuum {
|
|
103
|
+
display: block;
|
|
104
|
+
max-width: 90%;
|
|
105
|
+
max-height: 200px;
|
|
106
|
+
image-rendering: crisp-edges;
|
|
107
|
+
margin: 30px auto 20px auto;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.vacuum.on,
|
|
111
|
+
.vacuum.cleaning,
|
|
112
|
+
.vacuum.auto,
|
|
113
|
+
.vacuum.spot,
|
|
114
|
+
.vacuum.edge,
|
|
115
|
+
.vacuum.single_room {
|
|
116
|
+
animation: cleaning 5s linear infinite;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.vacuum.returning {
|
|
120
|
+
animation: returning 2s linear infinite;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.vacuum.paused {
|
|
124
|
+
opacity: 100%;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.vacuum.docked {
|
|
128
|
+
opacity: 50%;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.fill-gap {
|
|
132
|
+
flex-grow: 1;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.header {
|
|
136
|
+
height: 40px;
|
|
137
|
+
display: flex;
|
|
138
|
+
flex-direction: row;
|
|
139
|
+
justify-content: space-between;
|
|
140
|
+
align-items: center;
|
|
141
|
+
color: var(--text-primary-color);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.battery {
|
|
145
|
+
text-align: right;
|
|
146
|
+
font-weight: bold;
|
|
147
|
+
padding: 8px;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.source {
|
|
151
|
+
padding-left: 7px;
|
|
152
|
+
text-align: center;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.status {
|
|
156
|
+
display: flex;
|
|
157
|
+
align-items: center;
|
|
158
|
+
justify-content: center;
|
|
159
|
+
direction: ltr;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.status-text {
|
|
163
|
+
color: var(--text-primary-color);
|
|
164
|
+
white-space: nowrap;
|
|
165
|
+
text-overflow: ellipsis;
|
|
166
|
+
overflow: hidden;
|
|
167
|
+
margin-left: calc(20px + 9px); /* size + margin of spinner */
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.status ha-circular-progress {
|
|
171
|
+
--mdc-theme-primary: var(
|
|
172
|
+
--card-background-color
|
|
173
|
+
); /* hack to override the color */
|
|
174
|
+
min-width: 24px;
|
|
175
|
+
width: 24px;
|
|
176
|
+
height: 24px;
|
|
177
|
+
margin-left: 9px;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.vacuum-name {
|
|
181
|
+
text-align: center;
|
|
182
|
+
font-weight: bold;
|
|
183
|
+
color: var(--text-primary-color);
|
|
184
|
+
font-size: 16px;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.not-available .offline {
|
|
188
|
+
text-align: center;
|
|
189
|
+
color: var(--text-primary-color);
|
|
190
|
+
font-size: 16px;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.metadata {
|
|
194
|
+
margin: 10px auto;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.stats {
|
|
198
|
+
border-top: 1px solid rgba(255, 255, 255, 0.2);
|
|
199
|
+
display: flex;
|
|
200
|
+
flex-direction: row;
|
|
201
|
+
justify-content: space-evenly;
|
|
202
|
+
color: var(--text-primary-color);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.stats-block {
|
|
206
|
+
margin: 10px 0px;
|
|
207
|
+
text-align: center;
|
|
208
|
+
border-right: 1px solid rgba(255, 255, 255, 0.2);
|
|
209
|
+
flex-grow: 1;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.stats-block:last-child {
|
|
213
|
+
border: 0px;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.stats-value {
|
|
217
|
+
font-size: 20px;
|
|
218
|
+
font-weight: bold;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
ha-icon {
|
|
222
|
+
color: #fff;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.toolbar {
|
|
226
|
+
background: var(--lovelace-background, var(--primary-background-color));
|
|
227
|
+
min-height: 30px;
|
|
228
|
+
display: flex;
|
|
229
|
+
flex-direction: row;
|
|
230
|
+
flex-flow: row wrap;
|
|
231
|
+
flex-wrap: wrap;
|
|
232
|
+
justify-content: space-evenly;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.toolbar ha-icon-button {
|
|
236
|
+
color: var(--primary-color);
|
|
237
|
+
flex-direction: column;
|
|
238
|
+
width: 44px;
|
|
239
|
+
height: 44px;
|
|
240
|
+
--mdc-icon-button-size: 44px;
|
|
241
|
+
margin: 5px 0;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.toolbar ha-icon-button:first-child {
|
|
245
|
+
margin-left: 5px;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.toolbar ha-icon-button:last-child {
|
|
249
|
+
margin-right: 5px;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.toolbar paper-button {
|
|
253
|
+
color: var(--primary-color);
|
|
254
|
+
flex-direction: column;
|
|
255
|
+
margin-right: 10px;
|
|
256
|
+
padding: 15px 10px;
|
|
257
|
+
cursor: pointer;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.toolbar ha-icon-button:active,
|
|
261
|
+
.toolbar paper-button:active {
|
|
262
|
+
opacity: 0.4;
|
|
263
|
+
background: rgba(0, 0, 0, 0.1);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.toolbar paper-button {
|
|
267
|
+
color: var(--primary-color);
|
|
268
|
+
flex-direction: row;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.toolbar ha-icon {
|
|
272
|
+
color: var(--primary-color);
|
|
273
|
+
display: flex;
|
|
274
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"status": {
|
|
3
|
+
"cleaning": "清扫中",
|
|
4
|
+
"auto": "自动清扫",
|
|
5
|
+
"spot": "区域清扫",
|
|
6
|
+
"edge": "边缘清扫",
|
|
7
|
+
"single_room": "单房间清扫",
|
|
8
|
+
"paused": "暂停中",
|
|
9
|
+
"idle": "闲置中",
|
|
10
|
+
"stop": "已停止",
|
|
11
|
+
"charging": "充电中",
|
|
12
|
+
"returning home": "回充",
|
|
13
|
+
"returning": "回充",
|
|
14
|
+
"docked": "充电中",
|
|
15
|
+
"unknown": "未知",
|
|
16
|
+
"offline": "离线",
|
|
17
|
+
"error": "错误"
|
|
18
|
+
},
|
|
19
|
+
"source": {
|
|
20
|
+
"gentle": "轻柔",
|
|
21
|
+
"silent": "安静",
|
|
22
|
+
"standard": "标准",
|
|
23
|
+
"medium": "中等",
|
|
24
|
+
"turbo": "强力",
|
|
25
|
+
"normal": "正常",
|
|
26
|
+
"high": "高",
|
|
27
|
+
"strong": "强力",
|
|
28
|
+
"quiet": "安静",
|
|
29
|
+
"max": "Max",
|
|
30
|
+
"max+": "Max+"
|
|
31
|
+
},
|
|
32
|
+
"common": {
|
|
33
|
+
"name": "Vacuum Card",
|
|
34
|
+
"description": "Vacuum Card 允许您控制您的扫地机器人。",
|
|
35
|
+
"start": "清扫",
|
|
36
|
+
"continue": "继续",
|
|
37
|
+
"pause": "暂停",
|
|
38
|
+
"stop": "停止",
|
|
39
|
+
"return_to_base": "回充",
|
|
40
|
+
"locate": "定位扫地机器人",
|
|
41
|
+
"not_available": "扫地机器人不可用"
|
|
42
|
+
},
|
|
43
|
+
"error": {
|
|
44
|
+
"missing_entity": "必须指定一个实体!"
|
|
45
|
+
},
|
|
46
|
+
"warning": {
|
|
47
|
+
"actions_array": "警告: \"动作\" 是为了覆盖现有按钮的默认动作而保留的。如果你的目的是增加额外的动作,请使用\"快捷键\"选项来代替。"
|
|
48
|
+
},
|
|
49
|
+
"editor": {
|
|
50
|
+
"entity": "实体 (必填)",
|
|
51
|
+
"map": "地图 (选填)",
|
|
52
|
+
"image": "图片 (选填)",
|
|
53
|
+
"compact_view": "紧凑视图",
|
|
54
|
+
"compact_view_aria_label_on": "开启紧凑视图",
|
|
55
|
+
"compact_view_aria_label_off": "关闭紧凑视图",
|
|
56
|
+
"show_name": "显示名称",
|
|
57
|
+
"show_name_aria_label_on": "开启名称显示",
|
|
58
|
+
"show_name_aria_label_off": "关闭名称显示",
|
|
59
|
+
"show_status": "显示状态",
|
|
60
|
+
"show_status_aria_label_on": "开启状态显示",
|
|
61
|
+
"show_status_aria_label_off": "关闭状态显示",
|
|
62
|
+
"show_toolbar": "显示工具栏",
|
|
63
|
+
"show_toolbar_aria_label_on": "开启工具栏显示",
|
|
64
|
+
"show_toolbar_aria_label_off": "关闭工具栏显示",
|
|
65
|
+
"code_only_note": "注意: 设置动作和统计选项只能使用代码编辑器。"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
|
+
import { nothing } from 'lit-html';
|
|
2
3
|
import { fireEvent } from 'custom-card-helpers';
|
|
3
4
|
import localize from './localize';
|
|
4
5
|
|
|
@@ -84,7 +85,7 @@ export class VacuumCardEditor extends LitElement {
|
|
|
84
85
|
|
|
85
86
|
render() {
|
|
86
87
|
if (!this.hass) {
|
|
87
|
-
return
|
|
88
|
+
return nothing;
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
const vacuumEntities = this.getEntitiesByType('vacuum');
|
package/src/vacuum-card.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { LitElement, html } from 'lit-element';
|
|
2
|
+
import { nothing } from 'lit-html';
|
|
2
3
|
import { hasConfigOrEntityChanged, fireEvent } from 'custom-card-helpers';
|
|
3
4
|
import get from 'lodash.get';
|
|
4
5
|
import './vacuum-card-editor';
|
|
5
6
|
import localize from './localize';
|
|
6
|
-
import styles from './styles';
|
|
7
|
-
import defaultImage from './vacuum.
|
|
7
|
+
import styles from './styles.css';
|
|
8
|
+
import defaultImage from './vacuum.svg';
|
|
8
9
|
import { version } from '../package.json';
|
|
9
10
|
|
|
10
11
|
console.info(
|
|
@@ -272,45 +273,36 @@ class VacuumCard extends LitElement {
|
|
|
272
273
|
);
|
|
273
274
|
|
|
274
275
|
if (!sources) {
|
|
275
|
-
return
|
|
276
|
+
return nothing;
|
|
276
277
|
}
|
|
277
278
|
|
|
278
279
|
const selected = sources.indexOf(source);
|
|
279
280
|
|
|
280
281
|
return html`
|
|
281
|
-
<
|
|
282
|
-
slot="
|
|
283
|
-
.horizontalAlign=${'right'}
|
|
284
|
-
.verticalAlign=${'top'}
|
|
285
|
-
.verticalOffset=${40}
|
|
286
|
-
.noAnimations=${true}
|
|
287
|
-
@click="${(e) => e.stopPropagation()}"
|
|
288
|
-
>
|
|
289
|
-
<paper-button slot="dropdown-trigger">
|
|
282
|
+
<ha-button-menu @click="${(e) => e.stopPropagation()}">
|
|
283
|
+
<mmp-icon-button slot="trigger">
|
|
290
284
|
<ha-icon icon="mdi:fan"></ha-icon>
|
|
291
|
-
<span
|
|
285
|
+
<span>
|
|
292
286
|
${localize(`source.${source}`) || source}
|
|
293
287
|
</span>
|
|
294
|
-
</
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
</paper-listbox>
|
|
307
|
-
</paper-menu-button>
|
|
288
|
+
</mmp-icon-button>
|
|
289
|
+
${sources.map(
|
|
290
|
+
(item, index) =>
|
|
291
|
+
html`<mwc-list-item
|
|
292
|
+
?activated=${selected === index}
|
|
293
|
+
value=${item}
|
|
294
|
+
@click=${(e) => this.handleSpeed(e)}
|
|
295
|
+
>
|
|
296
|
+
${localize(`source.${item}`) || item}
|
|
297
|
+
</mwc-list-item>`
|
|
298
|
+
)}
|
|
299
|
+
</ha-button-menu>
|
|
308
300
|
`;
|
|
309
301
|
}
|
|
310
302
|
|
|
311
303
|
renderMapOrImage(state) {
|
|
312
304
|
if (this.compactView) {
|
|
313
|
-
return
|
|
305
|
+
return nothing;
|
|
314
306
|
}
|
|
315
307
|
|
|
316
308
|
if (this.map) {
|
|
@@ -321,14 +313,14 @@ class VacuumCard extends LitElement {
|
|
|
321
313
|
src="${this.hass.states[this.config.map].attributes
|
|
322
314
|
.entity_picture}&v=${+new Date()}"
|
|
323
315
|
/>`
|
|
324
|
-
:
|
|
316
|
+
: nothing;
|
|
325
317
|
}
|
|
326
318
|
|
|
327
319
|
if (this.image) {
|
|
328
320
|
return html`<img class="vacuum ${state}" src="${this.image}" />`;
|
|
329
321
|
}
|
|
330
322
|
|
|
331
|
-
return
|
|
323
|
+
return nothing;
|
|
332
324
|
}
|
|
333
325
|
|
|
334
326
|
renderStats(state) {
|
|
@@ -338,7 +330,7 @@ class VacuumCard extends LitElement {
|
|
|
338
330
|
|
|
339
331
|
return statsList.map(({ entity_id, attribute, unit, subtitle }) => {
|
|
340
332
|
if (!entity_id && !attribute) {
|
|
341
|
-
return
|
|
333
|
+
return nothing;
|
|
342
334
|
}
|
|
343
335
|
|
|
344
336
|
const value = entity_id
|
|
@@ -359,7 +351,7 @@ class VacuumCard extends LitElement {
|
|
|
359
351
|
const { friendly_name } = this.getAttributes(this.entity);
|
|
360
352
|
|
|
361
353
|
if (!this.showName) {
|
|
362
|
-
return
|
|
354
|
+
return nothing;
|
|
363
355
|
}
|
|
364
356
|
|
|
365
357
|
return html`
|
|
@@ -374,7 +366,7 @@ class VacuumCard extends LitElement {
|
|
|
374
366
|
const localizedStatus = localize(`status.${status}`) || status;
|
|
375
367
|
|
|
376
368
|
if (!this.showStatus) {
|
|
377
|
-
return
|
|
369
|
+
return nothing;
|
|
378
370
|
}
|
|
379
371
|
|
|
380
372
|
return html`
|
|
@@ -392,7 +384,7 @@ class VacuumCard extends LitElement {
|
|
|
392
384
|
|
|
393
385
|
renderToolbar(state) {
|
|
394
386
|
if (!this.showToolbar) {
|
|
395
|
-
return
|
|
387
|
+
return nothing;
|
|
396
388
|
}
|
|
397
389
|
|
|
398
390
|
switch (state) {
|
package/src/vacuum.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="490" height="490" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M490 245c0 135.31-109.69 245-245 245S0 380.31 0 245c0-3.013.0543891-6.013.162239-9H5l5 3v-12l-8.84919-5.899C13.1643 97.0064 117.754 0 245 0c127.089 0 231.578 96.7672 243.804 220.641L480 227v12.5l5-4h4.819c.12 3.152.181 6.319.181 9.5Z" fill="#fff"/><path d="M411.749 119c-6.307-8.348-13.27-16.258-20.851-23.6492C351.81 57.243 299.364 35.941 244.774 36.0001c-54.59.0591-106.99 21.4746-145.9954 59.667C59.7735 133.86 37.2596 185.797 36.0512 240.374l2.0895.046c.918-41.46 14.2556-81.382 37.8593-114.798V126h116v-2H77.1576c.7253-1.006 1.46-2.006 2.204-3H192v-2H80.8779c5.8988-7.683 12.3626-14.985 19.3631-21.8395 38.615-37.8105 90.491-59.0119 144.535-59.0704 54.044-.0585 105.966 21.0305 144.663 58.7572 7.123 6.9447 13.694 14.3517 19.683 22.1527H299v2h111.638c.744.994 1.479 1.994 2.204 3H299v2h115.266c23.35 33.213 36.583 72.821 37.583 113.972l2.089-.051c-1.066-43.848-15.882-85.962-41.938-120.589V119h-.251Z" fill="#AAA"/><path fill-rule="evenodd" clip-rule="evenodd" d="M300 122.5c0 30.1-24.624 54.5-55 54.5s-55-24.4-55-54.5c0-30.0995 24.624-54.5 55-54.5s55 24.4005 55 54.5Zm-4 0c0 27.856-22.799 50.5-51 50.5s-51-22.644-51-50.5S216.799 72 245 72s51 22.644 51 50.5Z" fill="#666"/><path fill-rule="evenodd" clip-rule="evenodd" d="M1.12741 221.523C6.9567 160.97 35.1055 104.75 80.0964 63.8045 125.087 22.8589 183.702.115675 244.536.00044016 305.369-.114809 364.07 22.4061 409.216 63.1811c44.985 40.6299 73.305 96.4879 79.5 156.7719l.011.001c-.002.013-.004.025-.007.038.021.202.042.405.062.607l-.279.028c-.145.286-.312.483-.382.565l-.003.005c-.185.218-.402.426-.611.612-.425.377-.994.817-1.651 1.294-1.325.963-3.171 2.194-5.341 3.588-.17.109-.341.219-.515.33v12.215l.249-.174c1.54-1.073 2.823-1.981 3.736-2.644.39-.283.703-.515.936-.693l-.007-.183.254-.01c.048-.038.083-.067.106-.087l.008-.007-.01.01c-.01.009-.033.032-.063.066l-.015.017 4.616-.182c1.298 32.938-4.063 65.799-15.764 96.616-11.7 30.816-29.499 58.955-52.331 82.731-22.832 23.776-50.226 42.7-80.544 55.64-30.317 12.939-62.934 19.627-95.898 19.664-32.963.037-65.594-6.579-95.941-19.45-30.346-12.872-57.783-31.735-80.6677-55.46-22.8846-23.725-40.7463-51.824-52.5157-82.614-11.76935-30.791-17.20429-63.64-15.979377-96.58l3.830807.142V236c.18555 0 .35898.025.50489.057l.56091.021-.00581.158c.13048.053.26118.112.38589.171.35305.167.78483.397 1.26649.667.87404.489 1.99915 1.158 3.2876 1.949v-12.13l-.4815-.302c-2.17716-1.367-4.02092-2.536-5.35246-3.398-.66426-.431-1.21155-.792-1.61262-1.066-.19905-.136-.37589-.261-.51834-.366l-.01222-.009c-.04061-.03-.11781-.087-.20795-.163l-.6875-.066ZM464.644 236.475c3.564-2.147 7.127-4.312 10.356-6.313v12.528c-1.909 1.31-3.945 2.699-5.987 4.086-4.093 2.779-8.206 5.546-11.376 7.648-1.586 1.052-2.93 1.933-3.915 2.566-.474.304-.857.546-1.14.719l-.19-.011-.007.131c-.063.037-.107.062-.135.079-.03.017-.042.025-.042.025l.024-.009c.01-.004.023-.01.039-.016l.095.241c-3.217 52.86-26.453 102.516-64.989 138.858-38.646 36.444-89.759 56.743-142.878 56.743-53.12 0-104.232-20.3-142.878-56.745-38.6453-36.445-61.9029-86.281-65.0136-139.31l-.2108.013c-.0549-.17-.1194-.3-.1616-.378-.0859-.16-.1788-.29-.2489-.38-.1401-.181-.2992-.346-.4386-.482-.2858-.279-.6601-.598-1.0796-.936-.8488-.684-2.029-1.563-3.413-2.556-2.7761-1.991-6.4661-4.507-10.1873-6.974-1.9862-1.317-3.9866-2.622-5.8676-3.83v-12.157c3.2173 2.001 6.7542 4.19 10.2783 6.365 5.686 3.509 11.3427 6.985 15.5776 9.583 2.1175 1.299 3.8798 2.379 5.1126 3.134l1.0774.66c1.0989 51.017 21.909 99.675 58.1301 135.725 36.902 36.729 86.816 57.401 138.881 57.518 52.066.116 102.072-20.331 139.139-56.895 36.507-36.012 57.554-84.787 58.75-135.992.352-.224.817-.513 1.385-.861 1.325-.813 3.172-1.923 5.371-3.238 1.287-.77 2.693-1.609 4.183-2.498l.097-.058c3.574-2.133 7.624-4.55 11.662-6.983ZM6.22995 219.764l.11131.072c1.3071.847 3.13156 2.004 5.30424 3.368 4.343 2.727 10.0507 6.265 15.7336 9.772 5.6819 3.507 11.3354 6.98 15.5686 9.578 2.1165 1.298 3.8778 2.377 5.11 3.132l1.9049 1.166.9921-.007c.3546 51.024 20.8428 99.843 57.0073 135.837 36.165 35.995 85.08 56.253 136.104 56.367 51.025.115 100.03-19.924 136.356-55.756 36.325-35.832 57.032-84.559 57.615-135.58l.585.006-.071-.066c.19-.204.434-.374.522-.435l.012-.008c.144-.101.323-.22.524-.35.406-.262.96-.607 1.631-1.018 1.346-.826 3.21-1.946 5.409-3.261 1.321-.79 2.764-1.651 4.292-2.563 3.571-2.131 7.608-4.54 11.639-6.969 5.757-3.469 11.476-6.963 15.773-9.723 2.152-1.384 3.921-2.565 5.152-3.459.053-.038.104-.076.154-.113l.102-.075c-6.233-58.782-33.937-113.219-77.829-152.8616C361.689 26.858 304.162 4.78749 244.545 4.90042 184.928 5.01336 127.486 27.3017 83.3945 67.4284 39.856 107.052 12.4116 161.271 6.22995 219.764Zm2.09908 22.928c-1.35577-.837-2.51273-1.53-3.38991-2.026-.55505 30.74 4.79901 61.315 15.78648 90.06 11.534 30.175 29.0385 57.712 51.4654 80.963 22.427 23.25 49.315 41.736 79.055 54.35 29.739 12.614 61.718 19.097 94.022 19.061 32.304-.036 64.269-6.591 93.98-19.271 29.711-12.681 56.558-31.226 78.933-54.527 22.375-23.3 39.818-50.876 51.284-81.077 10.871-28.632 16.159-59.064 15.594-89.655-.734.522-1.584 1.119-2.522 1.773-3.095 2.159-7.176 4.958-11.277 7.742-4.101 2.785-8.227 5.56-11.412 7.673-1.284.851-2.419 1.597-3.34 2.194-3.637 53.361-27.268 103.418-66.216 140.147C350.858 437.287 298.702 458 244.498 458c-54.204 0-106.359-20.714-145.7927-57.903-39.1679-36.938-62.8452-87.356-66.2735-141.057-.1301-.112-.2876-.243-.4742-.394-.7611-.613-1.8697-1.441-3.2341-2.419-2.7209-1.952-6.3663-4.439-10.0659-6.891-3.6986-2.452-7.4329-4.857-10.32857-6.644Z" fill="#666"/><rect x="233" y="365" width="24" height="53" rx="12" stroke="#AAA" stroke-width="2"/></svg>
|