mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Improve generic event typing [EventComponentLoaded] (#114739)
This commit is contained in:
parent
fa7da34298
commit
e0f5559c8f
@ -7,7 +7,7 @@ from homeassistant.const import EVENT_COMPONENT_LOADED
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.setup import ATTR_COMPONENT
|
||||
from homeassistant.setup import EventComponentLoaded
|
||||
|
||||
from . import (
|
||||
area_registry,
|
||||
@ -56,6 +56,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
if panel.async_setup(hass):
|
||||
name = panel.__name__.split(".")[-1]
|
||||
key = f"{DOMAIN}.{name}"
|
||||
hass.bus.async_fire(EVENT_COMPONENT_LOADED, {ATTR_COMPONENT: key})
|
||||
hass.bus.async_fire(
|
||||
EVENT_COMPONENT_LOADED, EventComponentLoaded(component=key)
|
||||
)
|
||||
|
||||
return True
|
||||
|
@ -23,6 +23,7 @@ from homeassistant.helpers.issue_registry import (
|
||||
from homeassistant.helpers.start import async_at_start
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
from homeassistant.setup import EventComponentLoaded
|
||||
|
||||
COMPONENT_LOADED_COOLDOWN = 30
|
||||
DOMAIN = "homeassistant_alerts"
|
||||
@ -99,7 +100,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
)
|
||||
|
||||
@callback
|
||||
def _component_loaded(_: Event) -> None:
|
||||
def _component_loaded(_: Event[EventComponentLoaded]) -> None:
|
||||
refresh_debouncer.async_schedule_call()
|
||||
|
||||
await coordinator.async_refresh()
|
||||
|
@ -455,7 +455,7 @@ async def _async_setup_component( # noqa: C901
|
||||
if domain in hass.data[DATA_SETUP]:
|
||||
hass.data[DATA_SETUP].pop(domain)
|
||||
|
||||
hass.bus.async_fire(EVENT_COMPONENT_LOADED, {ATTR_COMPONENT: domain})
|
||||
hass.bus.async_fire(EVENT_COMPONENT_LOADED, EventComponentLoaded(component=domain))
|
||||
|
||||
return True
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user