Chuyển đến nội dung

Mẫu Countdown

Một mẫu dựa trên bộ hẹn giờ với vòng đời do máy chủ quản lý. Thiết lập rồi quên đi -- máy chủ tự động xử lý các thông báo cảnh báo và hoàn thành.

Trình diễn Live Activity

Fields

FieldTypeDescription
templatestringRequired. Must be "countdown"
progressfloatRequired. Initial progress (usually 0.0)
durationstringRequired (or end_date). Server-side convenience — converted to end_date before reaching the device. Accepts: "30s", "5m", "1h30m", or plain seconds ("1500")
end_dateintegerRequired (or duration). Unix timestamp when the countdown expires
start_dateintegerUnix timestamp when the countdown began. Must be less than end_date. Used to compute progress on-device.
warning_thresholdintegerSeconds before end_date to send a warning push (accent turns orange)
completion_messagestringText shown when countdown expires (default: "Completed")
statestringStatus text (e.g. "Baking", "Printing")
iconstringSF Symbol name or MDI icon with mdi: prefix (e.g. "mdi:timer-outline")
subtitlestringSecondary text
accent_colorstringNamed color or hex
background_colorstringBackground color override
text_colorstringText color override
alarmbooleanOpt-in: schedule an iOS AlarmKit alarm at end_date that rings through silent mode and Focus. iOS 26+ only. See Ringing an Alarm on Completion.
snooze_secondsintegerHow long the alarm's Snooze button defers the alarm, in seconds (60–3600). Defaults to 300 (5 minutes).

Example Payload

Bắt đầu một bộ đếm ngược
{
  "state": "ongoing",
  "content": {
    "template": "countdown",
    "progress": 0.0,
    "state": "Baking",
    "icon": "flame",
    "subtitle": "25 min timer",
    "duration": "25m",
    "warning_threshold": 60,
    "completion_message": "Done baking!",
    "accent_color": "orange",
    "alarm": true
  }
}

Auto-Managed Lifecycle

After starting a countdown, the server automatically manages the remaining lifecycle:

  1. You send the start push -- sets ended -> ongoing with the countdown content
  2. Server sends warning push -- when warning_threshold seconds remain, the server automatically sends an update with accent_color: "orange"
  3. Server sends completion push -- when end_date is reached, the server sends an end push with completion_message and progress: 1.0
Thông tin

The countdown timer display on the device is computed from start_date and end_date, so it counts down in real-time without needing additional pushes.

💡 Mẹo

Only the initial start push is required. You don't need to send any follow-up requests -- the server handles everything automatically.

Buttons & tap targets

Accepts url_action, secondary_url_action, and tap_actiontap_action is useful for deep-linking back into the timer's source app while it runs. See Tap actions for the action object shape.

Ringing an Alarm on Completion

Setting alarm: true (as shown above) schedules an iOS AlarmKit alarm at end_date. The alarm rings through silent mode and Focus -- like a native Clock alarm -- alongside the Live Activity countdown, with built-in Dismiss and Snooze controls (snooze defaults to 5 minutes; override per activity with snooze_seconds, 60–3600 s).

Thông tin

Requires iOS 26+ and user authorization on first use. Once set, the alarm persists across partial updates until you clear it with {"content":{"alarm":null}} in a PATCH body, or a transition to ended. See Alarms for details.

Integrations Using This Template

  • Home Assistant — configurable via the template option in entity config