Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default button actions overrides #183

Merged
merged 9 commits into from
Nov 5, 2021
48 changes: 32 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,19 @@ This card can be configured using Lovelace UI editor.
5. Choose `entity`.
6. Now you should see the preview of the card!

_Sorry, no support for `actions` and `stats` in visual config yet._
_Sorry, no support for `actions`, `shortcuts` and `stats` in visual config yet._

Typical example of using this card in YAML config would look like this:

```yaml
type: 'custom:vacuum-card'
entity: vacuum.vacuum_cleaner
actions:
start:
service: xiaomi_miio.vacuum_clean_segment
service_data:
entity_id: vacuum.vacuum_cleaner
segments: [16, 20]
stats:
default:
- attribute: filter_left
Expand All @@ -86,7 +92,7 @@ stats:
- attribute: cleaning_time
unit: minutes
subtitle: Cleaning time
actions:
shortcuts:
- name: Clean living room
service: script.clean_living_room
icon: 'mdi:sofa'
Expand All @@ -100,19 +106,20 @@ actions:

Here is what every option means:

| Name | Type | Default | Description |
| -------------- | :-------: | ------------ | ----------------------------------------------------------------------- |
| `type` | `string` | **Required** | `custom:vacuum-card` |
| `entity` | `string` | **Required** | An entity_id within the `vacuum` domain. |
| `map` | `string` | Optional | An entity_id within the `camera` domain, for streaming live vacuum map. |
| `map_refresh` | `integer` | `5` | Update interval for map camera in seconds |
| `image` | `string` | `default` | Path to image of your vacuum cleaner. Better to have `png` or `svg`. |
| `show_name` | `boolean` | `true` | Show friendly name of the vacuum. |
| `show_status` | `boolean` | `true` | Show status of the vacuum. |
| `show_toolbar` | `boolean` | `true` | Show toolbar with actions. |
| `compact_view` | `boolean` | `false` | Compact view without image. |
| `stats` | `object` | Optional | Custom per state stats for your vacuum cleaner |
| `actions` | `object` | Optional | Custom actions for your vacuum cleaner. |
| Name | Type | Default | Description |
| -------------- | :-------: | ------------ | --------------------------------------------------------------------------------------------------------- |
| `type` | `string` | **Required** | `custom:vacuum-card` |
| `entity` | `string` | **Required** | An entity_id within the `vacuum` domain. |
| `map` | `string` | Optional | An entity_id within the `camera` domain, for streaming live vacuum map. |
| `map_refresh` | `integer` | `5` | Update interval for map camera in seconds |
| `image` | `string` | `default` | Path to image of your vacuum cleaner. Better to have `png` or `svg`. |
| `show_name` | `boolean` | `true` | Show friendly name of the vacuum. |
| `show_status` | `boolean` | `true` | Show status of the vacuum. |
| `show_toolbar` | `boolean` | `true` | Show toolbar with actions. |
| `compact_view` | `boolean` | `false` | Compact view without image. |
| `stats` | `object` | Optional | Custom per state stats for your vacuum cleaner |
| `actions` | `object` | Optional | Override default actions behavior with service invocations. |
| `shortcuts` | `object` | Optional | List of shortcuts shown at the right bottom part of the card with custom actions for your vacuum cleaner. |

### `stats` object

Expand All @@ -127,7 +134,16 @@ You can use any attribute of vacuum or even any entity by `entity_id` to display

### `actions` object

You can defined [custom scripts][ha-scripts] for custom actions i.e cleaning specific room and add them to this card with `actions` option.
You can defined service invocations to override default actions behavior. Available actions to override are `start`, `pause`, `resume`, `stop`, `locate` and `return_to_base`.

| Name | Type | Default | Description |
| -------------- | :------: | --------------------------------- | ----------------------------------------------- |
| `service` | `string` | Optional | A service to call, i.e. `script.clean_bedroom`. |
| `service_data` | `object` | `service_data` for `service` call |

### `shortcuts` object

You can defined [custom scripts][ha-scripts] for custom actions i.e cleaning specific room and add them to this card with `shortcuts` option.

| Name | Type | Default | Description |
| -------------- | :------: | --------------------------------- | -------------------------------------------------- |
Expand Down
2 changes: 1 addition & 1 deletion src/localize.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var languages = {
vi,
lt,
ro,
pt
pt,
};

const DEFAULT_LANG = 'en';
Expand Down
3 changes: 3 additions & 0 deletions src/translations/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"error": {
"missing_entity": "Je vyžadováno specifikování entity!"
},
"warning": {
"actions_array": ""
},
"editor": {
"entity": "Entita (Povinný)",
"map": "Mapa (Nepovinný)",
Expand Down
3 changes: 3 additions & 0 deletions src/translations/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"error": {
"missing_entity": "En enhed skal specificeres!"
},
"warning": {
"actions_array": ""
},
"editor": {
"entity": "Enhed (Påkrævet)",
"map": "Map Camera (Valgfrit)",
Expand Down
3 changes: 3 additions & 0 deletions src/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
"error": {
"missing_entity": "Angabe der Entität ist erforderlich!"
},
"warning": {
"actions_array": ""
},
"editor": {
"entity": "Entität (Erforderlich)",
"map": "Map Camera (Optional)",
Expand Down
3 changes: 3 additions & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
"error": {
"missing_entity": "Specifying entity is required!"
},
"warning": {
"actions_array": "WARNING: 'actions' is reserved to override default actions for existing buttons. If your intention was to add additional actions, use the 'shortcuts' option instead."
},
"editor": {
"entity": "Entity (Required)",
"map": "Map Camera (Optional)",
Expand Down
3 changes: 3 additions & 0 deletions src/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
"error": {
"missing_entity": "¡Se requiere especificar una entidad!"
},
"warning": {
"actions_array": "ATENCIÓN: La opcion 'actions' está reservada para sobreescribir el comportamiento por defecto de los botones existentes. Si su intención es añadir acciones adicionales, debe utilizar la opcion 'shortcuts' en su lugar."
},
"editor": {
"entity": "Entidad (Requerido)",
"map": "Map Camera (Opcional)",
Expand Down
3 changes: 3 additions & 0 deletions src/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
"error": {
"missing_entity": "La spécification de l'entité est requise !"
},
"warning": {
"actions_array": ""
},
"editor": {
"entity": "Entité (obligatoire)",
"map": "Caméra de carte (facultatif)",
Expand Down
3 changes: 3 additions & 0 deletions src/translations/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
"error": {
"missing_entity": "יש צורך לציין ישות!"
},
"warning": {
"actions_array": ""
},
"editor": {
"entity": "ישות (נדרש)",
"map": "מצלמת מפה (אפשרי)",
Expand Down
3 changes: 3 additions & 0 deletions src/translations/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"error": {
"missing_entity": "Entitás megadása kötelező!"
},
"warning": {
"actions_array": ""
},
"editor": {
"entity": "Entitás (Kötelező)",
"map": "Térkép kamera (Opcionális)",
Expand Down
3 changes: 3 additions & 0 deletions src/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"error": {
"missing_entity": "È necessario specificare l'entità!"
},
"warning": {
"actions_array": ""
},
"editor": {
"entity": "Entità (Richiesto)",
"map": "Mappa (Opzionale)",
Expand Down
3 changes: 3 additions & 0 deletions src/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"error": {
"missing_entity": "구성요소를 선택해주세요."
},
"warning": {
"actions_array": ""
},
"editor": {
"entity": "구성요소 (필수 요소)",
"map": "지도 (선택 사항)",
Expand Down
3 changes: 3 additions & 0 deletions src/translations/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"error": {
"missing_entity": "Spesifiserende enhet kreves!"
},
"warning": {
"actions_array": ""
},
"editor": {
"entity": "Enhet (påkrevd)",
"map": "Kartkamera (valgfritt)",
Expand Down
3 changes: 3 additions & 0 deletions src/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"error": {
"missing_entity": "Het specificeren van een entiteit is verplicht!"
},
"warning": {
"actions_array": ""
},
"editor": {
"entity": "Entiteit (Verplicht)",
"map": "Kaart Camera (Optioneel)",
Expand Down
3 changes: 3 additions & 0 deletions src/translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"error": {
"missing_entity": "Ustawienie encji jest wymagane!"
},
"warning": {
"actions_array": ""
},
"editor": {
"entity": "Encja (wymagane)",
"map": "Kamera (opcjonalne)",
Expand Down
3 changes: 3 additions & 0 deletions src/translations/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"error": {
"missing_entity": "Entidade obrigatória!"
},
"warning": {
"actions_array": ""
},
"editor": {
"entity": "Entidade (Obrigatório)",
"map": "Mapa (Opcional)",
Expand Down
117 changes: 58 additions & 59 deletions src/translations/ro.json
Original file line number Diff line number Diff line change
@@ -1,61 +1,60 @@
{
"status": {
"cleaning": "Curățare",
"auto": "Curățare Automată",
"spot": "Curățare Punct",
"edge": "Curățare Margini",
"single_room": "Curățare o singură cameră",
"paused": "Repauz",
"idle": "Inactiv",
"stop": "Oprit",
"charging": "Încărcare",
"returning home": "Revenire Acasă",
"returning": "Revenire Acasă",
"docked": "Parcat",
"unknown": "Necunoscut",
"offline": "Deconectat",
"error": "Eroare"
},
"source": {
"gentle": "Blând",
"silent": "Silențios",
"standard": "Standard",
"medium": "Mediu",
"turbo": "Turbo",
"normal": "Normal",
"high": "Ridicat"
},
"common": {
"name": "Card de vid.",
"description": "Un card de vid vă permite să controlați vidul robotului.",
"start": "Curat",
"continue": "Continuă",
"pause": "Repauz",
"stop": "Stop",
"return_to_base": "Parchează",
"locate": "Găsește Aspirator",
"not_available": "Aspiratorul nu este disponibil"
},
"error": {
"missing_entity": "Este necesară specificarea entității!"
},
"editor": {
"entity": "Entitate (Necesar)",
"map": "Camera Harta (Optional)",
"image": "Imagine (Optional)",
"compact_view": "Vizualizare compactă",
"compact_view_aria_label_on": "Pornește vizualizare compactă",
"compact_view_aria_label_off": "Oprește vizualizare compactă compact view off",
"show_name": "Arată Nume",
"show_name_aria_label_on": "Pornește arată nume",
"show_name_aria_label_off": "Oprește arată nume",
"show_status": "Arată Status",
"show_status_aria_label_on": "Pornește arată status",
"show_status_aria_label_off": "Oprește arată status",
"show_toolbar": "Arată bara de instrumente",
"show_toolbar_aria_label_on": "Pornește arată bara de instrumente",
"show_toolbar_aria_label_off": "Oprește arată bara de instrumente",
"code_only_note": "Notă: Acțiunile de setare și opțiunile de statistici sunt disponibile exclusiv folosind Editorul de cod."
}
"status": {
"cleaning": "Curățare",
"auto": "Curățare Automată",
"spot": "Curățare Punct",
"edge": "Curățare Margini",
"single_room": "Curățare o singură cameră",
"paused": "Repauz",
"idle": "Inactiv",
"stop": "Oprit",
"charging": "Încărcare",
"returning home": "Revenire Acasă",
"returning": "Revenire Acasă",
"docked": "Parcat",
"unknown": "Necunoscut",
"offline": "Deconectat",
"error": "Eroare"
},
"source": {
"gentle": "Blând",
"silent": "Silențios",
"standard": "Standard",
"medium": "Mediu",
"turbo": "Turbo",
"normal": "Normal",
"high": "Ridicat"
},
"common": {
"name": "Card de vid.",
"description": "Un card de vid vă permite să controlați vidul robotului.",
"start": "Curat",
"continue": "Continuă",
"pause": "Repauz",
"stop": "Stop",
"return_to_base": "Parchează",
"locate": "Găsește Aspirator",
"not_available": "Aspiratorul nu este disponibil"
},
"error": {
"missing_entity": "Este necesară specificarea entității!"
},
"editor": {
"entity": "Entitate (Necesar)",
"map": "Camera Harta (Optional)",
"image": "Imagine (Optional)",
"compact_view": "Vizualizare compactă",
"compact_view_aria_label_on": "Pornește vizualizare compactă",
"compact_view_aria_label_off": "Oprește vizualizare compactă compact view off",
"show_name": "Arată Nume",
"show_name_aria_label_on": "Pornește arată nume",
"show_name_aria_label_off": "Oprește arată nume",
"show_status": "Arată Status",
"show_status_aria_label_on": "Pornește arată status",
"show_status_aria_label_off": "Oprește arată status",
"show_toolbar": "Arată bara de instrumente",
"show_toolbar_aria_label_on": "Pornește arată bara de instrumente",
"show_toolbar_aria_label_off": "Oprește arată bara de instrumente",
"code_only_note": "Notă: Acțiunile de setare și opțiunile de statistici sunt disponibile exclusiv folosind Editorul de cod."
}
}
3 changes: 3 additions & 0 deletions src/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
"error": {
"missing_entity": "Объект является обязательным полем!"
},
"warning": {
"actions_array": ""
},
"editor": {
"entity": "Объект (Обязательное)",
"map": "Камера для карты (Опциональное)",
Expand Down
3 changes: 3 additions & 0 deletions src/translations/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"error": {
"missing_entity": "Specificera entitet är obligatoriskt!"
},
"warning": {
"actions_array": ""
},
"editor": {
"entity": "Entitet (Obligatoriskt)",
"map": "Kartkamera (Valfritt)",
Expand Down
3 changes: 3 additions & 0 deletions src/translations/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
"error": {
"missing_entity": "Необхідно вказати сутність!"
},
"warning": {
"actions_array": ""
},
"editor": {
"entity": "Сутність (обов'язково)",
"map": "Камера для карти (Додатково)",
Expand Down
Loading