Template Sensors showing as Unavailable

Something weird is going on. I have a variety of template sensors in my yaml configuration file, the values for which are calculated from other source sensors.

They have all been working just fine for years. But in the last couple of weeks a few of them started to report “Unavailable”, now it’s happening to most of them.

e.g.:

template:
  - sensor:
    - name: net_power_grid_and_battery
      device_class: power
      unit_of_measurement: W
      state: >
        {{ states('sensor.power_grid_fronius_power_flow_0_http_192_168_0_201')|float(0) * -1 + states('sensor.battery_power')|float(0)}}

If I use the Developer Tools / Template editor and enter that code, it returns the values correctly as expected, and is constantly updating:

The source sensors are also reporting just fine:

But for the life of me I cannot get the derived template sensor to report a value any more.

The template sensor doesn’t even appear when I use the Developer Tools / State to look for its current state. It’s just not appearing at all. As mentioned, these are template sensors which have worked for long time, it’s just now they are not appearing.

Last reported value was a few days ago, since then it has gone:

It’s like Home Assistant doesn’t know it even exists. Yet there it is in the configuration.yaml file.

I have tried rebooting HA, reloading just yaml, even rebooting my proxmox server. No dice.

The above of course is just one example of many which have suffered the same fate.

I’m at a complete loss. It’s affecting a whole raft of template sensors and resulting in chaos for many automations.

Home Assistant:

  • Core 2024.12.4
  • Supervisor 2024.12.0
  • Operating System 10.3
  • Frontend 20241127.8

Help!

Just to add a bit more to the mystery, I have some older template sensors still using the old legacy format. None of these have been affected and are still working just fine.

So I created a new template sensor test_sensor_1 to replicate the example in my post above but using the old legacy format as follows:

sensor:
  - platform: template
    sensors:
      test_sensor_1:
        unit_of_measurement: "W"
        value_template: >
          {{ states('sensor.power_grid_fronius_power_flow_0_http_192_168_0_201')|float(0) * -1 + states('sensor.battery_power')|float(0)}}

And this one works just fine, is discoverable with the Developer Tools and is reporting correct and updated values: