Change lawn_mower state to an enum (#126458)
* Change lawn_mower state to an enum * annotate as string
This commit is contained in:
parent
8a2dccddc5
commit
8eb76ea68d
3 changed files with 3 additions and 5 deletions
|
@ -86,9 +86,7 @@ class LawnMowerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
|||
@property
|
||||
def state(self) -> str | None:
|
||||
"""Return the current state."""
|
||||
if (activity := self.activity) is None:
|
||||
return None
|
||||
return str(activity)
|
||||
return self.activity
|
||||
|
||||
@cached_property
|
||||
def activity(self) -> LawnMowerActivity | None:
|
||||
|
|
|
@ -100,7 +100,7 @@ async def test_mower(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
assert state_changes[0].data["entity_id"] == entity
|
||||
assert state_changes[0].data["new_state"].state == str(next_activity.value)
|
||||
assert state_changes[0].data["new_state"].state == next_activity.value
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
|
|
@ -176,4 +176,4 @@ async def test_lawn_mower_state(hass: HomeAssistant) -> None:
|
|||
lawn_mower.hass = hass
|
||||
lawn_mower.start_mowing()
|
||||
|
||||
assert lawn_mower.state == str(LawnMowerActivity.MOWING)
|
||||
assert lawn_mower.state == LawnMowerActivity.MOWING
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue