Skip to content

Tutorial #1, Part 4

In this tutorial, you will learn how to create a Swiss Army Knife toolset template from the toolset created in Part 3.

By doing this, you learn something about how to use a toolset template and variables.

Prerequisites

Step 1: Create the yml view file

  • Create view-tutorial-basic-series01-part4.yml in the lovelace/views/sak-tutorial-views/ folder.
  • Add it to the sak-tutorials-dashboard.yaml in your root folder.

Step 2: define the view basics

1
2
3
4
5
6
7
8
title: TUT-01-P4
path: tut-01-p4
panel: false
cards:
- type: vertical-stack
  cards:
    - type: horizontal-stack
      cards:

Step 3: Define card, entities and layout structure

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
title: TUT-01-P4
path: tut-01-p4
panel: false
cards:
- type: vertical-stack
  cards:
    - type: horizontal-stack
      cards:
        - type: 'custom:swiss-army-knife-card'
          aspectratio: 1/2
          entities: 
            - entity: sensor.humidity
              name: Study
            - entity: sensor.temperature
              name: Study
          layout:
            toolsets:

Step 4: Add first toolset using the template

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
title: TUT-01-P4
path: tut-01-p4
panel: false
cards:
- type: vertical-stack
  cards:
    - type: horizontal-stack
      cards:
        - type: 'custom:swiss-army-knife-card'
          aspectratio: 1/2
          entities: 
            - entity: sensor.humidity
              name: Study
            - entity: sensor.temperature
              name: Study
          layout:
            toolsets:
              - toolset: first
                template:
                  name: toolset_tutorial_01_part3
                  variables:
                    - var_entity_index: 0

10-step-tutorial-01-part4-step4

Step 5: Add second toolset using the template

Actions:

  • Add second template
  • Pass entity index 1 as a variable
  • Pass the new toolset cy position as a variable
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
title: TUT-01-P4
path: tut-01-p4
panel: false
cards:
- type: vertical-stack
  cards:
    - type: horizontal-stack
      cards:
        - type: 'custom:swiss-army-knife-card'
          aspectratio: 1/2
          entities: 
            - entity: sensor.humidity
              name: Study
            - entity: sensor.temperature
              name: Study
          layout:
            toolsets:
              - toolset: first
                template:
                  name: toolset_tutorial_01_part3
                  variables:
                    - var_entity_index: 0
              - toolset: second
                template:
                  name: toolset_tutorial_01_part3
                  variables:
                    - var_entity_index: 1
                    - var_toolset_position_cy: 150

10-step-tutorial-01-part4-step5

Done!