Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
[![License][license-shield]](LICENSE.md)
[![hacs_badge](https://img.shields.io/badge/HACS-default-orange.svg?style=for-the-badge)](https://github.com/custom-components/hacs)

Display the options of an `input_select` entity as a clickable list card.
Display the options of an `input_select` or a `select` entity as a clickable list card.
In other words: the content of the dropdown menu is displayed as a card.
The `input_select.select_option` service is called after the user clicks (selects) an option.
The `(input_)select.select_option` service is called after the user clicks (selects) an option.

Some use cases:
* Select with too many options to show in dropdown
Expand All @@ -27,16 +27,16 @@ Select List Card supports Lovelace's Visual Editor. Click the + button to add a

### Options

| Name | Type | Default | Description |
| ------------------ | ------- | ------------ | --------------------------------------------------------------------------- |
| type | string | **required** | `custom:select-list-card` |
| entity | string | **required** | An entity_id within the `input_select` domain. |
| title | string | `` | Card header title |
| icon | string | `` | Card header icon |
| show_toggle | boolean | `false` | Card header toggle |
| truncate | boolean | `true` | Truncate option text to fit 1 line |
| scroll_to_selected | boolean | `true` | Scroll the list to the position of the selected option |
| max_options | number | `5` | Number of options before a scrollbar appears, 0 = no scrollbar |
| Name | Type | Default | Description |
| ------------------ | ------- | ------------ |----------------------------------------------------------------|
| type | string | **required** | `custom:select-list-card` |
| entity | string | **required** | An entity_id within the `input_select` or `select` domain. |
| title | string | `` | Card header title |
| icon | string | `` | Card header icon |
| show_toggle | boolean | `false` | Card header toggle |
| truncate | boolean | `true` | Truncate option text to fit 1 line |
| scroll_to_selected | boolean | `true` | Scroll the list to the position of the selected option |
| max_options | number | `5` | Number of options before a scrollbar appears, 0 = no scrollbar |



Expand Down
8 changes: 4 additions & 4 deletions dist/select-list-card.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/localize/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"common": {
"version": "Version",
"name": "Select list card",
"description": "Display the options of an input_select entity as a clickable list card."
"description": "Display the options of an input_select or a select entity as a clickable list card."
},
"error": {
"missing_entity": "Entity is required",
Expand Down
2 changes: 1 addition & 1 deletion src/localize/languages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"common": {
"version": "Versión",
"name": "Seleccionar tarjeta de la lista",
"description": "Mostrar las opciones de una entidad input_select como una tarjeta de lista en la que se puede hacer clic."
"description": "Mostrar las opciones de una entidad input_select o un select como una tarjeta de lista en la que se puede hacer clic."
},
"error": {
"missing_entity": "Se requiere entidad",
Expand Down
2 changes: 1 addition & 1 deletion src/localize/languages/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"common": {
"version": "Verzió",
"name": "Select list card",
"description": "Az input_select megjelenítése mint egy gördíthető, kattintható lista."
"description": "Az input_select vagy a select megjelenítése mint egy gördíthető, kattintható lista."
},
"error": {
"missing_entity": "Entitás megadása kötelező",
Expand Down
2 changes: 1 addition & 1 deletion src/localize/languages/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"common": {
"version": "Versie",
"name": "Select lijst kaart",
"description": "Toon de opties van een input_select entiteit in een kaart"
"description": "Toon de opties van een input_select of een select entiteit in een kaart"
},
"error": {
"missing_entity": "Het specificeren van een entiteit is verplicht!",
Expand Down
7 changes: 4 additions & 3 deletions src/select-list-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class SelectListCard extends LitElement implements LovelaceCard {
}

public static getStubConfig(hass, entities): object {
const entity = entities.find(item => item.startsWith('input_select'));
const entity = entities.find(item => item.startsWith('input_select') || item.startsWith('select'));
const dummy = hass;
return {
entity: entity || '',
Expand All @@ -60,7 +60,7 @@ export class SelectListCard extends LitElement implements LovelaceCard {
}

public setConfig(config: SelectListCardConfig): void {
if (!config || !config.entity || !config.entity.startsWith('input_select')) {
if (!config || !config.entity || !config.entity.startsWith('input_select') || !config.entity.startsWith('select')) {
throw new Error(localize('error.invalid_configuration'));
}

Expand Down Expand Up @@ -194,7 +194,8 @@ export class SelectListCard extends LitElement implements LovelaceCard {
}

private static setInputSelectOption(hass: HomeAssistant, entity: string, option: string): Promise<any> {
return hass.callService('input_select', 'select_option', {
const service = entity.startsWith('input_select.') ? 'input_select' : 'select';
return hass.callService(service, 'select_option', {
option,
entity_id: entity,
});
Expand Down