Deprecation of legacy template entities in 2025.12

Bingo! :slight_smile:

- sensor:
    - default_entity_id: sensor.count_device_tracker
      state: "{{ states.device_tracker | list | count }}"
      name: count_device_tracker

It’s working like this. I missed the - before the sensor. That was the problem. Thanks for all the help guys!

I just found out indeed.

I thought it wasn’t necessary, as I load all files for the templates using !include_dir_merge_list. After adding the dash it worked. :slight_smile:

Let’s put the full one:

template:  
  - sensor:
     - default_entity_id: sensor.count_device_tracker
       state: "{{ states.device_tracker | list | count }}"
       name: count_device_tracker
2 Likes

I do find it strange, that the missing dash before the sensor is only causing issues for the count template sensors. For other template sensors, it’s not a problem and they all load.

But glad it works. :slight_smile:

Edit: updated all sensors, to hopefully prevent future issues. :slight_smile:

Oops, my mistake. Okay, it’s late, I should stop. My head is buzzing from all the YAML corrections. :innocent:

If you add the unique_id: field you can edit some details in UI of a yaml created template sensor. I do not believe the UI helpers will cover advanced template sensors.

Neither did the old format. I think the main issue with @crazyfx1’s plan is that they are going to loose history…

1 Like

You can just comment out the legacy template sensors in the packages, one at a time, as you replace them with the new format. You can update this in each individual package just like they are today. I just did this for one of the packages I have in my setup.

1 Like

Out of the 20 legacy sensor templates that have been reported, I’ve managed to successfully update 19 of them.

One is giving me an error when I use the suggested fix.

Old template:

  - platform: template
    sensors:
      energy_total:
        friendly_name: 'Total living room lights energy'
        entity_id:
          - sensor.tv_fan_light_1_eb13e9fe_level_on_off_energy
          - sensor.tv_fan_light_2_9830fafe_level_on_off_energy
          - sensor.tv_fan_light_3_level_on_off_energy
          - sensor.tv_fan_light_4_level_on_off_energy
        value_template: "{{ (states('sensor.tv_fan_light_1_eb13e9fe_level_on_off_energy')|float + states('sensor.tv_fan_light_2_9830fafe_level_on_off_energy')|float + states('sensor.tv_fan_light_3_level_on_off_energy')|float + states('sensor.tv_fan_light_4_level_on_off_energy')|float)|round(3) }}"
        unit_of_measurement: k

Suggested fix:

template:
- sensor:
  - entity_id:
    - sensor.tv_fan_light_1_eb13e9fe_level_on_off_energy
    - sensor.tv_fan_light_2_9830fafe_level_on_off_energy
    - sensor.tv_fan_light_3_level_on_off_energy
    - sensor.tv_fan_light_4_level_on_off_energy
    unit_of_measurement: k
    default_entity_id: sensor.energy_total
    name: Total living room lights energy
    state: '{{ (states(''sensor.tv_fan_light_1_eb13e9fe_level_on_off_energy'')|float
      + states(''sensor.tv_fan_light_2_9830fafe_level_on_off_energy'')|float + states(''sensor.tv_fan_light_3_level_on_off_energy'')|float
      + states(''sensor.tv_fan_light_4_level_on_off_energy'')|float)|round(3) }}'


Any idea what is wrong?
Thanks

FWIW…
I had 25 repairs. They came from things in configuration.yaml and lights.yaml. I gave both of these files to chatgpt (version 5.1). I asked if it could fix the template definitions and it said it could. I then gave it an example from one of the repair warnings just to be sure this matched what it thought the format had to be. It put all of the template definitions into a templates.yaml file, and gave me updated versions of configuration and lights. I made copies of the current files, installed the new ones, checked config, then restarted HA. Everything works great and I have no more warnings.

A few notes:
-I am not suggesting anyone use chatgpt. I just thought it was worth trying it and was pleasantly surprised it worked. I am pretty good at prompting chatgpt as I’ve been using it quite a lot for almost a year.
-I’m not an expert on templates but I do know my way around HA pretty well so I was able to sanity check what chatgpt did.
-So long as I didn’t prevent HA from starting with completely broken files (which I think may not even happen anymore), I think what would have been totally reversible. I also did a backup before messing with the files.

Remove the entity_id portion. That’s a current bug.

Try this

template:
  - sensor:
      - default_entity_id: sensor.energy_total
        name: "Total living room lights energy"
        unit_of_measurement: "k"
        state: >-
          {{ (
              states('sensor.tv_fan_light_1_eb13e9fe_level_on_off_energy') | float +
              states('sensor.tv_fan_light_2_9830fafe_level_on_off_energy') | float +
              states('sensor.tv_fan_light_3_level_on_off_energy') | float +
              states('sensor.tv_fan_light_4_level_on_off_energy') | float
            ) | round(3)
          }}

I ran into the exact same thing, and Petro identified the issue for me in a previous message. Technically a bug, but remove entity_id portion and it will work.

1 Like

Thanks.

I removed the - entity_id: section and I don’t get an error.
But, it is still reporting that the template needs fixing and gives the same fix as mentioned above.

Could somebody please help me with this code, it’s driving me mental trying to work out what Iv’e done wrong. I read tons, have another thread as well but was pointed in this direction to read, which I did and followed Tom’s post but I still get errors.

template:
    trigger:
      - trigger: event
        event_type: bubble_card_update_modules
    sensor:
      - name: "Bubble Card Modules"
        state: "saved"
        icon: "mdi:puzzle"
        attributes:
          modules: "{{ trigger.event.data.modules }}"
          last_updated: "{{ trigger.event.data.last_updated }}"
    cover:
       cover.cinema_front_window: # unique ID
        friendly_name: "Cinema Front Window" # your name
        optimistic: true # default when no state is available
        open_cover:
          - action: cover.open_cover
            target:
              entity_id: cover.cinema_front_window # change to your device id
        close_cover:
          - action: cover.close_cover
            target:
              entity_id: cover.cinema_front_window # change to your device id
        stop_cover:
          - action: cover.stop_cover
            target:
              entity_id: cover.cinema_front_window # change to your device id
    # cover:  
       cover.cinema_side_window: # unique ID
        friendly_name: "Cinema Side Window" # your name
        optimistic: true # default when no state is available
        open_cover:
          - action: cover.open_cover
            target:
              entity_id: cover.cinema_side_window # change to your device id
        close_cover:
          - action: cover.close_cover
            target:
              entity_id: cover.cinema_side_window # change to your device id
        stop_cover:
          - action: cover.stop_cover
            target:
              entity_id: cover.cinema_side_window # change to your device id

Try this

template:

  # ────────────────────────────────────────────────────────────────
  # TRIGGERED SENSOR – Bubble Card Modules
  # ────────────────────────────────────────────────────────────────
  - trigger:
      - trigger: event
        event_type: bubble_card_update_modules
    sensor:
      - name: "Bubble Card Modules"
        state: "saved"
        icon: "mdi:puzzle"
        attributes:
          modules: "{{ trigger.event.data.modules }}"
          last_updated: "{{ trigger.event.data.last_updated }}"

  # ────────────────────────────────────────────────────────────────
  # TEMPLATE COVER – Cinema Front Window
  # ────────────────────────────────────────────────────────────────
  - cover:
      - name: "Cinema Front Window"
        unique_id: cover.cinema_front_window
        optimistic: true
        open_cover:
          - action: cover.open_cover
            target:
              entity_id: cover.cinema_front_window
        close_cover:
          - action: cover.close_cover
            target:
              entity_id: cover.cinema_front_window
        stop_cover:
          - action: cover.stop_cover
            target:
              entity_id: cover.cinema_front_window

  # ────────────────────────────────────────────────────────────────
  # TEMPLATE COVER – Cinema Side Window
  # ────────────────────────────────────────────────────────────────
  - cover:
      - name: "Cinema Side Window"
        unique_id: cover.cinema_side_window
        optimistic: true
        open_cover:
          - action: cover.open_cover
            target:
              entity_id: cover.cinema_side_window
        close_cover:
          - action: cover.close_cover
            target:
              entity_id: cover.cinema_side_window
        stop_cover:
          - action: cover.stop_cover
            target:
              entity_id: cover.cinema_side_window

The docs are here, alsway refer to the docs.

The only reason you would continue to get the repair notice is that you didn’t delete the old sensor config.

I did, though.

Did you restart HA?