Skip to content

About

Timer Card for all switches and for their assigned time sensors

Topics

Resources

Stars

21 stars

Watchers

1 watching

Forks

Latest commit

 

History

89 Commits

Folders and files

Repository files navigation

Buy Me a Coffee

Switch and Timer Bar Card

Downloads hacs_badge GitHub Release License Home Assistant Maintenance GitHub Stars GitHub Issues

A flexible Lovelace card for Home Assistant that lets you control a device, manage an associated timer, and track its progress with a visual bar. Perfect for automations that need timing and status tracking—irrigation, pool pumps, blinds, gates, media players, charging stations, and more. You can even turn_off your automations or your input_boolean entity for spesific time that you want!

image1

✨ Features

  • Multi‑domain control: The card supports switch, light, fan, input_boolean, automation, siren, cover, valve, lock, and media_player entities.
  • Device‑aware Start/Stop: The card sends the right service for each domain (see mapping below).
  • Auto turn‑off at timer end: When the timer finishes, the card can stop the device automatically. In this (direct‑control) mode the switch‑off is performed by your browser, so for unattended use — when no dashboard is open — automation mode is recommended (see the note below).
  • Optional automation mode: Use timer_and_entity_connected_via_automation: true if your own automations already link the timer ↔️ device; the card then avoids extra on/off actions.
  • Smarter status: “Active” is interpreted sensibly per domain (e.g., covers consider closed as active; locks consider unlocked as active; media players consider playing/on as active).
  • Shared-device aware: Use the same controllable entity across multiple cards (e.g., one boiler with 15/30/60-minute boost buttons). Each card tracks its own timer independently and coordinates so an active timer is not interrupted by another card.
  • Editable duration: Optionally let users tap the total time on the card to change the timer duration on the fly. The value is saved per device, so each user can have their own preferred boost length. You can also set a YAML default to override the timer helper's configured duration without touching the helper.
  • Last run & Next run sensors: Show up to two sensors per entity (for example, when the device last finished and when it will run next). Each sensor can display its state or one of its attributes, with its own label, icon, and position.
  • Native value formatting: Sensor values are formatted by Home Assistant itself. Date/time values are shown as localized, auto‑updating relative time (e.g. "5 minutes ago").
  • Battery indicator: Optionally show a device's battery level in a smaller font next to the entity name, from any battery entity (its state is read) or a literal value.
  • Four‑tab visual editor: Each entity is configured through Entity, Timer, Sensors, and Design tabs, with a colored marker per entity so they are easy to tell apart.
  • Theme & card-mod compatible: The card is wrapped in a standard ha-card, so themes and card-mod can fully customize its appearance (transparent background, custom shadows, padding, etc.).

✅ Supported domains & service mapping

Domain Start does Stop does Active means
switch switch.turn_on switch.turn_off state is on
light light.turn_on light.turn_off state is on
siren siren.turn_on siren.turn_off state is on
fan fan.turn_on fan.turn_off state is on
automation automation.turn_on automation.turn_off state is on
input_boolean input_boolean.turn_on input_boolean.turn_off state is on
cover cover.close_cover cover.open_cover position is closed
valve valve.open_valve valve.close_valve state is open
lock lock.unlock lock.lock state is unlocked
media_player media_player.media_play (fallback turn_on) media_player.media_stop (fallback turn_off) state is playing/on

Note: When timer_and_entity_connected_via_automation: true, the card will not call these services on either Start or Stop; it will only start/finish the timer and display progress. Your automations must handle turning the device on/off.


📋 Prerequisites

  • Home Assistant
  • Timer integration and a device entity from one of the supported domains.
  • (Optional) Sensor for “last run” to show when the device last completed. Commonly a template sensor updated by an automation.
  • If using automation mode (timer_and_entity_connected_via_automation: true): create automations that (1) turn the device on when the timer starts and (2) turn it off when the timer finishes or is stopped.

🚀 Installation

HACS (Recommended)

  1. Go to HACS → Frontend.
  2. Open the three‑dot menu → Custom repositories.
  3. Add this repo as Lovelace/Frontend.
  4. Find Switch and Timer Bar Card and click Install.

⚙️ UI EDITOR

image8

The top of the editor has a single Card Header field. Every entity is then configured through four tabs, and each entity card shows a colored dot (with a matching border) so you can tell them apart at a glance:

  • Entity — display name and the controlled entity.
  • Timer — timer entity, Automation Link, default‑duration override, editable duration, and the time‑format strings.
  • Sensors — the Last run / Next run sensors and the Battery indicator. A ? button next to Last Run Sensor opens a popup that shows how to create a trigger‑based template sensor and lets you copy the YAML.
  • Design — button position, colors, icons, and status labels for that entity.

Global colors / icons / labels / button_position are no longer shown in the visual editor; styling is done per entity in the Design tab. If you set these keys globally in YAML, the card still reads and applies them.

⚙️ Configuration

Add the card via Add Card → Manual and paste YAML.

Options

Option Description Type Required Default
type Must be custom:switch-and-timer-bar-card. string YES
title Header text shown at the top of the card (labeled "Card Header" in the editor). string No
entities List of devices to display. list YES
switch The entity_id of the device to control. Supported domains: switch, light, fan, input_boolean, automation, siren, cover, valve, lock, media_player. string YES
timer The timer entity associated with the device. string No
last_run_sensor Per-entity. Sensor shown as the "last run" value. Object fields: entity (required), attribute (optional), name, icon, position (left/center/right). See the Last run & Next run sensors section. object No
next_run_sensor Per-entity. Optional second sensor (e.g. "next run"). Same fields as last_run_sensor. object No
battery Per-entity. Battery level shown in a smaller font next to the entity name. Accepts an entity_id (its state is read) or a literal number. Hidden when empty/non-numeric. string / number No
timer_and_entity_connected_via_automation Set true (default) if your own automations handle turning the device on/off when the timer starts/finishes/is stopped. Set false if you want the card to call device services itself. boolean No true
duration Optional. Overrides the timer helper's configured duration when starting from this card. Accepts "HH:MM:SS" (e.g., "00:10:00") or a number of seconds. Leave empty to use the helper's default. string / number No
editable_duration If true, the user can tap the total time on the card to change the duration. The value is saved in the browser (per device). boolean No false
button_position Button side, left or right. Set per-entity (Design tab) or globally in YAML. string / object No left
colors Color overrides. Set per-entity (Design tab); also accepted globally in YAML. Keys: on, ready, unavailable, button_start, button_stop, icon, progress_fill. object No
icons Icon overrides. Keys: start, stop. Per-entity (Design tab) or global YAML. object No
labels Text overrides. Keys: status_on, status_ready, status_unavailable, time_format_zero, time_unit_minutes, time_unit_seconds (plus global edit_duration_* / start_confirm_* strings). Per-entity (Design tab) or global YAML. object No

Legacy sensor: an older per-entity sensor: string is still rendered for backward compatibility and is automatically migrated to last_run_sensor the first time you open the card in the visual editor.


🧩 Option timer_and_entity_connected_via_automation

Default value is true.

true — automation mode (recommended for unattended use). You link the timer and the device with your own automation/script. The card only starts the timer (which triggers your automation) and shows progress — it does not switch the device on/off itself. Because the timer runs on the Home Assistant server, the switch‑off fires reliably even when no browser or dashboard is open. As a bonus, you can reuse one timer for several entities (e.g. six entities from different domains that all need a 10‑minute timer can share a single timer).

false — direct control. You don't need any automation: the card starts the timer and turns the device on at the same time, and turns it off automatically when the timer finishes.

⚠️ Direct control runs in your browser. The auto‑off is performed by the card, so if no dashboard is open when the timer ends (tab/browser closed, or the mobile companion app was killed), the device will not switch off at that moment. For unattended setups, use automation mode instead.

To keep direct‑control mode safe, it includes:

  • A confirmation dialog each time you start a timer in this mode, explaining the browser limitation (choose Cancel or Start anyway).
  • Auto‑recovery on reopen — when you open the dashboard again, the card detects a timer that already finished while you were away and switches the device off then.
  • An inline warning in the visual editor when Automation Link is turned off.

Automation example (for automation mode)

Turn the device on when its timer starts and off when it finishes:

alias: Zone 1 — timer controls switch
triggers:
  - trigger: event
    event_type: timer.started
    event_data:
      entity_id: timer.zone_1
    id: started
  - trigger: event
    event_type: timer.finished
    event_data:
      entity_id: timer.zone_1
    id: finished
actions:
  - choose:
      - conditions: "{{ trigger.id == 'started' }}"
        sequence:
          - action: switch.turn_on
            target:
              entity_id: switch.zone_1
      - conditions: "{{ trigger.id == 'finished' }}"
        sequence:
          - action: switch.turn_off
            target:
              entity_id: switch.zone_1
mode: queued

If a timer finishes while Home Assistant itself is restarting, the timer.finished event won't fire after startup — this is a Home Assistant limitation, not specific to this card.

🔁 Multiple timers for the same device

You can also use the same controllable entity across multiple cards, each with its own timer. The classic use case is a heating boost panel: one boiler with 15/30/60-minute buttons, each driven by its own timer.

The card detects this setup automatically (no extra config needed) and:

  • Each card reflects its own timer — Start on one card does not make the others appear active.
  • The progress bar, status badge, and Start/Stop button each follow that card's own timer.
  • If multiple boosts overlap, finishing one does not turn the device off while another timer is still running. The device is turned off only when the last active timer finishes (or you stop it).
  • Works with both timer_and_entity_connected_via_automation: true and false. Pick whichever matches your setup.

A full YAML example is in the "Multiple timers for the same device" section below.

⏱️ Setting and editing the duration

By default, the card uses the duration configured in your timer helper. v1.4.0 adds two ways to override this without editing the helper:

image8

YAML default (duration)

Set a fixed duration in the card config. Useful when you want one timer helper to behave differently in different cards (for example, the same timer.boiler used as a "15 minute boost" in one card and "30 minute boost" in another).

entities:
  - name: 15 Minute Boost
    switch: switch.boiler
    timer: timer.boost
    duration: "00:15:00"   # or 900 (seconds)
  - name: 30 Minute Boost
    switch: switch.boiler
    timer: timer.boost
    duration: "00:30:00"

When you press Start, the card starts the timer with this duration. The helper itself stays untouched.

Live editing from the card (editable_duration)

Set editable_duration: true to make the total time on the card tappable. A dialog opens with hours / minutes / seconds inputs.

entities:
  - name: Heating Boost
    switch: switch.boiler
    timer: timer.boost
    editable_duration: true
  • The new value is saved in the browser (localStorage) per device, so it persists across page reloads.
  • The tap target is only active while the timer is idle — running timers are not disturbed.
  • A "Reset to default" button is shown when an override is active. It removes the saved value and falls back to the YAML default or the helper default.
  • You can also set editable_duration: true globally for all entities, and override per-entity if needed.

Priority order

When the card starts a timer, it uses the first available value:

  1. User-set value from the editable-duration dialog (if any)
  2. YAML duration on the entity (if any)
  3. Timer helper's own configured duration

🔋 Battery percentage indicator

Add an optional battery value to any entity to show its battery level in a smaller font right next to the entity name. When it isn't provided (or the value is empty/non‑numeric), nothing is shown.

You can provide either a battery entity_id (the card reads its state) or a literal number:

entities:
  - name: Zone 1
    switch: switch.zone_1
    timer: timer.zone_1
    battery: sensor.zone_1_battery   # reads the sensor's state, e.g. 87 → "87%"
  - name: Zone 2
    switch: switch.zone_2
    timer: timer.zone_2
    battery: 55                      # literal value → "55%"
  • The value is rounded to a whole number and displayed as NN%.
  • If battery is omitted, empty, or non‑numeric (e.g. unavailable), the indicator stays hidden.
  • You can also set it from the visual editor: open an entity and turn on Battery on the Sensors tab, then pick any entity whose state is the battery level.

🎨 Theming & card-mod compatibility

The card uses a standard ha-card wrapper, so it honours your active theme automatically and can be customized further with card-mod.

Example — transparent card with no shadow:

type: custom:switch-and-timer-bar-card
title: My Card
entities:
  - switch: switch.zone_1
    timer: timer.zone_1
card_mod:
  style: |
    ha-card {
      background: rgba(0, 0, 0, 0.1);
      box-shadow: none;
    }
    .entity-card {
      background: transparent !important;
    }

The ha-card selector controls the outer shell. The .entity-card selector controls each entity row inside.


📟 Last run & Next run sensors

Each entity can show up to two sensors below the timer row: a Last run sensor and a Next run sensor. Both are optional and fully independent.

entities:
  - name: Zone 1
    switch: switch.zone_1
    timer: timer.zone_1
    last_run_sensor:
      entity: sensor.zone_1_last_run
      name: Last run          # label shown on the card
      icon: mdi:history
      position: left          # left | center | right
    next_run_sensor:
      entity: sensor.zone_1_next_run
      name: Next run
      icon: mdi:update
      position: right

Each sensor accepts:

Field Description
entity Required. The entity to read.
attribute Optional. Show one of the entity's attributes instead of its state.
name Label shown next to the value on the card.
icon Icon shown before the label (any mdi: icon).
position Where the chip sits in its row: left, center, or right.

Formatting: values are rendered with Home Assistant's own formatting, so units and device‑class formatting match the rest of your dashboard. Timestamp / date values are shown as localized, auto‑updating relative time (for example "5 minutes ago"). This replaces the old last_on_* label strings, which are no longer used.

In the visual editor, open an entity → Sensors tab to enable each sensor. The ? button next to Last Run Sensor opens the helper below and lets you copy the template‑sensor YAML.

Legacy config: a single per‑entity sensor: string still works (it is shown as the "last run" value) and is automatically migrated to last_run_sensor when you open the card in the editor.


🧪 How to create a trigger‑based sensor

To show "last run" on the card, you can create a template sensor that updates when the timer finishes (works for all domains) and/or when the device turns off. Example below uses both a timer.finished event and a switch turning off; adapt the second trigger for your domain if needed.

This same example is available inside the editor: open an entity → Sensors tab → the ? button next to Last Run Sensor, then Copy YAML.

template:
  - trigger:
      - trigger: event
        event_type: timer.finished
        event_data:
          entity_id: timer.zone_1_timer
      - trigger: state
        entity_id: switch.zone_1   # For non-switch domains, change to your entity
        from: 'on'
        to: 'off'
    sensor:
      - name: zone_1_is_finished
        state: "{{ now().timestamp() | as_datetime }}"

📦 Examples with global defaults

type: custom:switch-and-timer-bar-card
title: ''
button_position: left
colors:
  on: '#2196F3'
  ready: '#4CAF50'
  unavailable: '#F44336'
  button_start: '#4CAF50'
  button_stop: '#2196F3'
  icon: 'white'
  progress_fill: '#2196F3'
icons:
  start: 'mdi:play'
  stop: 'mdi:stop'
labels:
  status_on: 'Watering'
  status_ready: 'Ready'
  status_unavailable: 'Unavailable'
  time_format_zero: '0m 00s'
  time_unit_minutes: 'm'
  time_unit_seconds: 's'
entities:
  - name: Zone 1
    switch: switch.zone_1
    timer: timer.zone_1_timer
    last_run_sensor:
      entity: sensor.zone_1_is_finished
  - name: Zone 2
    switch: cover.lounge_blind
    timer: timer.lounge_blind
    last_run_sensor:
      entity: sensor.lounge_blind_last_run

image3 image4


Another Example

type: custom:switch-and-timer-bar-card
title: Irrigation & Control Panel
button_position: left
colors:
  "on": "#2196F3"
  ready: "#4CAF50"
  unavailable: "#F44336"
  button_start: "#4CAF50"
  button_stop: "#2196F3"
  icon: "#FFFFFF"
  progress_fill: "#2196F3"
icons:
  start: mdi:play
  stop: mdi:stop
labels:
  status_on: Running
  status_ready: Ready
  status_unavailable: Unavailable
  time_format_zero: 0m 00s
  time_unit_minutes: m
  time_unit_seconds: s
entities:
  - name: Zone 1
    switch: switch.zone_1
    timer: timer.zone_1_timer
    last_run_sensor:
      entity: sensor.zone_1_is_finished
    timer_and_entity_connected_via_automation: true
    button_position: left
    colors:
      "on": "#1E88E5"
      ready: "#43A047"
      unavailable: "#E53935"
      button_start: "#43A047"
      button_stop: "#1E88E5"
      icon: "#FFFFFF"
      progress_fill: "#1E88E5"
    icons:
      start: mdi:play-circle
      stop: mdi:stop-circle
    labels:
      status_on: Watering
      status_ready: Ready
      status_unavailable: No Signal
      time_format_zero: 0m 00s
      time_unit_minutes: m
      time_unit_seconds: s
  - name: Zone 2
    switch: switch.zone_2
    timer: timer.zone_2_timer
    last_run_sensor:
      entity: sensor.zone_2_is_finished
    timer_and_entity_connected_via_automation: true
    button_position: right
    colors:
      button_start: "#7CB342"
      button_stop: "#3949AB"
      progress_fill: "#3949AB"
    icons:
      start: mdi:play
      stop: mdi:stop
    labels:
      status_on: Zone 2 On
      status_ready: Zone 2 Ready
  - name: Zone 3
    switch: switch.zone_3
    timer: timer.zone_3_timer
    last_run_sensor:
      entity: sensor.zone_3_is_finished
    timer_and_entity_connected_via_automation: true
    button_position: left
    colors:
      "on": "#00ACC1"
      ready: "#8BC34A"
      unavailable: "#D32F2F"
      progress_fill: "#00ACC1"
    icons:
      start: mdi:sprinkler-variant
      stop: mdi:sprinkler
    labels:
      status_on: Irrigating
      status_ready: Idle
  - name: Zone 4
    switch: switch.zone_4
    timer: timer.zone_4_timer
    last_run_sensor:
      entity: sensor.zone_4_is_finished
    timer_and_entity_connected_via_automation: true
    button_position: right
    colors:
      button_start: "#FFB300"
      button_stop: "#5E35B1"
      icon: "#FFFFFF"
    icons:
      start: mdi:play-outline
      stop: mdi:stop-outline
    labels:
      status_on: Zone 4 Running
      status_ready: Zone 4 Ready
      status_unavailable: Zone 4 Unavailable
  - name: Zone 5
    switch: switch.zone_5
    timer: timer.zone_5_timer
    last_run_sensor:
      entity: sensor.zone_5_is_finished
    timer_and_entity_connected_via_automation: false
    button_position: left
    colors:
      "on": "#EF6C00"
      button_start: "#EF6C00"
      button_stop: "#616161"
      progress_fill: "#EF6C00"
    icons:
      start: mdi:power
      stop: mdi:power-off
    labels:
      status_on: Manual ON
      status_ready: Manual Ready
  - name: Zone 6
    switch: switch.zone_6
    timer: timer.zone_6_timer
    last_run_sensor:
      entity: sensor.zone_6_is_finished
    timer_and_entity_connected_via_automation: true
    button_position: right
    colors:
      ready: "#2E7D32"
      unavailable: "#B71C1C"
    icons:
      start: mdi:play
      stop: mdi:stop
  - name: Zone 7
    switch: switch.zone_7
    timer: timer.zone_7_timer
    last_run_sensor:
      entity: sensor.zone_7_is_finished
    timer_and_entity_connected_via_automation: true
    button_position: left
    colors:
      "on": "#5E35B1"
      progress_fill: "#5E35B1"
    icons:
      start: mdi:play
      stop: mdi:stop
    labels:
      status_on: Running
      status_ready: Ready
  - name: Zone 8
    switch: switch.zone_8
    timer: timer.zone_8_timer
    last_run_sensor:
      entity: sensor.zone_8_is_finished
    timer_and_entity_connected_via_automation: true
    button_position: right
    colors:
      button_start: "#00897B"
      button_stop: "#C62828"
      icon: "#FFFFFF"
    icons:
      start: mdi:water
      stop: mdi:water-off
    labels:
      status_on: Water ON
      status_ready: Water OFF
  - name: Zone 9
    switch: switch.zone_9
    timer: timer.zone_9_timer
    last_run_sensor:
      entity: sensor.zone_9_is_finished
    timer_and_entity_connected_via_automation: true
    button_position: left
    colors:
      "on": "#1565C0"
      ready: "#43A047"
      unavailable: "#D32F2F"
      progress_fill: "#1565C0"
    icons:
      start: mdi:play
      stop: mdi:stop
    labels:
      time_format_zero: 0m 00s
      time_unit_minutes: m
      time_unit_seconds: s
  - name: Zone 10
    switch: switch.zone_10
    timer: timer.zone_10_timer
    last_run_sensor:
      entity: sensor.zone_10_is_finished
    timer_and_entity_connected_via_automation: true
    button_position: right
    colors:
      "on": "#00BCD4"
      button_start: "#00BCD4"
      button_stop: "#9E9E9E"
      progress_fill: "#00BCD4"
    icons:
      start: mdi:play-circle-outline
      stop: mdi:stop-circle-outline
    labels:
      status_on: Zone 10 Active
      status_ready: Zone 10 Ready

image8

Section View Example

type: sections
max_columns: 8
title: test
path: test
dense_section_placement: true
sections:
  - type: grid
    cards:
      - type: custom:switch-and-timer-bar-card
        entities:
          - switch: switch.zone_1
            timer: timer.zone_1_timer
            last_run_sensor:
              entity: sensor.zone_1_is_finished
            timer_and_entity_connected_via_automation: true
        colors: {}
        icons: {}
        labels: {}
        button_position: left
        grid_options:
          columns: 21
          rows: auto
      - type: custom:switch-and-timer-bar-card
        entities:
          - switch: switch.zone_2
            timer: timer.zone_2_timer
            last_run_sensor:
              entity: sensor.zone_2_is_finished
            timer_and_entity_connected_via_automation: true
        colors: {}
        icons: {}
        labels: {}
        button_position: left
        grid_options:
          columns: 21
          rows: auto
      - type: custom:switch-and-timer-bar-card
        entities:
          - switch: switch.zone_3
            timer: timer.zone_3_timer
            last_run_sensor:
              entity: sensor.zone_3_is_finished
            timer_and_entity_connected_via_automation: true
        colors: {}
        icons: {}
        labels: {}
        button_position: left
        grid_options:
          columns: 21
          rows: auto
      - type: custom:switch-and-timer-bar-card
        entities:
          - switch: switch.zone_4
            timer: timer.zone_4_timer
            last_run_sensor:
              entity: sensor.zone_4_is_finished
            timer_and_entity_connected_via_automation: true
        colors: {}
        icons: {}
        labels: {}
        button_position: left
        grid_options:
          columns: 21
          rows: auto
      - type: custom:switch-and-timer-bar-card
        entities:
          - switch: switch.zone_5
            timer: timer.zone_5_timer
            last_run_sensor:
              entity: sensor.zone_5_is_finished
            timer_and_entity_connected_via_automation: true
        colors: {}
        icons: {}
        labels: {}
        button_position: left
        grid_options:
          columns: 21
          rows: auto
      - type: custom:switch-and-timer-bar-card
        entities:
          - switch: switch.zone_6
            timer: timer.zone_6_timer
            last_run_sensor:
              entity: sensor.zone_6_is_finished
            timer_and_entity_connected_via_automation: true
        colors: {}
        icons: {}
        labels: {}
        button_position: left
        grid_options:
          columns: 21
          rows: auto
      - type: custom:switch-and-timer-bar-card
        entities:
          - switch: switch.zone_7
            timer: timer.zone_7_timer
            last_run_sensor:
              entity: sensor.zone_7_is_finished
            timer_and_entity_connected_via_automation: true
        colors: {}
        icons: {}
        labels: {}
        button_position: left
        grid_options:
          columns: 21
          rows: auto
      - type: custom:switch-and-timer-bar-card
        entities:
          - switch: switch.zone_8
            timer: timer.zone_8_timer
            last_run_sensor:
              entity: sensor.zone_8_is_finished
            timer_and_entity_connected_via_automation: true
        colors: {}
        icons: {}
        labels: {}
        button_position: left
        grid_options:
          columns: 21
          rows: auto
      - type: custom:switch-and-timer-bar-card
        entities:
          - switch: switch.zone_9
            timer: timer.zone_9_timer
            last_run_sensor:
              entity: sensor.zone_9_is_finished
            timer_and_entity_connected_via_automation: true
        colors: {}
        icons: {}
        labels: {}
        button_position: left
        grid_options:
          columns: 21
          rows: auto
      - type: custom:switch-and-timer-bar-card
        entities:
          - switch: switch.zone_10
            timer: timer.zone_10_timer
            last_run_sensor:
              entity: sensor.zone_10_is_finished
            timer_and_entity_connected_via_automation: true
        colors: {}
        icons: {}
        labels: {}
        button_position: left
        grid_options:
          columns: 21
          rows: auto
      - type: custom:switch-and-timer-bar-card
        entities:
          - switch: switch.zone_11
            timer: timer.zone_11_timer
            last_run_sensor:
              entity: sensor.zone_11_is_finished
            timer_and_entity_connected_via_automation: true
        colors: {}
        icons: {}
        labels: {}
        button_position: left
        grid_options:
          columns: 21
          rows: auto
      - type: custom:switch-and-timer-bar-card
        entities:
          - switch: switch.zone_11
            timer: timer.zone_11_timer
            last_run_sensor:
              entity: sensor.zone_11_is_finished
            timer_and_entity_connected_via_automation: true
        colors: {}
        icons: {}
        labels: {}
        button_position: left
        grid_options:
          columns: 21
          rows: auto
    column_span: 8
cards: []
icon: mdi:grass

image8

🔧 Per‑entity overrides example

type: custom:switch-and-timer-bar-card
title: ''
button_position: left
colors:
  on: '#2196F3'
  ready: '#4CAF50'
  unavailable: '#F44336'
  button_start: '#4CAF50'
  button_stop: '#2196F3'
  icon: 'white'
  progress_fill: '#2196F3'
icons:
  start: 'mdi:play'
  stop: 'mdi:stop'
labels:
  status_on: 'Watering'
  status_ready: 'Ready'
  status_unavailable: 'Unavailable'
  time_format_zero: '0m 00s'
  time_unit_minutes: 'm'
  time_unit_seconds: 's'
entities:
  - name: Zone 1
    switch: switch.zone_1
    timer: timer.zone_1_timer
    last_run_sensor:
      entity: sensor.zone_1_is_finished
  - name: Zone 2
    switch: switch.zone_2
    timer: timer.zone_2_timer
    last_run_sensor:
      entity: sensor.zone_2_is_finished
  - name: Living Room Light
    switch: switch.zone_3
    timer: timer.zone_3_timer
    last_run_sensor:
      entity: sensor.zone_3_is_finished
    button_position: right
    colors:
      button_start: '#F443FF'
      ready: '#FF5500'
    icons:
      start: 'mdi:light-switch'
    labels:
      status_ready: 'Light Off'

image5

🧩 YAML Examples (by domain & scenario)

Below are paired examples for each domain: first with automation mode off (false), then automation mode on (true). Replace entity IDs with your own.

1) switch domain

Entity and Timer are NOT connected via Automation, Script etc.

type: custom:switch-and-timer-bar-card
entities:
  - name: Pool Pump
    switch: switch.pool_pump
    timer: timer.pool_pump
    last_run_sensor:
      entity: sensor.pool_pump_last_run
    timer_and_entity_connected_via_automation: false

Entity and Timer are connected via Automation, Script etc. (default)

type: custom:switch-and-timer-bar-card
entities:
  - name: Pool Pump
    switch: switch.pool_pump
    timer: timer.pool_pump
    last_run_sensor:
      entity: sensor.pool_pump_last_run
    timer_and_entity_connected_via_automation: true #this line is not required because default value is true

2) cover domain (e.g., blinds)

Entity and Timer are NOT connected via Automation, Script etc.

type: custom:switch-and-timer-bar-card
entities:
  - name: Patio Blind
    switch: cover.patio_blind
    timer: timer.patio_blind
    last_run_sensor:
      entity: sensor.patio_blind_last_run
    timer_and_entity_connected_via_automation: false

Entity and Timer are connected via Automation, Script etc.

type: custom:switch-and-timer-bar-card
entities:
  - name: Patio Blind
    switch: cover.patio_blind
    timer: timer.patio_blind
    last_run_sensor:
      entity: sensor.patio_blind_last_run
    timer_and_entity_connected_via_automation: true

3) valve domain (e.g., irrigation / water valve)

Entity and Timer are NOT connected via Automation, Script etc.

type: custom:switch-and-timer-bar-card
entities:
  - name: Garden Valve
    switch: valve.garden_water_valve
    timer: timer.garden_valve
    last_run_sensor:
      entity: sensor.garden_valve_last_run
    timer_and_entity_connected_via_automation: false

Entity and Timer are connected via Automation, Script etc.

type: custom:switch-and-timer-bar-card
entities:
  - name: Garden Valve
    switch: valve.garden_water_valve
    timer: timer.garden_valve
    last_run_sensor:
      entity: sensor.garden_valve_last_run
    timer_and_entity_connected_via_automation: true

4) lock domain (e.g., gate lock)

Entity and Timer are NOT connected via Automation, Script etc.

type: custom:switch-and-timer-bar-card
entities:
  - name: Garden Gate
    switch: lock.garden_gate
    timer: timer.garden_gate
    last_run_sensor:
      entity: sensor.garden_gate_last_run
    timer_and_entity_connected_via_automation: false

Entity and Timer are connected via Automation, Script etc.

type: custom:switch-and-timer-bar-card
entities:
  - name: Garden Gate
    switch: lock.garden_gate
    timer: timer.garden_gate
    last_run_sensor:
      entity: sensor.garden_gate_last_run
    timer_and_entity_connected_via_automation: true

5) media_player domain (e.g., TV or speaker)

Entity and Timer are NOT connected via Automation, Script etc.

type: custom:switch-and-timer-bar-card
entities:
  - name: Living Room TV
    switch: media_player.living_room_tv
    timer: timer.tv_sleep_timer
    last_run_sensor:
      entity: sensor.tv_last_run
    timer_and_entity_connected_via_automation: false

Entity and Timer are connected via Automation, Script etc.

type: custom:switch-and-timer-bar-card
entities:
  - name: Living Room TV
    switch: media_player.living_room_tv
    timer: timer.tv_sleep_timer
    last_run_sensor:
      entity: sensor.tv_last_run
    timer_and_entity_connected_via_automation: true

6) automation domain (e.g., automation.arriving_home)

Entity and Timer are NOT connected via Automation, Script etc.

type: custom:switch-and-timer-bar-card
entities:
  - name: Living Room TV
    switch: automation.arriving_home
    timer: timer.stop_automation
    last_run_sensor:
      entity: sensor.stop_automation_last_time
    timer_and_entity_connected_via_automation: false

Entity and Timer are connected via Automation, Script etc.

type: custom:switch-and-timer-bar-card
entities:
  - name: Living Room TV
    switch: automation.arriving_home
    timer: timer.stop_automation
    last_run_sensor:
      entity: sensor.stop_automation_last_time
    timer_and_entity_connected_via_automation: true

7) Multiple timers for the same device (heating boost example)

A single boiler controlled by three boost buttons — 15, 30, and 60 minutes. The card automatically detects that all three cards share the same switch and coordinates between them.

type: custom:switch-and-timer-bar-card
title: ♨️ Central Heating
button_position: left
labels:
  status_on: Heating
  status_ready: Idle
entities:
  - name: 15 Minute Boost
    switch: switch.boiler_central_heating
    timer: timer.boost_central_heating_for_15_minutes
    timer_and_entity_connected_via_automation: false
  - name: 30 Minute Boost
    switch: switch.boiler_central_heating
    timer: timer.boost_central_heating_for_30_minutes
    timer_and_entity_connected_via_automation: false
  - name: 60 Minute Boost
    switch: switch.boiler_central_heating
    timer: timer.boost_central_heating_for_60_minutes
    timer_and_entity_connected_via_automation: false

Behavior:

  • Press Start on the 30-minute card → only that card shows "Heating" and a counting progress bar; the 15- and 60-minute cards stay "Idle".
  • Start a second boost while the first is running → both run in parallel, each with its own countdown.
  • When one of two parallel boosts finishes, the boiler stays on until the other one is also done.
  • Press Stop on the only running boost → boiler turns off. Press Stop on one of two running boosts → only that timer finishes; boiler stays on for the other.

If you prefer to handle the boiler on/off in your own automations, set timer_and_entity_connected_via_automation: true on every entry and trigger your automation from timer.started / timer.finished events.


License

MIT — see the LICENSE file.

⭐ Support

Buy Me a Coffee

About

Timer Card for all switches and for their assigned time sensors

Topics

Resources

Stars

21 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors