Przeglądaj źródła

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 4 miesięcy temu
rodzic
commit
f1c42b5948

+ 2 - 1
custom_components/tuya_local/entity.py

@@ -116,8 +116,9 @@ class TuyaLocalEntity:
 
     async def async_added_to_hass(self):
         self._device.register_entity(self)
+        _LOGGER.debug("Adding %s for %s", self._config.config_id, self._device.name)
         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):
         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:
                 data[ecfg.config_id] = entity_class(device, ecfg)
                 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:
                 _LOGGER.error(
                     "Error adding %s for %s: %s",