Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: update the documentation to explain where the templates should b… #26

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,74 @@ 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`.

#### With the yaml mode

> [!WARNING]
> The path are put here as examples. you might want to change them to match your needs.
>
> Also, you need to understand the principles of yaml and Home Assistant's includes to fully understand this version.

In your lovelace-dashboard.yaml file, you will find the following lines, adjusted to your needs:

```yaml
ui-example:
mode: yaml
title: My Example Dsahboard
icon: mdi:face-man
require_admin: false
show_in_sidebar: true
filename: lovelace/ui/ui-example.yaml
```

This will create a new dashboard named `ui-example` with the content of the file `lovelace/ui/ui-example.yaml`. This file name is very important because it is the place where you are going to put your templates.

The file will look like this:

```yaml
title: "My Example Dashboard"

views:
- !include ../views/example/first-view.yaml

streamline_templates: !include_dir_named ../streamline_templates/
```

or, if you want to inline all your templates:

```yaml
title: "My Example Dashboard"

views:
- !include ../views/example/first-view.yaml

streamline_templates:
my_first_template:
# ...

my_second_template:
# ...
```

#### With the UI Mode

> [!WARNING]
> Even if you are using the UI mode, you need to understand the principles of yaml to make streamline-card work.

When editing your dashboard in UI mode, you can find an option to edit it as a yaml file. For this, open the three dots menu at the top right of the dashboard and click on `Raw configuration editor`. This will open a panel where you can edit your dashboard as a yaml file.

In this file, just add at the top of the file the following lines:

```yaml
streamline_templates:
my_first_template:
# ...

my_second_template:
# ...
```

Next, you can get back to the UI mode and add new streamline-cards to your dashboard with the UI Editor.

#### Basic 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]]'`.
Expand Down