Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions homeassistant/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,12 @@ def log_error(msg: str, link: bool = True) -> None:
if hasattr(component, 'async_setup'):
result = await component.async_setup( # type: ignore
hass, processed_config)
else:
elif hasattr(component, 'setup'):
result = await hass.async_add_executor_job(
component.setup, hass, processed_config) # type: ignore
else:
log_error("No setup function defined.")
return False
except Exception: # pylint: disable=broad-except
_LOGGER.exception("Error during setup of component %s", domain)
async_notify_setup_error(hass, domain, True)
Expand All @@ -176,15 +179,15 @@ def log_error(msg: str, link: bool = True) -> None:
for entry in hass.config_entries.async_entries(domain):
await entry.async_setup(hass, integration=integration)

hass.config.components.add(component.DOMAIN) # type: ignore
hass.config.components.add(domain)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we use component.DOMAIN in other places, or does this mean we don't need to define DOMAIN anymore?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes because of manifest

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's optional now. I think that it's still good to keep around and use it to as a key for hass.data etc, because it allows for people to easily copy an integration and change the DOMAIN value to make a copy.


# Cleanup
if domain in hass.data[DATA_SETUP]:
hass.data[DATA_SETUP].pop(domain)

hass.bus.async_fire(
EVENT_COMPONENT_LOADED,
{ATTR_COMPONENT: component.DOMAIN} # type: ignore
{ATTR_COMPONENT: domain}
)

return True
Expand Down