-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5d08ab9
Showing
14 changed files
with
960 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
github: [brunosabot] | ||
patreon: brunosabot | ||
buy_me_a_coffee: brunosabot1 | ||
custom: ['https://paypal.me/BrunoSabot?country.x=FR&locale.x=fr_FR'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
name: Bug report | ||
about: Help me improving Streamline Card by reporting any issue you encounter | ||
title: "" | ||
labels: tracking issue, needs triage | ||
assignees: brunosabot | ||
--- | ||
|
||
For any feature request you can open a new discussion here: | ||
https://github.com/brunosabot/streamline-card/discussions/categories/ideas | ||
|
||
For any question you can open a new discussion here: | ||
https://github.com/brunosabot/streamline-card/discussions/categories/q-a | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
|
||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**YAML** | ||
If applicable, add any relevant YAML code. | ||
|
||
```yaml | ||
Your code here | ||
``` | ||
|
||
**Informations (please complete the following information):** | ||
|
||
- OS: [e.g. iOS] | ||
- Browser/App: [e.g. chrome, safari] | ||
- Bubble Card version: [e.g. 2.0.4] | ||
- Home Assistant version: [e.g. 2024.6.4] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. | ||
|
||
Thank you! 🍻 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Validation of the plugin | ||
|
||
on: | ||
push: | ||
pull_request: | ||
schedule: | ||
- cron: "0 0 * * *" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
validate-plugin: | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: Code Checkout | ||
uses: "actions/checkout@v4" | ||
- name: HACS Validation | ||
uses: "hacs/action@main" | ||
with: | ||
category: "plugin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
.env.*.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Bruno Sabot | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# Streamline Card | ||
|
||
Streamline your Lovelace configuration with with a card template system. | ||
|
||
This card is for [Lovelace](https://www.home-assistant.io/lovelace) on [Home Assistant](https://www.home-assistant.io/). | ||
|
||
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. | ||
|
||
`streamline-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. | ||
|
||
`streamline-card` is an adaptation of `decluttering-card` by [@brunosabot](https://github.com/brunosabot) which is not maintained anymore. | ||
|
||
## Installation | ||
|
||
### With HACS (Recommended) | ||
|
||
This method allows you to get updates directly on the HACS main page | ||
|
||
1. If HACS is not installed yet, download it following the instructions on [https://hacs.xyz/docs/setup/download](https://hacs.xyz/docs/setup/download/) | ||
2. Proceed to the HACS initial configuration following the instructions on [https://hacs.xyz/docs/configuration/basic](https://hacs.xyz/docs/configuration/basic) | ||
3. On your sidebar go to `HACS` > `Frontend` | ||
4. Click on the `+` button at the bottom right corner | ||
5. Now search for `Streamline Card` and then click on the button at the bottom right corner to download it | ||
6. Go back on your dashboard and click on the icon at the right top corner then on `Edit dashboard` | ||
7. You can now click on `Add card` in the bottom right corner and search for `Streamline Card` | ||
|
||
If it's not working, try to clear your browser cache. | ||
|
||
### Without HACS | ||
|
||
1. Download these files: [streamline-card.js](https://raw.githubusercontent.com/brunosabot/streamline-card/main/dist/streamline-card.js) | ||
2. Add these files to your `<config>/www` folder | ||
3. On your dashboard click on the icon at the right top corner then on `Edit dashboard` | ||
4. Click again on that icon and then click on `Manage resources` | ||
5. Click on `Add resource` | ||
6. Copy and paste this: `/local/streamline-card.js?v=1` | ||
7. Click on `JavaScript Module` then `Create` | ||
8. Go back and refresh your page | ||
9. You can now click on `Add card` in the bottom right corner and search for `streamline Card` | ||
10. After any update of the file you will have to edit `/local/streamline-card.js?v=1` and change the version to any higher number | ||
|
||
If it's not working, just try to clear your browser cache.` | ||
|
||
## 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 `streamline_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 instantiate 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. | ||
|
||
For a card: | ||
|
||
```yaml | ||
streamline_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 | ||
[...] | ||
``` | ||
|
||
For a Picture-Element: | ||
|
||
```yaml | ||
streamline_templates: | ||
<template_name> | ||
default: # This is optional | ||
- <variable_name>: <variable_value> | ||
- <variable_name>: <variable_value> | ||
[...] | ||
element: # This is where you put your element config | ||
type: icon | ||
[...] | ||
``` | ||
|
||
Example in your `lovelace-ui.yaml`: | ||
|
||
```yaml | ||
resources: | ||
- url: /local/streamline-card.js | ||
type: module | ||
|
||
streamline_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:streamline-card` | | ||
| template | object | **Required** | The template to use from `streamline_templates` | | ||
| variables | list | **Optional** | List of variables and their value to replace in the `template` | | ||
|
||
Example which references the previous templates: | ||
|
||
```yaml | ||
- type: custom:streamline-card | ||
template: my_first_template | ||
variables: | ||
- name: Test Button | ||
- icon: arrow-up | ||
- type: custom:streamline-card | ||
template: my_first_template | ||
variables: Default Icon Button | ||
- type: custom:streamline-card | ||
template: my_second_template | ||
variables: | ||
- entity_1: switch.my_switch | ||
- entity_2: light.my_light | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "Streamline Card", | ||
"content_in_root": false, | ||
"render_readme": true, | ||
"filename": "streamline-card.js", | ||
"homeassistant": "2023.9.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "streamline-card", | ||
"version": "0.0.1", | ||
"description": "", | ||
"type": "module", | ||
"main": "src/streamline-card.js", | ||
"scripts": { | ||
"dev": "vite build --watch --mode development", | ||
"build": "vite build", | ||
"preview": "vite preview" | ||
}, | ||
"author": "", | ||
"license": "MIT", | ||
"dependencies": { | ||
"vite": "^5.3.5" | ||
} | ||
} |
Oops, something went wrong.