mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Add a fast path for _stringify_state when state is already a str (#116295)
This commit is contained in:
parent
eea66921bb
commit
f295172d07
@ -1014,6 +1014,9 @@ class Entity(
|
|||||||
return STATE_UNAVAILABLE
|
return STATE_UNAVAILABLE
|
||||||
if (state := self.state) is None:
|
if (state := self.state) is None:
|
||||||
return STATE_UNKNOWN
|
return STATE_UNKNOWN
|
||||||
|
if type(state) is str: # noqa: E721
|
||||||
|
# fast path for strings
|
||||||
|
return state
|
||||||
if isinstance(state, float):
|
if isinstance(state, float):
|
||||||
# If the entity's state is a float, limit precision according to machine
|
# If the entity's state is a float, limit precision according to machine
|
||||||
# epsilon to make the string representation readable
|
# epsilon to make the string representation readable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user