Make use of generic EntityComponent (part 2) (#78494)
This commit is contained in:
parent
bbf54e6f44
commit
64988521bb
21 changed files with 108 additions and 63 deletions
|
@ -41,10 +41,12 @@ class ButtonDeviceClass(StrEnum):
|
|||
|
||||
DEVICE_CLASSES_SCHEMA = vol.All(vol.Lower, vol.Coerce(ButtonDeviceClass))
|
||||
|
||||
# mypy: disallow-any-generics
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up Button entities."""
|
||||
component = hass.data[DOMAIN] = EntityComponent(
|
||||
component = hass.data[DOMAIN] = EntityComponent[ButtonEntity](
|
||||
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
|
||||
)
|
||||
await component.async_setup(config)
|
||||
|
@ -60,13 +62,13 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Set up a config entry."""
|
||||
component: EntityComponent = hass.data[DOMAIN]
|
||||
component: EntityComponent[ButtonEntity] = hass.data[DOMAIN]
|
||||
return await component.async_setup_entry(entry)
|
||||
|
||||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Unload a config entry."""
|
||||
component: EntityComponent = hass.data[DOMAIN]
|
||||
component: EntityComponent[ButtonEntity] = hass.data[DOMAIN]
|
||||
return await component.async_unload_entry(entry)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue