Skip to content

Switch Card #2

Visualization

Swiss Army Knife Functional Card Switch Sensor2 D06 Light Off Swiss Army Knife Functional Card Switch Sensor2 D06 Light On
Swiss Army Knife Functional Card Switch Sensor2 D06 Dark Off Swiss Army Knife Functional Card Switch Sensor2 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 4/1 Grid with 2 columns
SAK Tool Used for
Badge Background of card. Left part is animated, state dependent
Icon Entity Icon. Animated, state dependent
Switch To indicate that this part is the switch. Animated, state dependent
Name Name of Entity
State Secondary Info of Entity

Interaction

Part Description
Left part of badge The whole left part functions as a button to toggle the binary sensor entity
Right part of badge 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
- type: 'custom:swiss-army-knife-card'
  entities:
    - entity: light.livingroom_light_duo_right_light
      name: 'Switch #2a'
    - entity: light.livingroom_light_duo_right_light
      secondary_info: last_changed
      format: relative
  layout:
    template:
      name: sak_layout_fce_switch2
      variables:
        - sak_layout_switch_icon_spin: false
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
147
148
149
150
151
152
153
154
155
156
157
sak_layout_fce_switch2:
  template:
    type: layout
    defaults: 
      - sak_layout_switch_icon_spin: false
      - sak_layout_switch_service: switch.toggle
  layout:
    aspectratio: 4/1
    toolsets:
      # ================================================================
      - toolset: badge-background
        position:
          cx: 150
          cy: 50
        tools:
          - type: badge
            position:
              cx: 50
              cy: 50
              height: 100
              width: 300
              ratio: 25
              radius: 5
              divider: 30
            entity_index: 0
            user_actions:
              tap_action:
                haptic: light
                actions:
                  - action: call-service
                    service: light.toggle
            animations:
              - state: 'on'
                styles:
                  left:
                    fill: var(--theme-sys-color-primary)
              - state: 'off'
                styles:
                  left:                     # Use as filled tonal button (m3)
                    fill: var(--theme-sys-color-secondary-container)
            styles:
              left:
                fill: grey
              right:
                fill: none                  # Show background
                pointer-events: none        # Disable user interaction

      # ================================================================
      - toolset: column-icon
        position:
          cx: 37.5                           # On 12.5% f width
          cy: 50
        tools:
          # ------------------------------------------------------------
          - type: icon
            position:
              cx: 50
              cy: 50
              align: center
              icon_size: 45
            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
                pointer-events: none        # Disable user interaction

      # ================================================================
      - toolset: switch
        position:
          cx: 37.5                           # On 1/3 of card width
          cy: 85
          scale: 2
        tools:
          # ------------------------------------------------------------
          - type: switch
            position:
              cx: 50
              cy: 50
              orientation: 'horizontal'
              track:
                width: 15
                height: 5
                radius: 2.5
              thumb:
                width: 3
                height: 3
                radius: 2.5
                offset: 4.5
            entity_index: 0
            user_actions:
              tap_action:
                haptic: light
                actions:
                  - action: call-service
                    service: '[[sak_layout_switch_service]]'
            styles:
              track:
                --switch-checked-track-color: var(--primary-background-color)
                --switch-unchecked-track-color: var(--theme-sys-color-secondary)
                # --switch-checked-button-color: 
                pointer-events: none
              thumb:
                --thumb-stroke: 'var(--primary-background-color)'
                pointer-events: none

      # ================================================================
      - toolset: column-name
        position:
          cx: 110
          cy: 50
        tools:
          # ------------------------------------------------------------
          - type: name
            position:
              cx: 50
              cy: 37
            entity_index: 0
            styles:
              name:
                text-anchor: start
                font-size: 30em
                font-weight: 700
          # ------------------------------------------------------------
          - type: state
            position:
              cx: 50
              cy: 70
            entity_index: 1
            show:
              uom: none
            styles:
              state:
                text-anchor: start
                font-size: 26em
                font-weight: 500
                opacity: 0.7