Skip to content

Switch Card #1

Visualization

Swiss Army Knife Functional Card Switch Sensor1 D06 Light Off Swiss Army Knife Functional Card Switch Sensor1 D06 Light On
Swiss Army Knife Functional Card Switch Sensor1 D06 Dark Off Swiss Army Knife Functional Card Switch Sensor1 D06 Dark On

This card uses the Material 3 theme D06, TealBlue

Description Aspect Ratio Target Size
A simple switch card with the "switch" on the left side of the card 3/1 Grid with 2 columns
SAK Tool Used for
Circle The half circle, as the left part of the circle is cutoff by the card. Circle is animated, state dependent
Icon Entity Icon. Animated, state dependent. Icon spins in this case
Name Name of Entity
State Secondary Info of Entity
Line Used as vertical separator
Switch The switch. Animated, state dependent

Interaction

Part Description
Switch Used to toggle the binary sensor entity
Other tools All tools connected to an entity do show by default the "more-info" dialog once clicked

Usage

1.0.0-rc.3

Replace example entities with your entities!

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
- type: 'custom:swiss-army-knife-card'
  entities:
    - entity: light.livingroom_light_duo_right_light
      name: 'Switch #1'
      icon: mdi:fan
    - entity: light.livingroom_light_duo_right_light
      secondary_info: last_changed
      format: relative
  layout:
    template:
      name: sak_layout_fce_switch1
      variables:
        - sak_layout_switch_icon_spin: true
        - sak_layout_switch_service: light.toggle
Data Default Required Description
entities The two entities on the card
sak_layout_switch_icon_spin false True to have the icon spin indefinitely
sak_layout_switch_service switch.toggle You can alter the service, if that is needed...

YAML Template Definition

1.0.0-rc.3

Full definition of card
  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
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
sak_layout_fce_switch1:
  template:
    type: layout
    defaults: 
      - sak_layout_switch_icon_spin: false
      - sak_layout_switch_service: switch.toggle
  layout:
    aspectratio: 3/1
    toolsets:
      # ================================================================
      - toolset: half-circle
        position:
          cx: 0                             # Center on cards border 
          cy: 50
        tools:
          # ------------------------------------------------------------
          - type: circle
            position:
              cx: 50
              cy: 50
              radius: 50
            entity_index: 0
            animations:
              - state: 'on'
                styles:
                  circle:
                    fill: var(--theme-sys-color-primary)
              - state: 'off'
                styles:
                  circle:
                    fill: var(--theme-sys-elevation-surface-neutral4)
            styles:
              circle:
                stroke: none
                # transition: fill 1s ease

      # ================================================================
      - toolset: column-icon
        position:
          cx: 25
          cy: 50
        tools:
          # ------------------------------------------------------------
          - type: icon
            position:
              cx: 50
              cy: 50
              align: center
              icon_size: 35
            icon: mdi:fan
            entity_index: 0
            # Define template variable for this icon tool, so it can be
            # processed by a piece of JavaScript ;-)
            # The template engine will replace the variable!
            variables:
              sak_layout_switch_icon_spin : '[[sak_layout_switch_icon_spin]]'
            animations:
              - state: 'on'
                styles:
                  icon:
                    # Use template variable as the source to spin or not.
                    # the config JavaScript parameter is this tools config...
                    animation: >
                      [[[ if (tool_config.variables.sak_layout_switch_icon_spin) return "spin 3s linear infinite";
                          return "";
                      ]]]
                    fill: var(--primary-background-color)
              - state: 'off'
                styles:
                  icon:
                    fill: var(--theme-sys-color-secondary)
            styles:
              icon:
                fill: var(--primary-background-color)
                opacity: 0.9

      # ================================================================
      - toolset: column-name
        position:
          cx: 120
          cy: 50
        tools:
          # ------------------------------------------------------------
          - type: name
            position:
              cx: 50
              cy: 50
            entity_index: 0
            styles:
              name:
                text-anchor: middle
                font-size: 25em
                font-weight: 700
                opacity: 1
          # ------------------------------------------------------------
          - type: state
            position:
              cx: 50
              cy: 80
            entity_index: 1
            show:
              uom: none
            styles:
              state:
                text-anchor: middle
                font-size: 14em
                font-weight: 500
                opacity: 0.7

      # ================================================================
      - toolset: line1
        position:
          cx: 200                           # On 1/3 of card width
          cy: 50
        tools:
          # ------------------------------------------------------------
          - type: line
            position:
              cx: 50
              cy: 50
              orientation: vertical
              length: 50
            styles:
              line:
                fill: var(--primary-text-color)
                opacity: 0.5

      # ================================================================
      - toolset: switch
        position:
          cx: 250                           # On 1/3 of card width
          cy: 50
          scale: 3
        tools:
          # ------------------------------------------------------------
          - type: switch
            position:
              cx: 50
              cy: 50
            entity_index: 0
            user_actions:
              tap_action:
                haptic: light
                actions:
                  - action: call-service
                    service: '[[sak_layout_switch_service]]'