Timeout for state "unknown" in template sensor

I have a php script that acts as a sensor. The script sometimes goes unknown for 5 minutes or so. This is not a problem, but the sensor immediately goes to “unknown”. Is there a way to delay the unknown state for maximum 5 minutes and just stay at the previous value?

  - sensor:
      command: /opt/homebrew/bin/php /Users/server/Steuerung/homeassistant-config/php/satellit.php
      value_template: >-
          {% if value_json is defined %}
              {{ value_json.WolkenDichteIR }}
            {% else %}
              {{ "unknown" }}
            {% endif %}
      scan_interval: 60
      name: Wolkendichte Online
      unit_of_measurement: "%"
      unique_id: wolken_satellit_ir
        {% if value_json is defined %}
          {{ value_json.WolkenDichteIR }}
        {% else %}
          {{ states('sensor.wolkendichte_online') }}
        {% endif %}

It’ll never go unknown though.