1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-02 08:26:41 +01:00

Update hassfest conditions, services and triggers plugins to not require field descriptions (#166954)

Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Erik Montnemery
2026-03-31 13:29:05 +02:00
committed by GitHub
parent 971579f021
commit 80802c9997
5 changed files with 16 additions and 49 deletions

View File

@@ -231,8 +231,8 @@ def validate_conditions(config: Config, integration: Integration) -> None: # no
f"Condition {condition_name} has no description {error_msg_suffix}",
)
# The same check is done for the description in each of the fields of the
# condition schema.
# The same check is done for each of the fields of the condition schema,
# except that we don't enforce that fields have a description.
for field_name, field_schema in condition_schema.get("fields", {}).items():
if "fields" in field_schema:
# This is a section
@@ -249,20 +249,6 @@ def validate_conditions(config: Config, integration: Integration) -> None: # no
),
)
if "description" not in field_schema and integration.core:
try:
strings["conditions"][condition_name]["fields"][field_name][
"description"
]
except KeyError:
integration.add_error(
"conditions",
(
f"Condition {condition_name} has a field {field_name} with no "
f"description {error_msg_suffix}"
),
)
if "selector" in field_schema:
with contextlib.suppress(KeyError):
translation_key = field_schema["selector"]["select"][

View File

@@ -303,8 +303,8 @@ def validate_services(config: Config, integration: Integration) -> None: # noqa
integration, service_name, strings, service_schema
)
# The same check is done for the description in each of the fields of the
# service schema.
# The same check is done for each field in the service schema,
# except that we don't require fields to have a description.
for field_name, field_schema in service_schema.get("fields", {}).items():
if "fields" in field_schema:
# This is a section
@@ -318,17 +318,6 @@ def validate_services(config: Config, integration: Integration) -> None: # noqa
f"Service {service_name} has a field {field_name} with no name {error_msg_suffix}",
)
if "description" not in field_schema and integration.core:
try:
strings["services"][service_name]["fields"][field_name][
"description"
]
except KeyError:
integration.add_error(
"services",
f"Service {service_name} has a field {field_name} with no description {error_msg_suffix}",
)
if "selector" in field_schema:
with contextlib.suppress(KeyError):
translation_key = field_schema["selector"]["select"][

View File

@@ -245,8 +245,8 @@ def validate_triggers(config: Config, integration: Integration) -> None: # noqa
f"Trigger {trigger_name} has no description {error_msg_suffix}",
)
# The same check is done for the description in each of the fields of the
# trigger schema.
# The same check is done for each of the fields of the trigger schema,
# except that we don't enforce that fields have a description.
for field_name, field_schema in trigger_schema.get("fields", {}).items():
if "fields" in field_schema:
# This is a section
@@ -263,20 +263,6 @@ def validate_triggers(config: Config, integration: Integration) -> None: # noqa
),
)
if "description" not in field_schema and integration.core:
try:
strings["triggers"][trigger_name]["fields"][field_name][
"description"
]
except KeyError:
integration.add_error(
"triggers",
(
f"Trigger {trigger_name} has a field {field_name} with no "
f"description {error_msg_suffix}"
),
)
if "selector" in field_schema:
with contextlib.suppress(KeyError):
translation_key = field_schema["selector"]["select"][

View File

@@ -35,6 +35,9 @@ CONDITION_DESCRIPTIONS = {
after_offset:
selector:
time: null
after_offset_no_description:
selector:
time: null
""",
CONDITION_ICONS_FILENAME: {"conditions": {"_": {"condition": "mdi:flash"}}},
CONDITION_STRINGS_FILENAME: {
@@ -48,6 +51,9 @@ CONDITION_DESCRIPTIONS = {
"name": "Offset",
"description": "The offset.",
},
"after_offset_no_description": {
"name": "Offset",
},
},
}
}
@@ -105,10 +111,8 @@ CONDITION_DESCRIPTIONS = {
"has no name",
"has no description",
"field after with no name",
"field after with no description",
"field after with a selector with a translation key",
"field after_offset with no name",
"field after_offset with no description",
],
},
}

View File

@@ -32,6 +32,9 @@ TRIGGER_DESCRIPTIONS = {
offset:
selector:
time: null
offset_no_description:
selector:
time: null
""",
TRIGGER_ICONS_FILENAME: {"triggers": {"_": {"trigger": "mdi:flash"}}},
TRIGGER_STRINGS_FILENAME: {
@@ -42,6 +45,7 @@ TRIGGER_DESCRIPTIONS = {
"fields": {
"event": {"name": "Event", "description": "The event."},
"offset": {"name": "Offset", "description": "The offset."},
"offset_no_description": {"name": "Offset"},
},
}
}
@@ -99,10 +103,8 @@ TRIGGER_DESCRIPTIONS = {
"has no name",
"has no description",
"field event with no name",
"field event with no description",
"field event with a selector with a translation key",
"field offset with no name",
"field offset with no description",
],
},
}