I want to display my backups in my dashboard, or rather, whether they are overdue and when they were last created. I’m not referring to backups from Home Assistant itself, but rather backups created by other computers or smartphones. Whenever a backup is created on my end, the status is recorded in a JSON file. I can retrieve this via an HTTP request, which usually tells me which device created the last backup. In the same JSON file, it also states how many days the backup is required for this type. I have now created a sensor in HA using the RESTful integration that converts the response into entities. The JSON looks something like this (+ additional types):
{
"bbackup": {
"name": "Backup",
"days": "30",
"last": "01 Apr 2026 12:17:27"
},
"calibre": {
"name": "Calibre",
"days": "3",
"last": "01 Apr 2026 20:36:27"
}
}
Since I’ve been experimenting with the Battery State Card lately, I’d like to use the same integration to show whether a backup is overdue. In the bbackup example, the last backup was on April 1, 2026, at 12:17:27 PM; it’s supposed to be created every 30 days, so it’s not due yet. This should be displayed in green. The Calibre backup is from “April 1, 2026, 8:36:27 PM,” but it’s supposed to be created every 3 days, so it’s overdue and should be displayed in red. The backups themselves usually start automatically and on time. However, sometimes the rsync server is unavailable or the source device has been offline for an extended period; in such cases, the backup cannot start and may become overdue.
I have used the following in configuration.yaml to integrate the sensor:
rest:
- authentication: basic
username: "myuser"
password: "mypassword"
scan_interval: 43200
resource: https://mydomain.com/?action=getbackups
method: GET
headers:
Accept: application/json
sensor:
- name: "bbackup"
unique_id: 22c32b5b-8c0c-4995-8a38-2838f78ac147
json_attributes_path: "$.bbackup"
device_class: timestamp
value_template: "{{ as_timestamp(strptime(value_json.bbackup.last, '%d %b %Y %H:%M:%S')) | timestamp_local }}"
json_attributes:
- "last"
- "name"
- "days"
- name: "calibre"
json_attributes_path: "$.calibre"
unique_id: e30614af-4a31-4ffa-a3d8-f911bbd0ece2
device_class: timestamp
value_template: "{{ as_timestamp(strptime(value_json.calibre.last, '%d %b %Y %H:%M:%S')) | timestamp_local }}"
json_attributes:
- "last"
- "name"
- "days"
The JSON attributes are read correctly, and I can retrieve them in the entity. But how can I create an “Overdue” attribute from this and use it as a threshold in the Battery State Card?
My card looks like the following:
type: custom:battery-state-card
title: Backups
secondary_info: In {attributes.days} Days
icon: null
entities:
- entity: sensor.bbackup
- entity: sensor.calibre
sort: name
I know, i can use something like
colors:
steps:
- value: 0
color: green
- value: 1
color: red
to specify colors for the tresholds. I know if i calculate "days" / ("now" - "last") i get either smaller zero (overdue/red) or bigger/equal zero (in time/green). But i don’t know, how to use this to decide if the entry is green or red.
Can someone please take me in the right direction?