1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-25 22:52:20 +01:00

[config] Use `cv.UNDEFINED instead of adhoc _UNDEF` objects (#8725)

This commit is contained in:
Jesse Hills
2025-05-09 20:18:52 +12:00
committed by GitHub
parent e1732c4945
commit 8399d894c1
12 changed files with 82 additions and 102 deletions

View File

@@ -152,22 +152,20 @@ TEXT_SENSOR_SCHEMA = (
)
)
_UNDEF = object()
def text_sensor_schema(
class_: MockObjClass = _UNDEF,
class_: MockObjClass = cv.UNDEFINED,
*,
icon: str = _UNDEF,
entity_category: str = _UNDEF,
device_class: str = _UNDEF,
icon: str = cv.UNDEFINED,
entity_category: str = cv.UNDEFINED,
device_class: str = cv.UNDEFINED,
) -> cv.Schema:
schema = TEXT_SENSOR_SCHEMA
if class_ is not _UNDEF:
if class_ is not cv.UNDEFINED:
schema = schema.extend({cv.GenerateID(): cv.declare_id(class_)})
if icon is not _UNDEF:
if icon is not cv.UNDEFINED:
schema = schema.extend({cv.Optional(CONF_ICON, default=icon): cv.icon})
if device_class is not _UNDEF:
if device_class is not cv.UNDEFINED:
schema = schema.extend(
{
cv.Optional(
@@ -175,7 +173,7 @@ def text_sensor_schema(
): validate_device_class
}
)
if entity_category is not _UNDEF:
if entity_category is not cv.UNDEFINED:
schema = schema.extend(
{
cv.Optional(