Sensor template not working after 0.107.x

Can somebody help me to understand why this sensor template is not working anymore after installing 0.107.x ?

- platform: template
  sensors:
    nextsunrise:
      entity_id: sensor.time
      friendly_name: 'Prossima Alba'
      value_template: >
        {{ as_timestamp(states.sun.sun.attributes.next_rising) | timestamp_custom(' %H:%M') | replace(" 0", "") }}
      icon_template: mdi:weather-sunset-up
    nextsunset:
      entity_id: sensor.time
      friendly_name: 'Prossimo Tramonto'
      value_template: >
        {{ as_timestamp(states.sun.sun.attributes.next_setting) | timestamp_custom(' %H:%M') | replace(" 0", "") }}
      icon_template: mdi:weather-sunset-down
    sunrisetoday:
      entity_id: sensor.time
      friendly_name: 'Alba'
      value_template: >
        {{ as_timestamp(states.sun.sun.attributes.sunrise) | timestamp_custom(' %H:%M') | replace(" 0", "") }}
      icon_template: mdi:weather-sunset-up
    sunsettoday:
      entity_id: sensor.time
      friendly_name: 'Tramonto'
      value_template: >
        {{ as_timestamp(states.sun.sun.attributes.sunset) | timestamp_custom(' %H:%M') | replace(" 0", "") }}
      icon_template: mdi:weather-sunset-down
    daylightyesterday:
      entity_id: sensor.time
      friendly_name: 'Ore Giorno Ieri'
      value_template: >
        {{ (states.sun.sun.attributes.prev_daylight) | timestamp_custom(' %H:%M:%S',false) | replace(" 0", "") }}
      icon_template: mdi:weather-sunny
    daylighttoday:
      entity_id: sensor.time
      friendly_name: 'Ore Giorno Oggi'
      value_template: >
        {{ (states.sun.sun.attributes.daylight) | timestamp_custom(' %H:%M:%S',false) | replace(" 0", "") }}
      icon_template: mdi:weather-sunny
    daylighttomorrow:
      entity_id: sensor.time
      friendly_name: 'Ore Giorno Domani'
      value_template: >
          {{ (states.sun.sun.attributes.next_daylight) | timestamp_custom(' %H:%M:%S',false) | replace(" 0", "") }}
      icon_template: mdi:weather-sunny
    daylengthchange:
      entity_id: sensor.time
      friendly_name: 'Cambiamenti Durata Giorno'
      unit_of_measurement: "sec"
      value_template: >
        {{ (states.sun.sun.attributes.daylight) - (states.sun.sun.attributes.prev_daylight) }}
      icon_template: mdi:weather-sunny
    daylight_remaining_min:
      friendly_name: Daylight Remaining Minutes
      entity_id: sensor.time
      value_template: >
        {{ ((as_timestamp(state_attr('sun.sun', 'sunset')) - now().timestamp())/60)|int }}
      unit_of_measurement: min
    daylight_remaining_hm:
      friendly_name: "Daylight Remaining HH:MM"
      entity_id: sensor.time
      value_template: >
        {{ (as_timestamp(state_attr('sun.sun', 'sunset')) - now().timestamp())
           |timestamp_custom('%H:%M', false) }}
    dayofyear:
      friendly_name: 'Day Number'
      entity_id: sensor.date
      value_template: "{{ now().strftime('%j') }}"
    weekofyear:
      friendly_name: 'Week Number'
      entity_id: sensor.date
      value_template: "{{ now().strftime('%U') }}"

Is it maybe related to one of the breaking changes?

You have listed many Template Sensors. Have they all failed to work or just one of them?

All of them…

All of my Template Sensors work in 0.107 so I doubt the new version is the cause of this problem.

Are the Template Sensors listed in Developer Tools > States?
Are there any warning or error messages in the log?

I just restarted HA and now i see again all the sensors working… really don’t know why before they were not working. BTW Solved…

Glad to hear it’s working but I dislike calling a restart a “Solution” especially when:

really don’t know why before they were not working

:man_shrugging:

Using:

state_attr('sun.sun', 'daylight')

Instead of:

states.sun.sun.attributes.daylight

Might help after restarts.