Sensor template value unknown

Hi I started getting “unknown” value for my template variable which was working earlier. Currently using HA core 2021.8.8. I am using OpenUV to get sensor.max_uv_index and sensor.current_uv_index and both are getting value feed.

Sensor name label embeds max UV value for the day, current value is the value returned by template and a different icon is picked up for each integer value of UV index. Any guidance to trouble shoot the template evaluation issue would help:

        friendly_name_template: "Today {{ states.sensor.max_uv_index.state | round(1) }} Max"
        value_template: "{{ states.sensor.current_uv_index.state | round(1) }}"
        entity_picture_template: "/local/UVI/UVI_{% if states.sensor.current_uv_index.state | round(0) > 11 %}11p{% else %}{{states.sensor.current_uv_index.state | round(0)}}{% endif %}.png"
        unit_of_measurement: 'UVI'

This is how the developer console evaluating my template:

Not sure if this helps, but try-

        friendly_name_template: >-
          Today {{ states('sensor.max_uv_index') | float | round(1) }} Max
        value_template: >-
          {{ states('sensor.current_uv_index') | float | round(1) }}
        entity_picture_template: >-
          /local/UVI/UVI_{{ '11p' if states('sensor.current_uv_index') | int > 11 else states('sensor.current_uv_index') | int) }}.png
        unit_of_measurement: 'UVI'

It actually fixed the issue. Now I also remember somewhere I read that the syntax I used states.sensor.current_uv_index.state may return unknown value. Same problem I notice with another sensor below:

        friendly_name_template: '{{ states.sensor.season.state.title() }}'
        value_template: '{{ states.sensor.season.state.title() }}'
        entity_picture_template: "{% set state = states('sensor.season').title() %} {{ '/local/{}.png'.format(state) }}"

when I changed the syntax as you mentioned, it fixed the issue. Thanks for your quick help.