How to update esphome text_sensor when attribute no longer exists

I use the following esphome code to display the name of the currently playing media item:

text_sensor:
  - platform: homeassistant
    name: "Current Media Title"
    entity_id: media_player.squeezelite_lounge
    attribute: media_title
    id: media_title
    on_value:
      then:
        - component.update: esp_display

This works fine.

However, if I use the command media_player.clearplaylist, the attribute media_title is removed entirely (its not set to blank/null). Because of this, esphome is never updated and still shows the (pre cleared) media title.

Ideally I’d like to fix this in esphome code, but I think I might only be able to solve this by wrapping the attribute in its own template sensor ?

So, your Esphome text sensor displays the media player atribute (media title) then when you press “media_player.clearplaylist” the attribute is cleared and nothing is displayed as a value for your text sensor?

I’m not understanding what the problem is here.

When the attribute is cleared in HA, nothing is ever sent to esphome, so it doesn’t clear.