Sen5x start/stop measurement to improve battery life

The sen5x (e.g., SEN50, SEN54, SEN55) have the ability to be switched between idle mode, RHT/gas-only, and measurement mode. The current draw in measurement mode is 63 mA. The current draw in idle mode is about 2.6 mA. Sensirion’s documents indicate that I should set the device to measurement mode for ~30s (to accumulate statistics) before taking a reading. Assuming I want a measurement every 5 minutes, the ideal power consumption scenario would be:

  • Deep sleep for 4 minutes, 30 seconds.
  • Wake up, set device to measurement mode.
  • Deep sleep for 30 seconds.
  • Wake up, take readings. Post to MQTT.
  • Go back to step 1.

It looks like the current sen5x component is a PollingComponent and assumes that the device is always in measurement mode. I am happy to modify this for my needs, but I’m not sure what the best approach would be. I tried adding a line of code to start the measurement mode at the beginning of the update method and then added sleep(30). This seems to work, but Home Assistant does not like this (nor does esphome logs) as it causes ping to timeout. Is there a way I can configure this to temporarily pause execution of update (like a coroutine) to prevent HA API fro complaining?