From 5f8ce65aec62475f18b6f9060beaadb53b4c5955 Mon Sep 17 00:00:00 2001
From: pkoehlers <50806567+pkoehlers@users.noreply.github.com>
Date: Sat, 8 Jan 2022 09:58:41 +0100
Subject: [PATCH] feat: Add link functionality to shortcuts
---
README.md | 7 ++++---
src/vacuum-card.js | 20 +++++++++++++-------
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
index fb29d5f7..c469dc16 100644
--- a/README.md
+++ b/README.md
@@ -143,14 +143,15 @@ You can defined service invocations to override default actions behavior. Availa
### `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.
+You can define [custom scripts][ha-scripts] for custom actions i.e cleaning specific room and add them to this card with `shortcuts` option by using the `service` and `service_data` options or create a clickable link with the `link` option:
| Name | Type | Default | Description |
| -------------- | :------: | --------------------------------- | -------------------------------------------------- |
| `name` | `string` | Optional | Friendly name of the action, i.e. `Clean bedroom`. |
-| `service` | `string` | Optional | A service to call, i.e. `script.clean_bedroom`. |
| `icon` | `string` | Optional | Any icon for action button. |
-| `service_data` | `object` | `service_data` for `service` call |
+| `service` | `string` | Optional | A service to call, i.e. `script.clean_bedroom`. |
+| `service_data` | `object` | `service_data` for `service` call | |
+| `link` | `string` | Optional | Creates a web link, i.e. `https://vacuum.webui` |
## Animations
diff --git a/src/vacuum-card.js b/src/vacuum-card.js
index ee67e2a9..85335901 100755
--- a/src/vacuum-card.js
+++ b/src/vacuum-card.js
@@ -455,13 +455,19 @@ class VacuumCard extends LitElement {
const { shortcuts = [] } = this.config;
const buttons = shortcuts.map(
- ({ name, service, icon, service_data }) => {
- const execute = () => {
- this.callAction({ service, service_data });
- };
- return html``;
+ ({ name, service, icon, service_data, link }) => {
+ if (link) {
+ return html``;
+ } else {
+ const execute = () => {
+ this.callAction({ service, service_data });
+ };
+ return html``;
+ }
}
);