Automation triggers when transition from unavailable AND was unavailable for x mins

Hi,
I have a device that, from time to time, goes unavailable and after a few seconds or minutes, it goes available again.

I did a simple automation to send a notify when it was unavailable for 10 minutes, as a warning to check it.
I’d want to setup another automation to notify when it is available again, but the “notify when changes from unavailable for xx seconds” is not the right one, because I only want to send this notification if there was a unavailable notification before.

I mean, the automation I want is something like “nofify when was unavailable for 10 mins and changes from unavailable for xx seconds”. This is not so simple for me…
How can I achieve this?

My current automation (which can be edited using the GUI):

 alias: Send notification when device is available
 description: >-
   Send notification when device is available
 trigger:
   - platform: state
     entity_id:
       - switch.light_1
     for:
       hours: 0
       minutes: 0
       seconds: 30
     from: unavailable
 condition: []
 action:
   - service: notify.mobile_app
     data:
       title: Device available
       message: "{{trigger.to_state.attributes.friendly_name}} reconnected"
 mode: single

Thanks!