Template sensor not auto-updating: a possible bug?

I am using several ESP devices and a lot of Shelly devices, and wanted to have a clear overview of the areas where these are located.
For each device I did set the Area in Home Assistant.
Initially I made a template sensor that is looking at an entity of each device like this:

template:
  - sensor:
    - name: ESP01-DHT11 Area
      unique_id: area_esp01_dht11
      state: "{{ area_name( 'sensor.esp01_dht11_ip_address' ) }}"

But then I found out that an entity does not always have to be in the same area as the device itself.
So I decided to get the Area from the device ID like this:

template:
  - sensor:
    - name: ESP01-DHT11 Area
      unique_id: area_esp01_dht11
      state: "{{ area_name( device_id( 'sensor.esp01_dht11_ip_address' ) ) }}"

This does work, but it appeared that the sensors are not automatically updated in this case when the Area of the device is changed: I had to go through “Developer tools → YAML → Template Entities” to reload the template yaml code to update the sensors.
So I changed the template sensors in trigger based sensors like this:

template:
  - trigger:
    - platform: time_pattern
      minutes: /5
    sensor:
      - name: ESP01-DHT11 Area
        unique_id: area_esp01_dht11
        state: "{{ area_name( device_id( 'sensor.esp01_dht11_ip_address' ) ) }}"

This is working fine now, but I wonder why the templates without the trigger updates are not updating automatically?
The HA Template documentation states:

Template entities will by default update as soon as any of the referenced data in the template updates.

So why isn’t this the case here?
Is this due to the nested functions device_id and area_name?
Or is this a bug?
My current version of Home Assistant is 2024.3.0
Who can shed some light on this?

The Template Editor can tell you in advance which entities will be monitored for state-changes (if any).

In this case, it monitors none.

At the very least I would have expected it to monitor the light entity. From the documentation:

However, even then it would only update the template when the entity’s state value changed and not at the moment when the entity was reassigned to another area.

I don’t know if the behavior for this particular template (monitor no entities) is by design or a bug. It seems like it might be a bug.

Thanks, that’s helpful.
I did test the templates in the Template Editor, but didn’t look for this specific info.

Yes, so as I understand it now, the templates are only automatically updated when the state of an entity is changed (creating an event), and the Area and Device ID properties are not seen as a state of the entity.

So the area_name and device_id functions are not calling the state of an entity and therefor are not automatically updating the template.
Could this be a bug or still missing feature, or is this intentional?

For reference: the area_name and device_id in the template are updated when a Trigger-based Template is used. The documentation states:

Whenever the trigger fires, all related entities will re-render and it will have access to the trigger data in the templates.

So in the case of a Trigger-based template the template is not only looking for state changing events but is re-rendering the entities, finding the changed area name as well.

In a Trigger-based Template Sensor, the entities in the state template aren’t monitored and do not determine when the template is evaluated. The state template is evaluated only when one of the sensor’s triggers is triggered.

In a Template Sensor, the entities in the state template are monitored and determine when the template is evaluated. The state template is evaluated only when one of entities within the template changes state or if the template contains now() or refers to all State objects states or an entire domain of State objects (states.light).

Thanks for this additional info. Can you give a link to the location where this is documented?

Just as a test I added now() like this to the template:

And indeed the template is updated now every minute, so in fact like this a time pattern trigger is added to the template.