From 3e33829c7691b6a3b97c5444e5e3b033ced88cc2 Mon Sep 17 00:00:00 2001 From: Baptiste BOQUAIN Date: Wed, 29 Dec 2021 16:12:17 +0100 Subject: [PATCH] add async setup method --- custom_components/beewi_light/light.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/custom_components/beewi_light/light.py b/custom_components/beewi_light/light.py index 5da52af..c841261 100644 --- a/custom_components/beewi_light/light.py +++ b/custom_components/beewi_light/light.py @@ -41,6 +41,17 @@ def setup_platform(hass, config, add_entities, discovery_info=None): _LOGGER.debug(f"Adding light {name} with mac:{mac}") add_entities([BeewiLight(name, mac)]) +async def async_setup_entry(hass, config_entry, async_add_entities): + """Set up the platform from config_entry.""" + _LOGGER.debug( + f"async_setup_entry:setting up the config entry {config_entry.title} " + f"with data:{config_entry.data}" + ) + name = config_entry.data.get(CONF_NAME) or DOMAIN + mac = config_entry.data.get(CONF_ADDRESS) + entity = BeewiLight(name, mac) + async_add_entities([entity]) + class BeewiLight(LightEntity): def __init__(self, name, mac): """Initialize"""