Triggering based on unavailable device

Can someone point me to an example automation that triggers when a device is or becomes unavailable? Very new to HA.
Thanks in advance.

alias: example
triggers:
  - trigger: state
    entity_id: sensor.whatever
    to: unavailable
conditions: []
actions:
  - action: notify.persistent_notification
    data:
      title: Whatever is unavailable.

That was perfect. Thank you.

1 Like