-
-
Notifications
You must be signed in to change notification settings - Fork 38.2k
Add retry at startup #34656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add retry at startup #34656
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,8 @@ | |
| ) | ||
| import homeassistant.helpers.config_validation as cv | ||
| from homeassistant.helpers.dispatcher import async_dispatcher_send | ||
| from homeassistant.helpers.event import async_call_later | ||
|
|
||
|
|
||
| from .const import ATTR_SOUND_OUTPUT | ||
|
|
||
|
|
@@ -138,15 +140,30 @@ async def async_on_stop(event): | |
| client.clear_state_update_callbacks() | ||
| await client.disconnect() | ||
|
|
||
| hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, async_on_stop) | ||
| async def async_load_platforms(_): | ||
| """Load platforms and event listener.""" | ||
| await async_connect(client) | ||
|
|
||
| await async_connect(client) | ||
| hass.async_create_task( | ||
| hass.helpers.discovery.async_load_platform("media_player", DOMAIN, conf, config) | ||
| ) | ||
| hass.async_create_task( | ||
| hass.helpers.discovery.async_load_platform("notify", DOMAIN, conf, config) | ||
| ) | ||
| if client.connection is None: | ||
| async_call_later(hass, 60, async_load_platforms) | ||
| _LOGGER.warning( | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be another level, if logged at all?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, definitely :P |
||
| "No connection could be made with host %s, retrying in 60 seconds.", | ||
| conf.get(CONF_HOST), | ||
| ) | ||
| return | ||
|
|
||
| hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, async_on_stop) | ||
|
|
||
| hass.async_create_task( | ||
| hass.helpers.discovery.async_load_platform( | ||
| "media_player", DOMAIN, conf, config | ||
| ) | ||
| ) | ||
| hass.async_create_task( | ||
| hass.helpers.discovery.async_load_platform("notify", DOMAIN, conf, config) | ||
| ) | ||
|
|
||
| await async_load_platforms(None) | ||
|
|
||
|
|
||
| async def async_request_configuration(hass, config, conf, client): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be nice to use a back off mechanism like this:
core/homeassistant/components/tibber/__init__.py
Line 51 in 15569f1
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally would be against a back-off mechanism with a max of 15 minutes because I use it to monitor how much TV my kid has watched. Having an offset of up to 15 minutes is not much use if they're allowed 30 minutes in total ;)