Make use of generic EntityComponent (part 2) (#78494)

This commit is contained in:
epenet 2022-09-17 18:18:53 +02:00 committed by GitHub
parent bbf54e6f44
commit 64988521bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 108 additions and 63 deletions

View file

@ -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)