[schema] Get component name if available for deprecation warning (#8785)

This commit is contained in:
Jesse Hills 2025-05-14 13:25:21 +12:00 committed by GitHub
parent f28a373898
commit a835ab48bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2077,14 +2077,20 @@ def rename_key(old_key, new_key):
# Remove before 2025.11.0
def deprecated_schema_constant(entity_type: str):
def validator(config):
type: str = "unknown"
if (id := config.get(CONF_ID)) is not None and isinstance(id, core.ID):
type = str(id.type).split("::", maxsplit=1)[0]
_LOGGER.warning(
"Using `%s.%s_SCHEMA` is deprecated and will be removed in ESPHome 2025.11.0. "
"Please use `%s.%s_schema(...)` instead. "
"If you are seeing this, report an issue to the external_component author and ask them to update it.",
"If you are seeing this, report an issue to the external_component author and ask them to update it. "
"https://developers.esphome.io/blog/2025/05/14/_schema-deprecations/. "
"Component using this schema: %s",
entity_type,
entity_type.upper(),
entity_type,
entity_type,
type,
)
return config