Google Drive Backup integration last backup entity question - date/time display attribute question

I have created a template sensor in my configuration.yaml so that I can display on my Dashboard the last time my Google Drive Backup created a backup. I used ChatGPT to help me (it got me 60% of the way there), I got the last 40%.

The one last thing I want to fix is the way it is displaying the date and day and time. It all looks to confusing to me right now. I’d simply like to display it as something around 2025-04-17 0200 and not what it is showing right now (too complicated for me). How can I change the atriubiute part of the yaml?

Your help is appreciated! Below is my current configuration.yaml and a screenshot of what the date/day/time display looks like on the Frontend of HA.

Please tell me what text I can use to replace the current ‘sort’ and attribute area so it can display simpler.

Thanks very much in advance!

yaml -

- sensor:
    - name: "last_backup"
      unique_id: last_backup
      icon: mdi:harddisk
      state: “{{ (state_attr('sensor.backup_state', 'backups') | sort(attribute='date', reverse=True))[0].date }}

Picture of entity showing the date/day/time too complicated for me.

Picture of my dashboard of my ‘System Status’ section.

Try

{{(states.sensor.backup_state.state) | as_timestamp | timestamp_custom('%m/%d/%Y %H:%M') }}

Sorry, I tried instead and lots of error messages.

What error messages did you see?

"2025-04-17T18:00:00.193532+00:00

Sensor has wrong format for timestamp … " there is a quotation mark

edit your template

1 Like

Thank you for your help so far, VietNgoc! Now, how do I put it al together in my yaml.config?

This is my current->

  - sensor:
    - name: "last_backup"
      unique_id: last_backup
      icon: mdi:harddisk
      state: "{{ (state_attr('sensor.backup_state', 'backups') | sort(attribute='date', reverse=True))[0].date | as_datetime | as_local }}"

This is what you gave me to replace but what I do not know, is how I put the 2 together? What gets deleted from my current yaml.config?

{% set time = '2025-04-17T18:00:00.193532+00:00' %}
{{ time | as_timestamp | timestamp_custom( '%m/%d/%Y %H:%M' ) }}

thank you in advance for you all your time!!!

No, this is an example how to convert timestamp to custom format… You can use it directly in sensor template…

- sensor:
  - name: "last_backup"
    unique_id: last_backup
    icon: mdi:harddisk
    state: >
      {% set lastBackup = state_attr('sensor.backup_state', 'backups') | sort(attribute='date', reverse=True))[0].date | as_datetime | as_local %}
      {{ lastBackup | as_timestamp | timestamp_custom( '%m/%d/%Y %H:%M' ) }}

or you can simply create a helper sensor via UI… Where you just select last backup attrbute as source, select device class as timestamp for helper and you don’t have to worry about it in lovelace

Open your Home Assistant instance and show your helper entities.

1 Like

thank you very much!!! VietNgoc, that did the trick, see screenshots! SO CLEAN, thank you!!