Skip to content

Binary Card with Alert #1

Series 2 will be released in 2025!

Visualization

  • Alert "Off"


    Swiss Army Knife Functional Card Binary Sensor With Alert1 D06 Light Off Swiss Army Knife Functional Card Binary Sensor With Alert1 D06 Light Off

  • Alert "On"


    Swiss Army Knife Functional Card Binary Sensor With Alert1 D06 Light On Swiss Army Knife Functional Card Binary Sensor With Alert1 D06 Light On

This card uses the Material 3 theme D06, TealBlue

Description Aspect Ratio Target Size
A card that shows the state of a binary sensor, including an icon as an alert. Card includes battery and link levels, the time of the last state change, and a history chart (per hour of current day) that shows when alerts where detected.

Nice for doors, windows and occupancy alerts.
1/1 Grid with 2 columns

Interaction

Part Description
Card All tools connected to an entity do show by default the "more-info" dialog once clicked

Usage

4.0.1

Replace example entities with your entities!

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
- type: 'custom:swiss-army-knife-card'
  entities:
    - entity: binary_sensor.livingroom_movement_occupancy
      area: Woonkamer
      name: Beweging
    - entity: binary_sensor.livingroom_movement_occupancy
      secondary_info: last_changed
      format: time-24h_date-short
    - entity: sensor.livingroom_movement_battery
      decimals: 0
    - entity: sensor.livingroom_movement_linkquality
      decimals: 0
  layout:
    template:
      name: sak_layout_fce2_binary1
Data Default Required Description
entities The four required entities

YAML Template Definition

4.0.1

Full definition of layout template
  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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
sak_layout_fce2_binary1:
  template:
    type: layout
    defaults: 
      - sak_layout_binary_icon_color: var(--theme-sys-color-primary)
      - sak_layout_binary_icon_color_on: var(--theme-sys-color-error #var(--theme-ref-palette-error50) #var(--theme-sys-color-error-container)
      - sak_layout_binary_icon_animation: flash # none, flash, spin
      - sak_layout_binary_history_color_on: var(--theme-sys-color-error) #var(--theme-sys-color-primary)
      - sak_layout_binary_history_disabled: false
      - sak_layout_battery_colorstops_template: sak_colorstops_battery_level
      - sak_layout_sensor_icon_style: colorstops

  layout:
    aspectratio: 1/1
    toolsets:
      # ==============================================================================
      - toolset: circle-with-icon
        position:
          cx: 20
          cy: 20
        tools:
          # ------------------------------------------------------------
          - type: circle
            position:
              cx: 50
              cy: 50
              radius: 12.5
            entity_index: 0
            animations:
              - state: 'on'
                styles:
                  circle:
                    stroke: var(--theme-sys-color-error)
              - state: 'off'
                styles:
                  circle:
                    # stroke: var(--theme-sys-elevation-surface-neutral10)
                    stroke: '[[sak_layout_binary_icon_color]]'
            styles:
              circle:
                stroke-width: 2em
                # stroke: var(--theme-sys-elevation-surface-neutral10)
                stroke: '[[sak_layout_binary_icon_color]]'
                fill: var(--primary-background-color)

          # ------------------------------------------------------------
          - type: icon
            position:
              cx: 50
              cy: 50
              align: center
              icon_size: 15
            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_binary_icon_animation : '[[sak_layout_binary_icon_animation]]'
            animations:
              - state: 'on'
                styles:
                  icon:
                    # Use template variable as the source to spin, flash or nothing
                    # the config JavaScript parameter is this tools config...
                    animation: >
                      [[[ if (tool_config.variables.sak_layout_binary_icon_animation === "spin") return "spin 3s linear infinite";
                          if (tool_config.variables.sak_layout_binary_icon_animation === "flash") return "flash 2s ease-in-out 5";
                          return "";
                      ]]]
                    fill: '[[sak_layout_binary_icon_color_on]]'
              - state: 'off'
                styles:
                  icon:
                    fill: '[[sak_layout_binary_icon_color]]'
            styles:
              icon:
                fill: '[[sak_layout_binary_icon_color]]'

      # ================================================================
      - toolset: colomn-battery
        position:
          cx: 87.5
          cy: 12.5
        tools:
          # ------------------------------------------------------------
          - type: icon
            position: &icon_pos
              cx: 50
              cy: 50
              align: right
              icon_size: 10
            entity_index: 2
            styles: &icon_styles
              icon:
                fill: var(--primary-text-color)
                opacity: 1
            show:
              style: '[[sak_layout_sensor_icon_style]]'
            colorlist:
              colors:
                - var(--theme-sys-color-secondary)
            colorstops:
              template:
                name: '[[sak_layout_battery_colorstops_template]]'

      # ================================================================
      - toolset: colomn-linkquality
        position:
          cx: 77.5
          cy: 12.5
        tools:
          # ------------------------------------------------------------
          - type: icon
            position: *icon_pos
            entity_index: 3
            styles: *icon_styles
            show:
              style: '[[sak_layout_sensor_icon_style]]'
            colorlist:
              colors:
                - var(--theme-sys-color-secondary)
            colorstops:
              template:
                name: '[[sak_layout_battery_colorstops_template]]'

      # ==============================================================================
      - toolset: area-name
        position:
          cx: 7.5
          cy: 45
        tools:
          # ------------------------------------------------------------
          - type: area
            position:
              cx: 50
              cy: 50
            entity_index: 0
            show:
              ellipsis: 12
            styles: 
              area: 
                text-anchor: start
                font-size: 12em
                font-weight: 700
                opacity: 1
          # ------------------------------------------------------------
          - type: name
            position:
              cx: 50
              cy: 62.5
            entity_index: 0
            show:
              ellipsis: 12
            styles: 
              name: 
                text-anchor: start
                font-size: 10em
                font-weight: 400
                opacity: 0.6

      # ==============================================================================
      - toolset: alert-time-boxes
        position:
          cx: 50
          cy: 75
        tools:
          # ------------------------------------------------------------
          - type: rectex
            position:
              cx: 20
              cy: 50
              width: 25
              height: 18
              radius:
                left: 5
                right: 0
            entity_index: 0
            animations:
              - state: 'on'
                styles:
                  rectex:
                    fill: var(--theme-sys-color-error)
              - state: 'off'
                styles:
                  rectex:
                    fill: var(--theme-sys-elevation-surface-neutral10)
            styles:
              rectex:
                fill: var(--theme-sys-elevation-surface-neutral10)
          # ------------------------------------------------------------
          - type: icon
            position:
              cx: 20
              cy: 50
              align: center
              icon_size: 12.5
            entity_index: 0
            animations:
              - state: 'on'
                icon: mdi:clock-alert-outline
                styles:
                  icon:
                    fill: var(--theme-sys-color-on-error)
              - state: 'off'
                icon: mdi:clock-check-outline
                styles:
                  icon:
                    fill: var(--primary-background-color)
            styles:
              icon:
                fill: '[[sak_layout_binary_icon_color]]'
          # ------------------------------------------------------------
          - type: rectex
            position:
              cx: 64
              cy: 50
              width: 57
              height: 18
              radius:
                left: 0
                right: 5
            entity_index: 0
            animations:
              - state: 'on'
                styles:
                  rectex:
                    fill: var(--theme-sys-elevation-surface-error4)
              - state: 'off'
                styles:
                  rectex:
                    fill: var(--theme-sys-elevation-surface-neutral4)
            styles:
              rectex:
                fill: var(--theme-sys-color-on-error)

          # ------------------------------------------------------------
          - type: state
            position:
              cx: 64 #92
              cy: 50
            # entity_index: 1
            entity_indexes:
              - entity_index: 1
              - entity_index: 0
            animations:
              - state: 'on'
                entity_index: 0
                styles:
                  state:
                    fill: var(--theme-sys-color-error)
              - state: 'off'
                entity_index: 0
                styles:
                  state:
                    fill: var(--theme-sys-elevation-surface-neutral10)
            styles: 
              state:
                # fill: var(--theme-sys-color-error-container)
                fill: var(--theme-sys-color-error)
                font-size: 12em
                text-anchor: middle #end
                # alignment-baseline: middle
                font-weight: 700
              uom:
                # fill: var(--theme-sys-color-error-container)
                fill: var(--theme-sys-color-error)
                alignment-baseline: hanging
                font-weight: 600

      # ==============================================================================
      - toolset: alert-history
        position:
          cx: 50
          cy: 92.5
        tools:
          # ------------------------------------------------------------
          - type: sparkline
            # When disabled, SAK will not use this tool
            disabled: '[[sak_layout_binary_history_disabled]]'
            entity_index: 0
            position:
              cx: 50
              cy: 50
              width: 85
              height: 3
              margin: 0
            period:
              calendar:
                period: day
                offset: 0
                duration:
                  hour: 24
                bins:
                  per_hour: 1
            sparkline:
              show:
                chart_type: barcode
                # chart_variant: stalagmites
              state_map:
                template:
                  name: sak_statemap_binary
              # State value settings
              # - set agg to max to see the binary changes
              # - set lower_bound to -1 to offset 'off' state
              #   the barcode will start wider now, instead of at minimum width
              # - set upper_bound to 1 ('on') to fix upper scale
              state_values:
                aggregate_func: max
                lower_bound: -1
                upper_bound: 1
              barcode:
                column_spacing: 3
                line_width: 0.1
              colorstops_transition: hard
              colorstops:
                colors:
                  - value: 0
                    color: var(--theme-sys-elevation-surface-neutral10)
                  - value: 1
                    color: '[[sak_layout_binary_history_color_on]]'
              styles: 
                tool: 
                  opacity: 1
                barcode_graph:
                  rx: 5
                  ry: 5