Sensor: If "not available" occurs keep the previous value

Basically turning your topic subject into code:

# Filtered OpenUV sensor
  - platform: template
    sensors:
      current_uv_index_filtered:
        friendly_name: "Open UV sensor filtered"
        value_template: >-
          {% if is_state('sensor.current_uv_index', 'unknown') %}
            {{ states('sensor.current_uv_index_filtered') }}
          {% else %}
            {{ states('sensor.current_uv_index') }}
          {% endif %}

This will retain the prior value for a potentially-unlimited amount of time if your source sensor goes down, so it might be worth setting up an automation to alert you if it’s unknown for too long.

4 Likes