Integration waits for first data - best practice

For a HA integration, I am looking for the best practice to wait for the first data. I have a TCP listener that receives data within a minimum of five minutes to max several hours (because the PV inverters are offline). The data contains devices and entities (unknown in advance how many). I can’t forward the input configuration to sensors.py for the platform configuration until I have data.

What I’ve done so far is wait with the coordinator async_config_entry_first_refresh(), but this has some negative side effects.

  • During HA restart, the persistent message: “not everything will be available until it’s done” is displayed for a longer period of time
  • When the integration is first set up it keeps initializing until the first data is available

Is there another way to approach this case? Serve dummy data and correct later? Introduce an update listener?

I would maybe have a single sensor entity created at startup to show some sort of status of the PV updates, like waiting for first update/ last update etc.

When you get updates from the PV controller, check if the entities have been created and create if not, then update them all.

This will not hold up the startup, ensure your component is loaded and will give some indication that it is waiting for first update.

EDIT. Should add, once the integration has had a first update and created the entities, on next restart, entities will still show but show as not being provided by integration. That might be ok as they will become available once first update afer restart happens.

The otherway maybe store the entities after first update after install. Recreate these from stored info on future reboots but with an unavailable status or restored value until data received.

Thanks Mark, I can indeed try a dummy sensor entity to start with.