|
|
@@ -23,21 +23,39 @@ async def async_tuya_setup_platform(
|
|
|
raise ValueError(f"No device config found for {discovery_info}")
|
|
|
ecfg = cfg.primary_entity
|
|
|
if ecfg.entity == platform:
|
|
|
- data[ecfg.config_id] = entity_class(device, ecfg)
|
|
|
- entities.append(data[ecfg.config_id])
|
|
|
- if ecfg.deprecated:
|
|
|
- _LOGGER.warning(ecfg.deprecation_message)
|
|
|
- _LOGGER.debug(f"Adding {platform} for {ecfg.config_id}")
|
|
|
-
|
|
|
- for ecfg in cfg.secondary_entities():
|
|
|
- if ecfg.entity == platform:
|
|
|
+ try:
|
|
|
data[ecfg.config_id] = entity_class(device, ecfg)
|
|
|
entities.append(data[ecfg.config_id])
|
|
|
if ecfg.deprecated:
|
|
|
_LOGGER.warning(ecfg.deprecation_message)
|
|
|
- _LOGGER.debug(f"Adding {platform} for {ecfg.config_id}")
|
|
|
+ _LOGGER.debug(f"Adding %s for %s", platform, ecfg.config_id)
|
|
|
+ except Exception as e:
|
|
|
+ _LOGGER.error(
|
|
|
+ f"Error adding %s for %s: %s",
|
|
|
+ ecfg.config_id,
|
|
|
+ cfg.config,
|
|
|
+ e,
|
|
|
+ )
|
|
|
+
|
|
|
+ for ecfg in cfg.secondary_entities():
|
|
|
+ if ecfg.entity == platform:
|
|
|
+ try:
|
|
|
+ data[ecfg.config_id] = entity_class(device, ecfg)
|
|
|
+ entities.append(data[ecfg.config_id])
|
|
|
+ if ecfg.deprecated:
|
|
|
+ _LOGGER.warning(ecfg.deprecation_message)
|
|
|
+ _LOGGER.debug(f"Adding %s for %s", platform, ecfg.config_id)
|
|
|
+ except Exception as e:
|
|
|
+ _LOGGER.error(
|
|
|
+ f"Error adding %s for %s: %s",
|
|
|
+ ecfg.config_id,
|
|
|
+ cfg.config,
|
|
|
+ e,
|
|
|
+ )
|
|
|
+
|
|
|
if not entities:
|
|
|
raise ValueError(f"{device.name} does not support use as a {platform} device.")
|
|
|
+
|
|
|
async_add_entities(entities)
|
|
|
|
|
|
|