[config] Add entity schema consts with deprecation log (#8747)

This commit is contained in:
Jesse Hills 2025-05-12 18:31:36 +12:00 committed by GitHub
parent 401c090edd
commit 8324b3244c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 37 additions and 0 deletions

View File

@ -88,6 +88,11 @@ def lock_schema(
return _LOCK_SCHEMA.extend(schema) return _LOCK_SCHEMA.extend(schema)
# Remove before 2025.11.0
LOCK_SCHEMA = lock_schema()
LOCK_SCHEMA.add_extra(cv.deprecated_schema_constant("lock"))
async def _setup_lock_core(var, config): async def _setup_lock_core(var, config):
await setup_entity(var, config) await setup_entity(var, config)

View File

@ -83,6 +83,11 @@ def text_schema(
return _TEXT_SCHEMA.extend(schema) return _TEXT_SCHEMA.extend(schema)
# Remove before 2025.11.0
TEXT_SCHEMA = text_schema()
TEXT_SCHEMA.add_extra(cv.deprecated_schema_constant("text"))
async def setup_text_core_( async def setup_text_core_(
var, var,
config, config,

View File

@ -81,6 +81,11 @@ def update_schema(
return _UPDATE_SCHEMA.extend(schema) return _UPDATE_SCHEMA.extend(schema)
# Remove before 2025.11.0
UPDATE_SCHEMA = update_schema()
UPDATE_SCHEMA.add_extra(cv.deprecated_schema_constant("update"))
async def setup_update_core_(var, config): async def setup_update_core_(var, config):
await setup_entity(var, config) await setup_entity(var, config)

View File

@ -126,6 +126,11 @@ def valve_schema(
return _VALVE_SCHEMA.extend(schema) return _VALVE_SCHEMA.extend(schema)
# Remove before 2025.11.0
VALVE_SCHEMA = valve_schema()
VALVE_SCHEMA.add_extra(cv.deprecated_schema_constant("valve"))
async def _setup_valve_core(var, config): async def _setup_valve_core(var, config):
await setup_entity(var, config) await setup_entity(var, config)

View File

@ -2072,3 +2072,20 @@ def rename_key(old_key, new_key):
return config return config
return validator return validator
# Remove before 2025.11.0
def deprecated_schema_constant(entity_type: str):
def validator(config):
_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.",
entity_type,
entity_type.upper(),
entity_type,
entity_type,
)
return config
return validator