Correct "wait until finished" syntax (e. g. 'wait_for_trigger')

I have the following script I run manually prior to updating HASS OS:

alias: System_SAMBA Backup manuell
  - service: hassio.addon_stdin
      addon: 15d21743_samba_backup
      input: trigger
  - wait_for_trigger:
      - platform: state
        entity_id: sensor.samba_backup
        from: RUNNING
        to: IDLE
  - service: notify.all_devices
      title: ✅ SAMBA-Backup fertig
      message: >-
        Das manuell gestartete SAMBA-Backup ist nun abgeschlossen (gestartet um
        {{ state_attr('script.system_manual_sambabackup', 'last_triggered') }})
        subtitle: ''
          thread-id: backup-notification-group
mode: single
icon: mdi:backup-restore

Initially I only had the run addon and the notification section, which lead to the notification “Backup finished!” being sent immediately after starting the script.

So I added the wait_for_trigger section. What I want it to do, is to wait until the backup has finished and send a notification.

Unfortunately, it doesn’t work with above code. Script still is running, probably because it is still waiting. That sensor has already changed from RUNNING to IDLE but the script is not aware of it.


I’m pretty sure “I’m holding it wrong” :smiley: Any clue?

It does not change from RUNNING to IDLE.

It changes:




1 Like

Oooooh that’s be so easy :slight_smile: Thx!

Gonna change the settings and give it a try at next chance.

For now I simply removed the „from“ value as it‘s optional. This way the script should now safely ignore the end of the backup, no matter if it succeeded or failed or has been canceled or…

Just never monitored the finishing closely and because it probably only shows up for a second or so it is not visible e. g. on the history card.

This is the way I monitor it:

- id: da632942-cd32-4699-8648-3a48256df2f6
  alias: Backup Notifications
    platform: state
    entity_id: sensor.samba_backup
  - condition: not
    - condition: state
      entity_id: sensor.samba_backup
      state: IDLE
  - service: notify.telegram_system
      title: >
        {% if states('sensor.samba_backup') == 'RUNNING' %}
          📅 *Samba backup*
        {% elif states('sensor.samba_backup') == 'SUCCEEDED' %}
          ✅ *Samba backup*
        {% elif states('sensor.samba_backup') == 'FAILED' %}
          ❌ *Samba backup*
        {% else %}
          ❓ *Samba backup*
        {% endif %}
      message: "{{ states('sensor.samba_backup')|title }}."
  - service: logbook.log
      name: Samba Backup
      message: "{{ states('sensor.samba_backup')|title }}"

I want to add a second script which only creates a HA backup (e. g. before updating HA).
For this, using Samba Backup addons seams too complicated because you can only set excludes, but not includes like “only backup this and that, nothing else”.

Maybe you can help me on this too @tom_l :
1) Is it possible to manually trigger Samba Backup addon so it creates only a HA backup?

Otherwise I´d go with the hassio.backup_partial service. But then another issue comes up:
2) How to check within a script if the backup (using this service) finished?

Yeah just exclude all your addons:

  - service: hassio.addon_stdin
      addon: 15d21743_samba_backup
        command: trigger
        backup_name: '{type}{date}v{version}'
        exclude_addons: [15ef4d2f_esphome, a0d7b954_vscode, core_mariadb]

That’s not bulletproof, unfortunately. Maybe tomorrow I add another addon, in 1 year there might be 7 additional addons - I don’t want to constantly think about “Wait a moment… don’t I need to update a script?”. So that SAMBA Backup limitation (not providing a whitelist, only a blacklist) is pretty ugly.

I guess a feature request to also support a whitelist would neither be successful nor quickly implemented, if at all. I gave it a small try @ Samba Backup: Create and store backups on a Samba share - #344 by e-raser.

What about my second question - any idea?

  - platform: state
    entity_id: sensor.samba_backup
    to: IDLE

and send a notification afterwards.