From 192e3d1f08cd4fb2859a9671d07dd6a12718a21b Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 21 Jun 2018 17:31:02 -0400 Subject: [PATCH] Update custom card example --- docs/lovelace_custom_card.md | 139 ++++++++++++++++++++--------------- 1 file changed, 78 insertions(+), 61 deletions(-) diff --git a/docs/lovelace_custom_card.md b/docs/lovelace_custom_card.md index 01f4a61d..41d08a84 100644 --- a/docs/lovelace_custom_card.md +++ b/docs/lovelace_custom_card.md @@ -12,84 +12,101 @@ You're not just limited to the cards that we decided to include in the Lovelace ## Defining your card -```html - - -``` - -## Loading your card in the frontend - -Home Assistant is currently transitioning away from HTML imports but have not finished yet. To include your custom card, you will have to create an HTML file that will be imported by the frontend. Create a new HTML file in `/www/custom-card.html`. - -Then update your configuration to be like this: - -```yaml -# configuration.yaml example -frontend: - extra_html_url: - - "/local/wired-cards.html" +customElements.define('wired-toggle-card', WiredToggleCard); ``` ## Referencing your new card -To use a custom card, set the card type in `ui-lovelace.yaml` to `custom:`. In the following example we're going to use a custom card which is registered as custom element `example-card`. Any other config defined with your card will be made available as the `config` property to your card. +In our example card we defined a card with the tag `wired-toggle-card` (see last line), so our card type will be `custom:wired-toggle-card`. And because you created the file in your `/www` directory, it will be accessible in your browser via the url `/local/`. ```yaml -# ui-lovelace.yaml example +# Example ui-lovelace.yaml +resources: + - url: /local/wired-cards.js + type: module views: - name: Example cards: - - type: 'custom:example-card' - entity_id: input_boolean.switch_ac_kitchen + - type: "custom:wired-toggle-card" + entities: + - input_boolean.switch_ac_kitchen + - input_boolean.switch_ac_livingroom + - input_boolean.switch_tv ``` - -## Other examples - - - Example card using [WiredJS](https://wiredjs.com) - [source](https://gist.github.com/balloob/d86afbecab97b34f9eaeb33b0c0be424)