Template with two states from one device stays "Unavailable", works for other devices

I have four humidity/temperature sensors that report their measurements via MQTT. For three of them my template for absolute humidity works well, for one sensor it stays at “Unavailable” indefinitely:

    -   name: "Absolute humidity Sensor 1"
        unit_of_measurement: g/m³
        state_class: measurement
        device_class: humidity
        state:  >-
          {% set h, t = states('sensor.htsensor1_humidity')|
          float, states('sensor.htsensor1_temperature') %}
          {% if not h or t == 'unknown' -%}
            'unknown'
          {%- else %}
          {% set t = t | float %}
          {{ (h*6.112*2.1674*e**((t*17.67)/(t+243.5))/(t+273.15))|round(2) }}
          {% endif %}

The one that stays “Unavailable” reports temperature and humidity independently and in irregular intervals (it tries to save on energy by only reporting a value if a certain change threshold has been reached). htsensor1_temperature and htsensor1_humidity always show their latest value in the default “Overview” dashboard, even when they are somewhat old. But the template stays at “Unavailable”. Any ideas?

Gah, what a stupid mistake: The “Unavailable” sensor is the only one, that uses the pattern ‘sensor.htsensor1_air_temperature’ for temperature but ‘sensor.htsensor1_humidity’ for humidity. All others have some long entity name and then just temperature or humidity appended. Stupid me needs a template checker, which checks whether all used entity names exist.