|
6 | 6 | [![custom_updater][customupdaterbadge]][customupdater]
|
7 | 7 | [![License][license-shield]](LICENSE.md)
|
8 | 8 |
|
9 |
| -[![Project Maintenance][maintainer]][maintenance-shield] |
| 9 | +[![Project Maintenance][maintenance-shield]][maintainer] |
10 | 10 |
|
11 | 11 | <!-- [![Discord][discord-shield]][discord] -->
|
12 | 12 | <!-- [![Community Forum][forum-shield]][forum] -->
|
13 | 13 |
|
14 | 14 | <!-- [![Twitter][twitter]][twitter] -->
|
15 |
| -[![Github][maintainer]][github] |
| 15 | +[![Github][github]][maintainer] |
16 | 16 |
|
| 17 | +This card is for [Lovelace](https://www.home-assistant.io/lovelace) on [Home Assistant](https://www.home-assistant.io/). |
| 18 | + |
| 19 | +We all use multiple times the same configuration accros our lovelace configuration and we don't want to change the same things in a hundred places accross our configuration each time we want to modify something. |
| 20 | + |
| 21 | +`decluterring-card` to the rescue!! This card allows you to reuse multiple times the same configuration in your lovelace configuration to avoid repetition. |
| 22 | + |
| 23 | +## Configuration |
| 24 | + |
| 25 | +### Defining your templates |
| 26 | + |
| 27 | +First, you need to define your templates. |
| 28 | + |
| 29 | +The templates are defined in a object at the root of your lovelace configuration. This object needs to be named `decluttering_templates`. |
| 30 | + |
| 31 | +This object needs to contains your templates declaration, each template has a name and can contain variables. A variable needs to be enclosed in double square brackets `[[variable_name]]`. It will later be replaced by a real value when you instanciate a card which uses this template. |
| 32 | + |
| 33 | +Eg in your `lovelace-ui.yaml`: |
| 34 | +```yaml |
| 35 | +resources: |
| 36 | + - url: /local/decluttering-card.js |
| 37 | + type: module |
| 38 | + |
| 39 | +decluttering_templates: |
| 40 | + my_first_template: # This is the name of a template |
| 41 | + type: custom:button-card |
| 42 | + name: '[[name]]' |
| 43 | + icon: 'mdi:[[icon]]' |
| 44 | + |
| 45 | + my_second_template: # This is the name of another template |
| 46 | + type: custom:vertical-stack-in-card |
| 47 | + cards: |
| 48 | + - type: horizontal-stack |
| 49 | + cards: |
| 50 | + - type: custom:button-card |
| 51 | + entity: '[[entity_1]]' |
| 52 | + - type: custom:button-card |
| 53 | + entity: '[[entity_2]]' |
| 54 | +``` |
| 55 | +
|
| 56 | +### Using the card |
| 57 | +
|
| 58 | +| Name | Type | Requirement | Description |
| 59 | +| ---- | ---- | ------- | ----------- |
| 60 | +| type | string | **Required** | `custom:decluttering-card` |
| 61 | +| template | object | **Required** | The template to use from `decluttering_templates` |
| 62 | +| variables | list | **Optional** | List of variables and their value to replace in the `template` |
| 63 | + |
| 64 | +Example which references the previous templates: |
| 65 | +```yaml |
| 66 | +- type: custom:decluttering-card |
| 67 | + template: my_first_template |
| 68 | + variables: |
| 69 | + - name: Test Button |
| 70 | + - icon: fire |
| 71 | +
|
| 72 | +- type: custom:decluterring-card |
| 73 | + template: my_second_template |
| 74 | + variables: |
| 75 | + - entity_1: switch.my_switch |
| 76 | + - entity_2: light.my_light |
| 77 | +``` |
| 78 | + |
| 79 | + |
| 80 | +## Installation |
| 81 | + |
| 82 | +### Step 1 |
| 83 | + |
| 84 | +Save [decluttering-card](https://github.com/custom-cards/decluttering-card/raw/master/dist/decluttering-card.js) to `<config directory>/www/decluttering-card.js` on your Home Assistant instanse. |
| 85 | + |
| 86 | +**Example:** |
| 87 | + |
| 88 | +```bash |
| 89 | +wget https://raw.githubusercontent.com/custom-cards/decluttering-card/master/dist/decluttering-card.js |
| 90 | +mv decluttering-card.js /config/www/ |
| 91 | +``` |
| 92 | + |
| 93 | +### Step 2 |
| 94 | + |
| 95 | +Link `decluttering-card` inside your `ui-lovelace.yaml` or Raw Editor in the UI Editor |
| 96 | + |
| 97 | +```yaml |
| 98 | +resources: |
| 99 | + - url: /local/decluttering-card.js |
| 100 | + type: module |
| 101 | +``` |
| 102 | + |
| 103 | +### Step 3 |
| 104 | + |
| 105 | +Add a custom element in your `ui-lovelace.yaml` or in the UI Editor as a Manual Card |
| 106 | + |
| 107 | +## Troubleshooting |
| 108 | + |
| 109 | +See this guide: [Troubleshooting](https://github.com/thomasloven/hass-config/wiki/Lovelace-Plugins) |
| 110 | + |
| 111 | +## Developers |
| 112 | +Fork and then clone the repo to your local machine. From the cloned directory run |
| 113 | + |
| 114 | +`npm install && npm run build` |
17 | 115 |
|
18 | 116 |
|
19 | 117 | [commits-shield]: https://img.shields.io/github/commit-activity/y/custom-cards/decluttering-card.svg?style=for-the-badge
|
|
0 commit comments