Sensor.file slow to update in frontend

Using the sensor.file to log my intercom messages I can see the sensor change only quite some time, lets say a second or 10-20 sometimes updated after the notification has been played.

Is there a way we can trigger the sensor.file to update immediately upon triggering of the automation I use to populate the sensor?

sensor:

  - name: filed_intercom_messages
    platform: file
    filename: /config/logging/filed_intercom_messages.txt

and automation:

  - alias: 'Person forward intercom messages to filed intercom messages'
    id: 'Person forward intercom messages to filed intercom messages'
    trigger:
      platform: state
      entity_id: script.intercom_text_message
    condition: []
    action:
      service: notify.filed_intercom_messages
      data_template:
        message: >
          {% set message = states('input_select.intercom_message') %}
          {% set device = states('input_select.intercom') %}
          {% set language = states('input_select.intercom_language') %}
          {% set id = trigger.to_state.context.user_id %}
          {% set time = as_timestamp(now())|timestamp_custom('%d %b: %X') %}
          {% set user = states.person|selectattr('attributes.user_id','eq',id)|first %}
          {% set user = user.attributes.friendly_name %}
          {{time}}: {{user}} played "{{message}}" on {{device}} in {{language}}

and the script:

script:
  intercom_text_message:
    alias: 'Intercom text message'
    icon: mdi:text-to-speech
    sequence:
      - condition: state
        entity_id: input_boolean.announce_intercom
        state: 'on'
      - service: media_player.volume_set
        data_template:
          entity_id: >
            {{states('sensor.intercom')}}
          volume_level: >
            {{states('input_number.intercom_volume')|float}}
      - service: tts.google_say
        data_template:
          language: >
            {{states('input_select.intercom_language')|lower}}
          entity_id: >
            {{states('sensor.intercom')}}
          message: >
            {{states('input_select.intercom_message')}}

thanks for having a look, and any suggestion you might have.

The homeassistant.update_entity service?

yes, Ive thought about that, or adding an entity_id to the sensor (which I dont think is possible) but when to update?
As you can see the automations triggers on state change of the script. Which I would have thought would be when the script is executed immediately, or at least when it would go to ‘off’ again.

This should be enough shouldn’t it? I cant explain the lag…

I could maybe check for the media_player to be ‘off’ again too… because on my auto-entities card for media_players, I see the announcement immediately when it happens.

Maybe with the automation?

    action:
      - service: notify.filed_intercom_messages
        data_template:
          message: >
            {% set message = states('input_select.intercom_message') %}
            ...
      # maybe a little delay here?
      - service: homeassistant.update_entity
        entity_id: sensor.filed_intercom_messages