diff --git a/README.md b/README.md index 3837a50..63e309c 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ This element is **not** all that useful as a card (it can be used for that to), | name | string | **Required** | The name you want to show. | url | string | **Required** | The url you want to open. | icon | string | **Required** | The icon you want to show. +| entity | string | **Optional** | The entity you want to the state from (if defined). ## Installation @@ -47,6 +48,7 @@ Add a custom element in your `ui-lovelace.yaml` name: Home Assistant url: https://www.home-assistant.io/ icon: mdi:home-assistant + entity: sensor.commute_to_home ``` **Give this result:**\ diff --git a/VERSION b/VERSION index 8a9ecc2..6c6aa7c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.1 \ No newline at end of file +0.1.0 \ No newline at end of file diff --git a/example.png b/example.png index bd8c137..bc5cd8a 100644 Binary files a/example.png and b/example.png differ diff --git a/ext-weblink.js b/ext-weblink.js index cce799f..77eacba 100644 --- a/ext-weblink.js +++ b/ext-weblink.js @@ -1,19 +1,26 @@ class ExtWebLink extends HTMLElement { - setConfig(config) { - if (!config || !config.name || !config.url) { - throw new Error('Error in card configuration.'); + set hass(hass) { + if (!this.config.entity) { + var state = ""; + } else { + var state = hass.states[this.config.entity].state; } - this.innerHTML = ` + this.innerHTML =` - - -
- ${config.name} + + +
+ ${this.config.name} +
+
+ ${state}
`; } + setConfig(config) { + this.config = config; + } + getCardSize() { return 1; }