Trigger MQTT update only when washing machine is running

Hey,

I‘m searching a solution for my Watermeter MQTT problem in Home Assistant.

I‘m a watermeter only for my washing machine to get the consumption for each wash cycle.

Is there a way to use a Python script or similar to set a trigger that only retrieves data via MQTT from my AI on the Edge water meter when the washing machine is running?

Because AI on the Edge currently sends data to Home Assistant every 5 minutes, even if the washing machine is not running.

Thank you.
Oliver