New template defaults in 2021.11

I may have missed it in the breaking changes but it seems they sneaked in another requirement to include deafault for | int.

(Full disclosure… I knew it was coming as I had heard about in the forum)

But anyway, I’m getting the warning:

Template warning: 'int' got invalid input 'unavailable' when rendering template '{% set sensor_used = states('sensor.light_level_sensor_being_used') %} {% set light_level_value = states('sensor.' + sensor_used) | int %} {% set sensor_threshold = states('input_number.hall_' + sensor_used +'_sensor_threshold') | int %} {{ light_level_value <= sensor_threshold }}' but no default was specified. Currently 'int' will return '0', however this template will fail to render in Home Assistant core 2022.1

But I would have thought that with my availability it should bnever even evaluate the state template?
What have I missed or done wrong?

      - name: Dark In The Dining Room
        state: >
          {% set sensor_used = states('sensor.light_level_sensor_being_used') %}
          {% set light_level_value = states('sensor.' + sensor_used) | int %}
          {% set sensor_threshold = states('input_number.dining_room_' + sensor_used +'_sensor_threshold') | int %}

          {{ light_level_value <= sensor_threshold }}
        availability: >
          {{ states('sensor.light_level_sensor_being_used') not in ['unknown','unavailable'] }}
        icon: >
          mdi:candle

That’s coming with 2021.12. Atm it resolves both regardless of the availability

1 Like

Ok, it isn’t coming until 2021.12, but what can we do now to fix the issue before that release causes “this template will fail to render in Home Assistant core 2022.1”?

1 Like

You don’t have to do anything if you’re using the availability template.