Hey,
I’ve created a new card that helps you declutter your LL config if you use multiple times the same block of cards with small differences (like an entity for example) to display things in LL.
Visit github for installation instructions, up to date documentation and troubleshooting guide
decluttering-card
This card is for Lovelace on Home Assistant.
We all use multiple times the same block of configuration across our lovelace configuration and we don’t want to change the same things in a hundred places across our configuration each time we want to modify something.
declutterring-card
to the rescue!! This card allows you to reuse multiple times the same configuration in your lovelace configuration to avoid repetition and supports variables and default values.
Configuration
Defining your templates
First, you need to define your templates.
The templates are defined in an object at the root of your lovelace configuration. This object needs to be named decluttering_templates
.
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. If a variable is alone on it’s line, enclose it in single quotes: '[[variable_name]]'
.
You can also define default values for your variables in the default
object.
decluttering_templates:
<template_name>
default: # This is optional
- <variable_name>: <variable_value>
- <variable_name>: <variable_value>
[...]
card: # This is where you put your card config (it can be a card embedding other cards)
type: custom:my-super-card
[...]
Example in your lovelace-ui.yaml
:
resources:
- url: /local/decluttering-card.js
type: module
decluttering_templates:
my_first_template: # This is the name of a template
default:
- icon: fire
card:
type: custom:button-card
name: '[[name]]'
icon: 'mdi:[[icon]]'
my_second_template: # This is the name of another template
card:
type: custom:vertical-stack-in-card
cards:
- type: horizontal-stack
cards:
- type: custom:button-card
entity: '[[entity_1]]'
- type: custom:button-card
entity: '[[entity_2]]'
Using the card
Name | Type | Requirement | Description |
---|---|---|---|
type | string | Required | custom:decluttering-card |
template | object | Required | The template to use from decluttering_templates
|
variables | list | Optional | List of variables and their value to replace in the template
|
Example which references the previous templates:
- type: custom:decluttering-card
template: my_first_template
variables:
- name: Test Button
- icon: arrow-up
- type: custom:decluttering-card
template: my_first_template
variables:
- name: Default Icon Button
- type: custom:decluterring-card
template: my_second_template
variables:
- entity_1: switch.my_switch
- entity_2: light.my_light