瀏覽代碼

fix: improve logging for entity addition and deprecation warnings

Do not output deprecation logs from async_tuya_setup_platform
  - this function is called for all entities in the config file
Remove stack trace from deprecation warning in async_added_to_hass
  - after confirmation that this was not involved in the unwanted
    deprecation log messages

Issue #3761, #3727, #3726, #3724 and others
Jason Rumney 8 月之前
父節點
當前提交
f1c42b5948
共有 2 個文件被更改,包括 2 次插入4 次删除
  1. 2 1
      custom_components/tuya_local/entity.py
  2. 0 3
      custom_components/tuya_local/helpers/config.py

+ 2 - 1
custom_components/tuya_local/entity.py

@@ -116,8 +116,9 @@ class TuyaLocalEntity:
 
 
     async def async_added_to_hass(self):
     async def async_added_to_hass(self):
         self._device.register_entity(self)
         self._device.register_entity(self)
+        _LOGGER.debug("Adding %s for %s", self._config.config_id, self._device.name)
         if self._config.deprecated:
         if self._config.deprecated:
-            _LOGGER.warning(self._config.deprecation_message, stack_info=True)
+            _LOGGER.warning(self._config.deprecation_message)
 
 
     async def async_will_remove_from_hass(self):
     async def async_will_remove_from_hass(self):
         await self._device.async_unregister_entity(self)
         await self._device.async_unregister_entity(self)

+ 0 - 3
custom_components/tuya_local/helpers/config.py

@@ -30,9 +30,6 @@ async def async_tuya_setup_platform(
             try:
             try:
                 data[ecfg.config_id] = entity_class(device, ecfg)
                 data[ecfg.config_id] = entity_class(device, ecfg)
                 entities.append(data[ecfg.config_id])
                 entities.append(data[ecfg.config_id])
-                if ecfg.deprecated:
-                    _LOGGER.warning(ecfg.deprecation_message)
-                _LOGGER.debug("Adding %s for %s", platform, ecfg.config_id)
             except Exception as e:
             except Exception as e:
                 _LOGGER.error(
                 _LOGGER.error(
                     "Error adding %s for %s: %s",
                     "Error adding %s for %s: %s",