mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 02:49:40 +00:00
Move state length validation to StateMachine APIs (#143681)
* Move state length validation to StateMachine async_set method We call validate_state to make sure we do not allow any states into the state machine that have a length>255 so we do not break the recorder. Since async_set_internal already requires callers to pre-validate the state, we can move the check to async_set instead of at State object creation time to avoid needing to check it twice in the hot path (entity write state) * move check in async_set_internal so it only happens on state change * no need to check if same_state
This commit is contained in:
@@ -1711,7 +1711,7 @@ async def test_invalid_state(
|
||||
ent.async_write_ha_state()
|
||||
assert hass.states.get("test.test").state == STATE_UNKNOWN
|
||||
assert (
|
||||
"homeassistant.helpers.entity",
|
||||
"homeassistant.core",
|
||||
logging.ERROR,
|
||||
f"State {long_state} for test.test is longer than 255, "
|
||||
f"falling back to {STATE_UNKNOWN}",
|
||||
|
||||
Reference in New Issue
Block a user