How to trigger an automation when xiaomi hub wasn’t found?

Hello. Is it possible to have a trigger or condition like “gateway is not found”

In some cases after reboot Home Assistant can not found xiaomi gateway because wi fi router is still loading. I would like to make an automation which would be triggered by Home Assistant start, then wait and check if hub is fine.
I need only to figure out how to say Home Assistant that hub is not found.

something like this will tell you if something is on the network,. just adapt to your needs.

Without knowing how you are setup, If you make this code into a binary sensor. With the Device tracker as the hub – assuming you have a method already to track devices. Nmap/Ping/router… etc. Shouldn’t be to hard to adapt.

      friendly_name: Printer
      value_template: >-
        {{ is_state('device_tracker.48_e2_44_90_f3_9d','home') and not is_state('device_tracker.48_e2_44_90_f3_9d','unavailable') }}
      device_class: connectivity
      icon_template: >
        {% if is_state('binary_sensor.printer','on') %} 
        {% else %} 
        {% endif %}