philips-airpurifier-coap icon indicating copy to clipboard operation
philips-airpurifier-coap copied to clipboard

HA hangs during device setup if device is not responsive

Open kongo09 opened this issue 2 years ago • 2 comments

During setup of entry at HA start devices might not be responsive and thus hang the process.

  • Try to detect this situation and let HA continue setup
  • Use callback to complete setup once the device is online / answers

kongo09 avatar May 03 '22 09:05 kongo09

On the current core-2022.6.0.dev0 there doesn't seem to be a hang anymore. If the device is not online, HA tries repeatedly in the background without blocking. Maybe this is solved on a higher level?

kongo09 avatar May 03 '22 16:05 kongo09

Hm, there seem to be two different cases:

  • async_setup_entry is called, but we cannot get a valid CoAPClient -> throwing the ConfigEntryNotReady exception causes HA to continue with the rest of the startup and retry this setup in the background
  • if we get past this stage, a Coordinator is created, which will then be asked to async_first_refresh -> this is where it hangs. The timer eventually expires and that might get it back going
022-05-03 17:20:48 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration philips_airpurifier_coap which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2022-05-03 17:21:25 INFO (MainThread) [custom_components.philips_airpurifier_coap] async_setup called
2022-05-03 17:21:26 INFO (MainThread) [custom_components.philips_airpurifier_coap] async_setup_entry called for host 192.168.179.26
2022-05-03 17:21:27 INFO (MainThread) [custom_components.philips_airpurifier_coap] got a valid client for host 192.168.179.26
2022-05-03 17:21:27 INFO (MainThread) [custom_components.philips_airpurifier_coap.philips] init: Creating and autostarting timer for host 192.168.179.26
2022-05-03 17:21:27 INFO (MainThread) [custom_components.philips_airpurifier_coap.philips] init: finished for host 192.168.179.26
2022-05-03 17:21:27 INFO (MainThread) [custom_components.philips_airpurifier_coap] got a valid coordinator for host 192.168.179.26
2022-05-03 17:21:27 INFO (MainThread) [custom_components.philips_airpurifier_coap.philips] async_first_refresh for host 192.168.179.26
2022-05-03 17:22:18 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: philips_airpurifier_coap
2022-05-03 17:23:19 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: philips_airpurifier_coap
2022-05-03 17:24:19 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: philips_airpurifier_coap
2022-05-03 17:24:27 INFO (MainThread) [custom_components.philips_airpurifier_coap.timer] Calling timeout callback...
2022-05-03 17:24:27 INFO (MainThread) [custom_components.philips_airpurifier_coap.philips] reconnect: called for host 192.168.179.26
2022-05-03 17:24:27 INFO (MainThread) [custom_components.philips_airpurifier_coap.philips] reconnect: creating new reconnect task for host 192.168.179.26
2022-05-03 17:24:27 INFO (MainThread) [custom_components.philips_airpurifier_coap.philips] Reconnecting...
2022-05-03 17:24:27 ERROR (MainThread) [custom_components.philips_airpurifier_coap.philips] config not ready, first refresh failed for host 192.168.179.26
2022-05-03 17:24:27 WARNING (MainThread) [homeassistant.config_entries] Config entry 'AC2729 Schlafzimmer' for philips_airpurifier_coap integration not ready yet; Retrying in background
2022-05-03 17:24:28 INFO (MainThread) [custom_components.philips_airpurifier_coap] async_setup_entry called for host 192.168.179.26
2022-05-03 17:24:28 INFO (MainThread) [custom_components.philips_airpurifier_coap] got a valid client for host 192.168.179.26
2022-05-03 17:24:28 INFO (MainThread) [custom_components.philips_airpurifier_coap.philips] init: Creating and autostarting timer for host 192.168.179.26
2022-05-03 17:24:28 INFO (MainThread) [custom_components.philips_airpurifier_coap.philips] init: finished for host 192.168.179.26
2022-05-03 17:24:28 INFO (MainThread) [custom_components.philips_airpurifier_coap] got a valid coordinator for host 192.168.179.26
2022-05-03 17:24:28 INFO (MainThread) [custom_components.philips_airpurifier_coap.philips] async_first_refresh for host 192.168.179.26
2022-05-03 17:24:31 INFO (MainThread) [custom_components.philips_airpurifier_coap.philips] finished first refresh for host 192.168.179.26
2022-05-03 17:24:31 INFO (MainThread) [custom_components.philips_airpurifier_coap] coordinator did first refresh for host 192.168.179.26
2022-05-03 17:24:31 INFO (MainThread) [custom_components.philips_airpurifier_coap.philips] PhilipsEntity __init__ called

kongo09 avatar May 03 '22 17:05 kongo09