mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 16:17:20 +00:00
Set state() template round param default to True
This commit is contained in:
parent
3c4ecffa1b
commit
be1ba31ff2
@ -938,17 +938,15 @@ class AllStates:
|
||||
def __call__(
|
||||
self,
|
||||
entity_id: str,
|
||||
rounded: bool | object = _SENTINEL,
|
||||
rounded: bool = True,
|
||||
with_unit: bool = False,
|
||||
) -> str:
|
||||
"""Return the states."""
|
||||
state = _get_state(self._hass, entity_id)
|
||||
if state is None:
|
||||
return STATE_UNKNOWN
|
||||
if rounded is _SENTINEL:
|
||||
rounded = with_unit
|
||||
if rounded or with_unit:
|
||||
return state.format_state(rounded, with_unit) # type: ignore[arg-type]
|
||||
return state.format_state(rounded, with_unit)
|
||||
return state.state
|
||||
|
||||
def __repr__(self) -> str:
|
||||
|
@ -5183,7 +5183,7 @@ def test_state_with_unit_and_rounding(
|
||||
|
||||
assert tpl.async_render() == "23.02 beers"
|
||||
assert tpl2.async_render() == "23.015 beers"
|
||||
assert tpl3.async_render() == 23.015
|
||||
assert tpl3.async_render() == 23.02
|
||||
assert tpl4.async_render() == 23.015
|
||||
assert tpl5.async_render() == "23.02 beers"
|
||||
assert tpl6.async_render() == "23.015 beers"
|
||||
|
Loading…
x
Reference in New Issue
Block a user