Use async_on_unload from config entry in ZHA (#61015)

* remove DATA_ZHA_DISPATCHERS

* update typing information

* fix rebase
This commit is contained in:
David F. Mulcahey 2021-12-11 11:50:03 -05:00 committed by GitHub
parent 0abfc90870
commit f6ac856b8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 99 additions and 58 deletions

View file

@ -30,18 +30,20 @@ from homeassistant.components.light import (
SUPPORT_FLASH,
SUPPORT_TRANSITION,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
ATTR_SUPPORTED_FEATURES,
STATE_ON,
STATE_UNAVAILABLE,
Platform,
)
from homeassistant.core import State, callback
from homeassistant.core import HomeAssistant, State, callback
from homeassistant.helpers.debounce import Debouncer
from homeassistant.helpers.dispatcher import (
async_dispatcher_connect,
async_dispatcher_send,
)
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.event import async_track_time_interval
import homeassistant.util.color as color_util
@ -52,7 +54,6 @@ from .core.const import (
CHANNEL_ON_OFF,
CONF_DEFAULT_LIGHT_TRANSITION,
DATA_ZHA,
DATA_ZHA_DISPATCHERS,
EFFECT_BLINK,
EFFECT_BREATHE,
EFFECT_DEFAULT_VARIANT,
@ -105,7 +106,11 @@ class LightColorMode(enum.IntEnum):
COLOR_TEMP = 0x02
async def async_setup_entry(hass, config_entry, async_add_entities):
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
):
"""Set up the Zigbee Home Automation light from config entry."""
entities_to_create = hass.data[DATA_ZHA][Platform.LIGHT]
@ -116,7 +121,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
discovery.async_add_entities, async_add_entities, entities_to_create
),
)
hass.data[DATA_ZHA][DATA_ZHA_DISPATCHERS].append(unsub)
config_entry.async_on_unload(unsub)
class BaseLight(LogMixin, light.LightEntity):