purifier-card 2.5.3 → 2.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "purifier-card",
3
- "version": "2.5.3",
3
+ "version": "2.6.0",
4
4
  "description": "Air Purifier card for Home Assistant Lovelace UI",
5
5
  "main": "dist/purifier-card.js",
6
6
  "scripts": {
@@ -48,7 +48,7 @@
48
48
  "eslint-config-prettier": "^9.1.0",
49
49
  "eslint-plugin-import": "^2.20.2",
50
50
  "husky": "^9.0.11",
51
- "lint-staged": "^13.0.0",
51
+ "lint-staged": "^15.2.2",
52
52
  "postcss-preset-env": "^9.1.2",
53
53
  "prettier": "^3.2.5",
54
54
  "rollup": "^2.7.6",
package/src/config.ts CHANGED
@@ -2,7 +2,7 @@ import { PurifierCardConfig } from './types';
2
2
  import localize from './localize';
3
3
 
4
4
  export default function buildConfig(
5
- config?: Partial<PurifierCardConfig>
5
+ config?: Partial<PurifierCardConfig>,
6
6
  ): PurifierCardConfig {
7
7
  if (!config) {
8
8
  throw new Error(localize('error.invalid_config'));
package/src/editor.ts CHANGED
@@ -63,9 +63,8 @@ export class PurifierCardEditor extends LitElement {
63
63
  validationMessage=${localize('error.missing_entity')}
64
64
  >
65
65
  ${fanEntities.map(
66
- (entity) => html`<mwc-list-item .value=${entity}
67
- >${entity}</mwc-list-item
68
- >`
66
+ (entity) =>
67
+ html`<mwc-list-item .value=${entity}>${entity}</mwc-list-item>`,
69
68
  )}
70
69
  </ha-select>
71
70
  </div>
@@ -75,7 +74,7 @@ export class PurifierCardEditor extends LitElement {
75
74
  aria-label=${localize(
76
75
  this.compact_view
77
76
  ? 'editor.compact_view_aria_label_off'
78
- : 'editor.compact_view_aria_label_on'
77
+ : 'editor.compact_view_aria_label_on',
79
78
  )}
80
79
  .checked=${this.compact_view}
81
80
  .configValue=${'compact_view'}
@@ -90,7 +89,7 @@ export class PurifierCardEditor extends LitElement {
90
89
  aria-label=${localize(
91
90
  this.show_name
92
91
  ? 'editor.show_name_aria_label_off'
93
- : 'editor.show_name_aria_label_on'
92
+ : 'editor.show_name_aria_label_on',
94
93
  )}
95
94
  .checked=${this.show_name}
96
95
  .configValue=${'show_name'}
@@ -105,7 +104,7 @@ export class PurifierCardEditor extends LitElement {
105
104
  aria-label=${localize(
106
105
  this.show_state
107
106
  ? 'editor.show_state_aria_label_off'
108
- : 'editor.show_state_aria_label_on'
107
+ : 'editor.show_state_aria_label_on',
109
108
  )}
110
109
  .checked=${this.show_state}
111
110
  .configValue=${'show_state'}
@@ -120,7 +119,7 @@ export class PurifierCardEditor extends LitElement {
120
119
  aria-label=${localize(
121
120
  this.show_name
122
121
  ? 'editor.show_toolbar_aria_label_off'
123
- : 'editor.show_toolbar_aria_label_on'
122
+ : 'editor.show_toolbar_aria_label_on',
124
123
  )}
125
124
  .checked=${this.show_toolbar}
126
125
  .configValue=${'show_toolbar'}
package/src/localize.ts CHANGED
@@ -48,7 +48,7 @@ const DEFAULT_LANG = 'en';
48
48
  export default function localize(
49
49
  str: string,
50
50
  search?: string,
51
- replace?: string
51
+ replace?: string,
52
52
  ): string | undefined {
53
53
  const [section, key] = str.toLowerCase().split('.');
54
54
 
@@ -23,19 +23,19 @@ import buildConfig from './config';
23
23
 
24
24
  registerTemplates();
25
25
 
26
- // String in the right side will be replaced by Rollup
26
+ // String on the right side will be replaced by Rollup
27
27
  const PKG_VERSION = 'PKG_VERSION_VALUE';
28
28
 
29
29
  console.info(
30
30
  `%c PURIFIER-CARD %c ${PKG_VERSION} `,
31
31
  'color: white; background: blue; font-weight: 700;',
32
- 'color: blue; background: white; font-weight: 700;'
32
+ 'color: blue; background: white; font-weight: 700;',
33
33
  );
34
34
 
35
35
  if (!customElements.get('ha-icon-button')) {
36
36
  customElements.define(
37
37
  'ha-icon-button',
38
- class extends (customElements.get('paper-icon-button') ?? HTMLElement) {}
38
+ class extends (customElements.get('paper-icon-button') ?? HTMLElement) {},
39
39
  );
40
40
  }
41
41
 
@@ -58,7 +58,7 @@ export class PurifierCard extends LitElement {
58
58
 
59
59
  public static getStubConfig(
60
60
  _: unknown,
61
- entities: string[]
61
+ entities: string[],
62
62
  ): Partial<PurifierCardConfig> {
63
63
  const [purifierEntity] = entities.filter((eid) => eid.startsWith('fan'));
64
64
 
@@ -103,20 +103,26 @@ export class PurifierCard extends LitElement {
103
103
  {
104
104
  bubbles: false,
105
105
  composed: true,
106
- }
106
+ },
107
107
  );
108
108
  }
109
109
 
110
110
  private callService(
111
111
  service: ServiceCallRequest['service'],
112
112
  options: ServiceCallRequest['serviceData'] = {},
113
- request = true
113
+ target?: ServiceCallRequest['target'],
114
+ request = true,
114
115
  ) {
115
116
  const [domain, name] = service.split('.');
116
- this.hass.callService(domain, name, {
117
- entity_id: this.config.entity,
118
- ...options,
119
- });
117
+ this.hass.callService(
118
+ domain,
119
+ name,
120
+ {
121
+ entity_id: this.config.entity,
122
+ ...options,
123
+ },
124
+ target,
125
+ );
120
126
 
121
127
  if (request) {
122
128
  this.requestInProgress = true;
@@ -161,16 +167,15 @@ export class PurifierCard extends LitElement {
161
167
  </mmp-icon-button>
162
168
 
163
169
  ${preset_modes.map(
164
- (item, index) =>
165
- html`
166
- <mwc-list-item
167
- ?activated=${selected === index}
168
- value=${item}
169
- @click=${(e: PointerEvent) => this.handlePresetMode(e)}
170
- >
171
- ${localize(`preset_mode.${item.toLowerCase()}`) || item}
172
- </mwc-list-item>
173
- `
170
+ (item, index) => html`
171
+ <mwc-list-item
172
+ ?activated=${selected === index}
173
+ value=${item}
174
+ @click=${(e: PointerEvent) => this.handlePresetMode(e)}
175
+ >
176
+ ${localize(`preset_mode.${item.toLowerCase()}`) || item}
177
+ </mwc-list-item>
178
+ `,
174
179
  )}
175
180
  </ha-button-menu>
176
181
  </div>
@@ -316,7 +321,7 @@ export class PurifierCard extends LitElement {
316
321
  <div class="stats-subtitle">${subtitle}</div>
317
322
  </div>
318
323
  `;
319
- }
324
+ },
320
325
  );
321
326
 
322
327
  return stats.length ? html`<div class="stats">${stats}</div>` : nothing;
@@ -331,10 +336,18 @@ export class PurifierCard extends LitElement {
331
336
  }
332
337
 
333
338
  const buttons = shortcuts.map(
334
- ({ name, icon, service, service_data, preset_mode, percentage }) => {
339
+ ({
340
+ name,
341
+ icon,
342
+ service,
343
+ service_data,
344
+ target,
345
+ preset_mode,
346
+ percentage,
347
+ }) => {
335
348
  const execute = () => {
336
349
  if (service) {
337
- this.callService(service, service_data);
350
+ this.callService(service, target, service_data);
338
351
  }
339
352
 
340
353
  if (preset_mode) {
@@ -362,7 +375,7 @@ export class PurifierCard extends LitElement {
362
375
  ><ha-icon icon="${icon}"></ha-icon
363
376
  ></ha-icon-button>
364
377
  `;
365
- }
378
+ },
366
379
  );
367
380
 
368
381
  return html`
package/src/types.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  HassEntityAttributeBase,
3
3
  HassEntityBase,
4
+ HassServiceTarget,
4
5
  } from 'home-assistant-js-websocket';
5
6
  import { TemplateResult, nothing } from 'lit';
6
7
 
@@ -44,6 +45,7 @@ export interface PurifierCardShortcut {
44
45
  icon?: string;
45
46
  service?: string;
46
47
  service_data?: Record<string, unknown>;
48
+ target?: HassServiceTarget;
47
49
  percentage?: number;
48
50
  preset_mode?: string;
49
51
  }