Pil Widget'ı
En fazla sekiz cihazın şarj seviyesi, halkalar hâlinde çizilir. Akıllı ev pilleri, sensörler ve bitmiş bulmak istemeyeceğiniz her şey için idealdir.
Bu bölüm, App Store incelemesini bekleyen bir uygulama güncellemesindeki bir özelliği açıklar. Güncelleme yayınlanır yayınlanmaz burada otomatik olarak açılır.
The battery template renders one ring per device, in the same idiom as Apple's own
Batteries widget.
Fields
| Field | Type | Notes |
|---|---|---|
template | string | Required. Must be "battery" |
devices | object[] | Required. Between 1 and 8 device objects, rendered in the order you send them. Replaced wholesale on PATCH — re-send the full roster, unchanged devices included (why) |
devices[].name | string | Required. Must not be empty. Max 32 characters |
devices[].level | float | Required. Charge percentage, 0 to 100 |
devices[].charging | boolean | Overlays a charging bolt on the ring |
devices[].icon | string | SF Symbol shown inside the ring, or an MDI icon prefixed with mdi:. Max 128 characters |
devices[].color | string | Ring color — named color or hex (see Colors). Default is green, switching to red at or below 20% |
device_sort | object[] | Up to 2 sort keys applied to devices before they are stored, so the smaller families show the devices you care about. Omit to keep the order you send |
device_sort[].field | string | Required. level or name. Names compare case-insensitively |
device_sort[].direction | string | asc (default) or desc |
label, subtitle, icon, accent_color, background_color, text_color | string | Shared content fields — see the API reference |
Example: household devices
{
"content": {
"template": "battery",
"label": "Devices",
"icon": "battery.75percent",
"accent_color": "green",
"devices": [
{ "name": "Vacuum", "level": 68, "icon": "fan.fill" },
{ "name": "Front lock", "level": 45, "icon": "lock.fill", "charging": true },
{ "name": "Doorbell", "level": 18, "icon": "video.fill" },
{ "name": "Sensor hub", "level": 92, "icon": "sensor.fill" }
]
}
}Behavior
Large Home Screen widgets list all eight devices; smaller families render as many as fit, taking them from the front of the array, so put the devices you care most about first.
Once you track more than two devices that ordering matters, because the small family shows only the
first two and the medium family the first four. Send "device_sort": [{ "field": "level" }] and the server reorders devices for you on every update, so the emptiest devices are the ones that stay visible
as levels drift.
Keys apply in order and the first one that separates two devices wins, so a second key is a
tie-break. With one key, devices sharing a level keep the order you sent them in; add { "field": "name" } after the level key and those ties resolve alphabetically
instead. The same field may not appear in both keys.
{
"content": {
"template": "battery",
"device_sort": [
{ "field": "level", "direction": "asc" },
{ "field": "name", "direction": "asc" }
],
"devices": [
{ "name": "Vacuum", "level": 68 },
{ "name": "Front lock", "level": 45 },
{ "name": "Doorbell", "level": 45 },
{ "name": "Sensor hub", "level": 92 }
]
}
}The server stores the sorted array, so every response and later GET return it
reordered — and because the reordering happens on write rather than on the device, it works on
every version of the app already installed.