Bump aioautomower to 2024.5.0 (#116942)

This commit is contained in:
Thomas55555 2024-05-07 00:59:34 +02:00 committed by GitHub
parent 486b8ca7c4
commit 8e66e5bb11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 46 additions and 20 deletions

View File

@ -83,7 +83,7 @@ class AutomowerLawnMowerEntity(AutomowerControlEntity, LawnMowerEntity):
async def async_start_mowing(self) -> None:
"""Resume schedule."""
try:
await self.coordinator.api.resume_schedule(self.mower_id)
await self.coordinator.api.commands.resume_schedule(self.mower_id)
except ApiException as exception:
raise HomeAssistantError(
f"Command couldn't be sent to the command queue: {exception}"
@ -92,7 +92,7 @@ class AutomowerLawnMowerEntity(AutomowerControlEntity, LawnMowerEntity):
async def async_pause(self) -> None:
"""Pauses the mower."""
try:
await self.coordinator.api.pause_mowing(self.mower_id)
await self.coordinator.api.commands.pause_mowing(self.mower_id)
except ApiException as exception:
raise HomeAssistantError(
f"Command couldn't be sent to the command queue: {exception}"
@ -101,7 +101,7 @@ class AutomowerLawnMowerEntity(AutomowerControlEntity, LawnMowerEntity):
async def async_dock(self) -> None:
"""Parks the mower until next schedule."""
try:
await self.coordinator.api.park_until_next_schedule(self.mower_id)
await self.coordinator.api.commands.park_until_next_schedule(self.mower_id)
except ApiException as exception:
raise HomeAssistantError(
f"Command couldn't be sent to the command queue: {exception}"

View File

@ -7,5 +7,5 @@
"documentation": "https://www.home-assistant.io/integrations/husqvarna_automower",
"iot_class": "cloud_push",
"loggers": ["aioautomower"],
"requirements": ["aioautomower==2024.4.4"]
"requirements": ["aioautomower==2024.5.0"]
}

View File

@ -49,7 +49,7 @@ async def async_set_work_area_cutting_height(
work_area_id: int,
) -> None:
"""Set cutting height for work area."""
await coordinator.api.set_cutting_height_workarea(
await coordinator.api.commands.set_cutting_height_workarea(
mower_id, int(cheight), work_area_id
)
# As there are no updates from the websocket regarding work area changes,
@ -58,6 +58,15 @@ async def async_set_work_area_cutting_height(
await coordinator.async_request_refresh()
async def async_set_cutting_height(
session: AutomowerSession,
mower_id: str,
cheight: float,
) -> None:
"""Set cutting height."""
await session.commands.set_cutting_height(mower_id, int(cheight))
@dataclass(frozen=True, kw_only=True)
class AutomowerNumberEntityDescription(NumberEntityDescription):
"""Describes Automower number entity."""
@ -77,9 +86,7 @@ NUMBER_TYPES: tuple[AutomowerNumberEntityDescription, ...] = (
native_max_value=9,
exists_fn=lambda data: data.cutting_height is not None,
value_fn=_async_get_cutting_height,
set_value_fn=lambda session, mower_id, cheight: session.set_cutting_height(
mower_id, int(cheight)
),
set_value_fn=async_set_cutting_height,
),
)

View File

@ -64,7 +64,7 @@ class AutomowerSelectEntity(AutomowerControlEntity, SelectEntity):
async def async_select_option(self, option: str) -> None:
"""Change the selected option."""
try:
await self.coordinator.api.set_headlight_mode(
await self.coordinator.api.commands.set_headlight_mode(
self.mower_id, cast(HeadlightModes, option.upper())
)
except ApiException as exception:

View File

@ -78,7 +78,7 @@ class AutomowerSwitchEntity(AutomowerControlEntity, SwitchEntity):
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the entity off."""
try:
await self.coordinator.api.park_until_further_notice(self.mower_id)
await self.coordinator.api.commands.park_until_further_notice(self.mower_id)
except ApiException as exception:
raise HomeAssistantError(
f"Command couldn't be sent to the command queue: {exception}"
@ -87,7 +87,7 @@ class AutomowerSwitchEntity(AutomowerControlEntity, SwitchEntity):
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the entity on."""
try:
await self.coordinator.api.resume_schedule(self.mower_id)
await self.coordinator.api.commands.resume_schedule(self.mower_id)
except ApiException as exception:
raise HomeAssistantError(
f"Command couldn't be sent to the command queue: {exception}"

View File

@ -201,7 +201,7 @@ aioaseko==0.1.1
aioasuswrt==1.4.0
# homeassistant.components.husqvarna_automower
aioautomower==2024.4.4
aioautomower==2024.5.0
# homeassistant.components.azure_devops
aioazuredevops==2.0.0

View File

@ -180,7 +180,7 @@ aioaseko==0.1.1
aioasuswrt==1.4.0
# homeassistant.components.husqvarna_automower
aioautomower==2024.4.4
aioautomower==2024.5.0
# homeassistant.components.azure_devops
aioazuredevops==2.0.0

View File

@ -90,5 +90,6 @@ def mock_automower_client() -> Generator[AsyncMock, None, None]:
return ClientWebSocketResponse
client.auth = AsyncMock(side_effect=websocket_connect)
client.commands = AsyncMock()
yield client

View File

@ -5,6 +5,22 @@
'battery_percent': 100,
}),
'calendar': dict({
'events': list([
dict({
'end': '2024-05-07T00:00:00+00:00',
'rrule': 'FREQ=WEEKLY;BYDAY=MO,WE,FR',
'start': '2024-05-06T19:00:00+00:00',
'uid': '1140_300_MO,WE,FR',
'work_area_id': None,
}),
dict({
'end': '2024-05-07T08:00:00+00:00',
'rrule': 'FREQ=WEEKLY;BYDAY=TU,TH,SA',
'start': '2024-05-07T00:00:00+00:00',
'uid': '0_480_TU,TH,SA',
'work_area_id': None,
}),
]),
'tasks': list([
dict({
'duration': 300,

View File

@ -71,9 +71,9 @@ async def test_lawn_mower_commands(
"""Test lawn_mower commands."""
await setup_integration(hass, mock_config_entry)
getattr(mock_automower_client, aioautomower_command).side_effect = ApiException(
"Test error"
)
getattr(
mock_automower_client.commands, aioautomower_command
).side_effect = ApiException("Test error")
with pytest.raises(HomeAssistantError) as exc_info:
await hass.services.async_call(

View File

@ -35,7 +35,7 @@ async def test_number_commands(
service_data={"value": "3"},
blocking=True,
)
mocked_method = mock_automower_client.set_cutting_height
mocked_method = mock_automower_client.commands.set_cutting_height
assert len(mocked_method.mock_calls) == 1
mocked_method.side_effect = ApiException("Test error")
@ -68,7 +68,9 @@ async def test_number_workarea_commands(
values[TEST_MOWER_ID].work_areas[123456].cutting_height = 75
mock_automower_client.get_status.return_value = values
mocked_method = AsyncMock()
setattr(mock_automower_client, "set_cutting_height_workarea", mocked_method)
setattr(
mock_automower_client.commands, "set_cutting_height_workarea", mocked_method
)
await hass.services.async_call(
domain="number",
service="set_value",

View File

@ -81,7 +81,7 @@ async def test_select_commands(
},
blocking=True,
)
mocked_method = mock_automower_client.set_headlight_mode
mocked_method = mock_automower_client.commands.set_headlight_mode
assert len(mocked_method.mock_calls) == 1
mocked_method.side_effect = ApiException("Test error")

View File

@ -76,7 +76,7 @@ async def test_switch_commands(
service_data={"entity_id": "switch.test_mower_1_enable_schedule"},
blocking=True,
)
mocked_method = getattr(mock_automower_client, aioautomower_command)
mocked_method = getattr(mock_automower_client.commands, aioautomower_command)
assert len(mocked_method.mock_calls) == 1
mocked_method.side_effect = ApiException("Test error")