Update an entity when loading a dashboard

Hello,

I have a REST API sensor and I’d like to refresh it every time I consult the dashboard.

I don’t really want to make an automation that updates the sensor every x minutes because it’s not useful if I consult the dashboard page 1x per week or 1x per day for example.

Would there be a way to detect when a dashboard page is loaded? Or to put a card in the dashboard that will automatically execute a script each time it is loaded?

Thanks for your help.