Perform action when Google backup has finished uploading

So how would I make a trigger to send me a notification when backup finished making a backup and also has uploaded to Google drive completely?

I do it this way:

sensor:

#--------------------------------------------------------------------------------------
# backup 
#--------------------------------------------------------------------------------------

  - platform: template
    sensors:
      last_backup:
        friendly_name: "Last Backup"
        value_template: "{{state_attr('sensor.snapshot_backup', 'last_snapshot')}}"

automation:

- id: '1593338157847'
  alias: Last backup
  description: ''
  trigger:
  - entity_id: sensor.last_backup
    platform: state
  condition:
  - condition: numeric_state
    entity_id: sensor.time_online
    above: '30'
  action:
  - data:
      title: Home backed up
      message: Home backed up
    service: notify.notifier_mail
  mode: single
2 Likes

What sensor is sensor.time_online?

it is a template sensors derived from the uptime integration.

Just to prevent getting an email when HA is restarted (the automation runs otherwise in that case too)

1 Like

I have this sensor, which shows date and time when backup is done (eg. 12/29/2022 12:00)

      data_ultimo_backup:
        friendly_name: 'Ultimo Backup'
        value_template: >
          {% if states('sensor.backup_state') == 'backed_up' %}
           {% set timestamp = as_timestamp(states.sensor.backup_state.attributes.last_backup) | timestamp_custom(" %d/%m/%Y - %H:%M ") %} {{ timestamp.lstrip("0") }}
          {% else %}
            Sconosciuto
          {% endif %}

And the Home Assistant uptime sensor sensor.uptime

This is the automation I created, but it doesn’t work…

alias: "ALERT Nuovo Backup "
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.data_ultimo_backup
condition:
  - condition: numeric_state
    entity_id: sensor.uptime
    above: 30
action:
  - service: notify.mobile_app_iphone
    data:
      title: BACKUP
      message: È stato eseguito il backup giornaliero
mode: single

The Uptime sensor is the one provided by Home Assistant “Integrations”.
Could that be the problem?

Sensor.uptime gives the date time HA was last restarted. This one gives how many minutes HA is already running:

  - platform: template
    sensors:
      time_online:
        friendly_name: "Time Online"
        value_template: >
          {{ (((as_timestamp(now()) - as_timestamp(states('sensor.uptime'))) ) /60  ) | int  }}


1 Like