Change name to entity_id Text platform error messages (#87963)

pull/88003/head
G Johansson 2023-02-13 12:51:38 +01:00 committed by GitHub
parent ea94a2fbfd
commit 896dd1a36b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -65,16 +65,16 @@ async def _async_set_value(entity: TextEntity, service_call: ServiceCall) -> Non
value = service_call.data[ATTR_VALUE]
if len(value) < entity.min:
raise ValueError(
f"Value {value} for {entity.name} is too short (minimum length"
f"Value {value} for {entity.entity_id} is too short (minimum length"
f" {entity.min})"
)
if len(value) > entity.max:
raise ValueError(
f"Value {value} for {entity.name} is too long (maximum length {entity.max})"
f"Value {value} for {entity.entity_id} is too long (maximum length {entity.max})"
)
if entity.pattern_cmp and not entity.pattern_cmp.match(value):
raise ValueError(
f"Value {value} for {entity.name} doesn't match pattern {entity.pattern}"
f"Value {value} for {entity.entity_id} doesn't match pattern {entity.pattern}"
)
await entity.async_set_value(value)

View File

@ -61,5 +61,5 @@ async def test_text_node(
)
assert str(err.value) == (
f"Value {value} for Text Node 1 1 is too long (maximum length 25)"
f"Value {value} for text.text_node_1_1 is too long (maximum length 25)"
)