Notification before restart

Hello Community!

Is it possible to trigger an automation slightly before I restart home assistant? I want to let my other colleagues know that a restart is happening in a few seconds.

Yes you can.

- id: affb7625-0dc2-4075-88a9-6eae3563af6c
  alias: 'Shutdown'
  trigger:
    platform: homeassistant
    event: 'shutdown'
  action:
  - service: notify.telegram_system
    data:
      title: '⚠️ *System shutdown*'
      message: >
        Home Assistant is shutting down.

        {{ now().strftime("%H:%M:%S") }}

And after it has started again:

- id: 46ba1b3e-14bc-4237-abb6-e9146eacc575
  alias: 'Startup'
  trigger:
    platform: homeassistant
    event: start
  action:
  - service: notify.telegram_system
    data:
      title: '✅ *System startup*'
      message: >
        Home Assistant has started.

        {{ now().strftime("%H:%M:%S") }}
6 Likes

Big thank you! Is it possible without using telegram? With notify.notify?

Indeed it is.

alias: "Reboot | Benachrichtigung "
description: ""
trigger:
  - platform: homeassistant
    event: shutdown
action:
  - service: notify.notify
    data:
      title: Neustart des Servers
mode: single

If i press on restart in developer tools for example, no notification happens :frowning: any thoughts?

Can you send any notifications with notify.notify?

yes, tested right now.

shutdown does not send the notification, it also does not show up in the trace of the automation. As if it was never triggered by shutdown event.