diff --git a/README.md b/README.md index 3bb1b87..55ebe69 100644 --- a/README.md +++ b/README.md @@ -102,17 +102,19 @@ compact_view: false Here is what every option means: -| Name | Type | Default | Description | -| -------------- | :-------: | ------------ | ------------------------------------------------ | -| `type` | `string` | **Required** | `custom:purifier-card` | -| `entity` | `string` | **Required** | An entity_id within the `fan` domain. | -| `show_name` | `boolean` | `true` | Show friendly name of the purifier. | -| `show_status` | `boolean` | `true` | Show status of the purifier. | -| `show_toolbar` | `boolean` | `true` | Show toolbar with actions. | -| `compact_view` | `boolean` | `false` | Compact view without image. | -| `aqi` | `object` | Optional | Custom entity or attribute for AQI value. | -| `stats` | `object` | Optional | Custom per state stats for your purifier cleaner | -| `actions` | `object` | Optional | Custom actions for your purifier cleaner. | +| Name | Type | Default | Description | +| ----------------- | :-------: | ------------ | ------------------------------------------------ | +| `type` | `string` | **Required** | `custom:purifier-card` | +| `entity` | `string` | **Required** | An entity_id within the `fan` domain. | +| `show_name` | `boolean` | `true` | Show friendly name of the purifier. | +| `show_status` | `boolean` | `true` | Show status of the purifier. | +| `show_speed` | `boolean` | `false` | Show speed of the purifier in the header. | +| `show_preset_mode`| `boolean` | `true` | Show preset mode of the purifier in the header. | +| `show_toolbar` | `boolean` | `true` | Show toolbar with actions. | +| `compact_view` | `boolean` | `false` | Compact view without image. | +| `aqi` | `object` | Optional | Custom entity or attribute for AQI value. | +| `stats` | `object` | Optional | Custom per state stats for your purifier cleaner | +| `actions` | `object` | Optional | Custom actions for your purifier cleaner. | ### `aqi` object diff --git a/src/purifier-card.js b/src/purifier-card.js index 64dbe8a..3879b7f 100644 --- a/src/purifier-card.js +++ b/src/purifier-card.js @@ -44,7 +44,23 @@ class PurifierCard extends LitElement { get entity() { return this.hass.states[this.config.entity]; } + + get showSpeed() { + if (this.config.show_speed === undefined) { + return false; + } + return this.config.show_speed; + } + + get showPresetMode() { + if (this.config.show_preset_mode === undefined) { + return true; + } + + return this.config.show_preset_mode; + } + get showName() { if (this.config.show_name === undefined) { return true; @@ -145,38 +161,40 @@ class PurifierCard extends LitElement { } = this.entity; // TODO handle percentages - if (!speed_list || !(supported_features & SUPPORT_SET_SPEED)) { + if (!this.showSpeed() || !speed_list || !(supported_features & SUPPORT_SET_SPEED)) { return html``; } const selected = speed_list.indexOf(speed); return html` - - - - ${localize(`speed.${speed}`) || speed} - - - ${speed_list.map( - (item) => - html`${localize(`speed.${item}`) || item}` - )} - - + + + ${localize(`speed.${speed}`) || speed} + + + ${speed_list.map( + (item) => + html`${localize(`speed.${item}`) || item}` + )} + + + `; } @@ -185,40 +203,42 @@ class PurifierCard extends LitElement { attributes: { preset_mode, preset_modes, supported_features }, } = this.entity; - if (!preset_modes || !(supported_features & SUPPORT_PRESET_MODE)) { + if (!this.showPresetMode() || !preset_modes || !(supported_features & SUPPORT_PRESET_MODE)) { return html``; } const selected = preset_modes.indexOf(preset_mode); return html` - - - - ${localize(`preset_mode.${preset_mode}`) || preset_mode} - - - + - ${preset_modes.map( - (item) => - html`${localize(`preset_mode.${item}`) || item}` - )} - - + + + ${localize(`preset_mode.${preset_mode}`) || preset_mode} + + + + ${preset_modes.map( + (item) => + html`${localize(`preset_mode.${item}`) || item}` + )} + + + `; } @@ -414,8 +434,8 @@ class PurifierCard extends LitElement { ?more-info="true" >
-
${this.renderSpeed()}
-
${this.renderPresetMode()}
+ ${this.renderSpeed()} + ${this.renderPresetMode()}
${this.renderAQI()}