SR04M ultrasonic sensor time

Can someone tell me how to get the travel time instead of distance from and SC04M ultrasonic sensor, please?

New to ESPHome and Home Assistant so apologies if this is a daft question!

Using the sensor to measure oil level in a plastic storage tank. But the oil level is varying with temperature throughout the day. Could be a mixture of the plastic tank expanding and contracting plus the speed of sound changing due to temperature

The ESPHome code uses the following function to convert the measured time (which is the time it took for the sensor to hear its echo) to a distance:

float UltrasonicSensorComponent::us_to_m(uint32_t us) {
  const float speed_sound_m_per_s = 343.0f;
  const float time_s = us / 1e6f;
  const float total_dist = time_s * speed_sound_m_per_s;
  return total_dist / 2.0f;
}

So to get back the number of microseconds it took, taking the distance as an input:

(distance * 2) / 343 * 1000000

It doesn’t look like there’s a way to get the travel time directly.

Thanks! @robertklep