Issues with sensor template offset when data unavailable

try this for the template:

value_template: >
  {% if states.sensor.krypgrund_humidity.state != 'unavailable' %}
    {{ (states.sensor.krypgrund_humidity.state | float + 7) | round(0) }}
  {% else %}
    {{ states.sensor.krypgrund_humidity_offset.state }}  
  {% endif %}