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

Add LawnMowerActivity.RETURNING to Lawn Mower #124261

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/mqtt/lawn_mower.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ async def async_start_mowing(self) -> None:

async def async_dock(self) -> None:
"""Dock the mower."""
await self._async_operate("dock", LawnMowerActivity.DOCKED)
await self._async_operate("dock", LawnMowerActivity.RETURNING)
mikey0000 marked this conversation as resolved.
Show resolved Hide resolved

async def async_pause(self) -> None:
"""Pause the lawn mower."""
Expand Down
24 changes: 20 additions & 4 deletions tests/components/mqtt/test_lawn_mower.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ async def test_run_lawn_mower_setup_and_state_updates(
state = hass.states.get("lawn_mower.test_lawn_mower")
assert state.state == "mowing"

async_fire_mqtt_message(hass, "test/lawn_mower_stat", "returning")

await hass.async_block_till_done()

state = hass.states.get("lawn_mower.test_lawn_mower")
assert state.state == "returning"

async_fire_mqtt_message(hass, "test/lawn_mower_stat", "docked")

await hass.async_block_till_done()
Expand Down Expand Up @@ -198,6 +205,13 @@ async def test_value_template(
state = hass.states.get("lawn_mower.test_lawn_mower")
assert state.state == "paused"

async_fire_mqtt_message(hass, "test/lawn_mower_stat", '{"val":"returning"}')

await hass.async_block_till_done()

state = hass.states.get("lawn_mower.test_lawn_mower")
assert state.state == "returning"

async_fire_mqtt_message(hass, "test/lawn_mower_stat", '{"val": null}')

await hass.async_block_till_done()
Expand Down Expand Up @@ -262,7 +276,7 @@ async def test_run_lawn_mower_service_optimistic(
mqtt_mock.async_publish.assert_called_once_with("dock-test-topic", "dock", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("lawn_mower.test")
assert state.state == "docked"
assert state.state == "returning"


@pytest.mark.parametrize(
Expand Down Expand Up @@ -362,7 +376,7 @@ async def test_run_lawn_mower_service_optimistic_with_command_templates(
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("lawn_mower.test_lawn_mower")
assert state.state == "docked"
assert state.state == "returning"


@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG])
Expand Down Expand Up @@ -632,7 +646,7 @@ async def test_entity_id_update_discovery_update(
(
SERVICE_DOCK,
"dock",
"docked",
"returning",
"test/lawn_mower_stat",
"dock-test-topic",
),
Expand Down Expand Up @@ -702,7 +716,8 @@ async def test_mqtt_payload_not_a_valid_activity_warning(

assert (
"Invalid activity for lawn_mower.test_lawn_mower: 'painting' "
"(valid activities: ['error', 'paused', 'mowing', 'docked'])" in caplog.text
"(valid activities: ['error', 'paused', 'mowing', 'docked', 'returning'])"
in caplog.text
)


Expand Down Expand Up @@ -774,6 +789,7 @@ async def test_reloadable(
[
("activity_state_topic", "paused", None, "paused"),
("activity_state_topic", "docked", None, "docked"),
("activity_state_topic", "returning", None, "returning"),
("activity_state_topic", "mowing", None, "mowing"),
],
)
Expand Down
Loading