mirror of
https://github.com/esphome/esphome.git
synced 2025-07-28 22:26:36 +00:00
[config] Add entity schema consts with deprecation log (#8747)
This commit is contained in:
parent
401c090edd
commit
8324b3244c
@ -88,6 +88,11 @@ def lock_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):
|
||||
await setup_entity(var, config)
|
||||
|
||||
|
@ -83,6 +83,11 @@ def text_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_(
|
||||
var,
|
||||
config,
|
||||
|
@ -81,6 +81,11 @@ def update_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):
|
||||
await setup_entity(var, config)
|
||||
|
||||
|
@ -126,6 +126,11 @@ def valve_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):
|
||||
await setup_entity(var, config)
|
||||
|
||||
|
@ -2072,3 +2072,20 @@ def rename_key(old_key, new_key):
|
||||
return config
|
||||
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user