Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collapse valid state check when creating a state #93655

Merged
merged 1 commit into from
May 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 1 addition & 6 deletions homeassistant/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,6 @@ def valid_entity_id(entity_id: str) -> bool:
return VALID_ENTITY_ID.match(entity_id) is not None


def valid_state(state: str) -> bool:
"""Test if a state is valid."""
return len(state) <= MAX_LENGTH_STATE_STATE


def callback(func: _CallableT) -> _CallableT:
"""Annotation to mark method as safe to call from within the event loop."""
setattr(func, "_hass_callback", True)
Expand Down Expand Up @@ -1256,7 +1251,7 @@ def __init__(
"Format should be <domain>.<object_id>"
)

if not valid_state(state):
if len(state) > MAX_LENGTH_STATE_STATE:
raise InvalidStateError(
f"Invalid state encountered for entity ID: {entity_id}. "
"State max length is 255 characters."
Expand Down