Skip to content

Commit ca75581

Browse files
authored
Bump automower-ble to 0.2.7 (#150979)
1 parent f8a8fb5 commit ca75581

File tree

8 files changed

+23
-17
lines changed

8 files changed

+23
-17
lines changed

homeassistant/components/husqvarna_automower_ble/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
from automower_ble.mower import Mower
6+
from automower_ble.protocol import ResponseResult
67
from bleak import BleakError
78
from bleak_retry_connector import close_stale_connections_by_address, get_device
89

@@ -37,12 +38,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: HusqvarnaConfigEntry) ->
3738
device = bluetooth.async_ble_device_from_address(
3839
hass, address, connectable=True
3940
) or await get_device(address)
40-
if not await mower.connect(device):
41-
raise ConfigEntryNotReady
41+
response_result = await mower.connect(device)
42+
if response_result != ResponseResult.OK:
43+
raise ConfigEntryNotReady(
44+
f"Unable to connect to device {address}, mower returned {response_result}"
45+
)
4246
except (TimeoutError, BleakError) as exception:
4347
raise ConfigEntryNotReady(
4448
f"Unable to connect to device {address} due to {exception}"
4549
) from exception
50+
4651
LOGGER.debug("connected and paired")
4752

4853
model = await mower.get_model()

homeassistant/components/husqvarna_automower_ble/coordinator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import TYPE_CHECKING
77

88
from automower_ble.mower import Mower
9+
from automower_ble.protocol import ResponseResult
910
from bleak import BleakError
1011
from bleak_retry_connector import close_stale_connections_by_address
1112

@@ -62,7 +63,7 @@ async def _async_find_device(self):
6263
)
6364

6465
try:
65-
if not await self.mower.connect(device):
66+
if await self.mower.connect(device) is not ResponseResult.OK:
6667
raise UpdateFailed("Failed to connect")
6768
except BleakError as err:
6869
raise UpdateFailed("Failed to connect") from err

homeassistant/components/husqvarna_automower_ble/lawn_mower.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from automower_ble.protocol import MowerActivity, MowerState
5+
from automower_ble.protocol import MowerActivity, MowerState, ResponseResult
66

77
from homeassistant.components import bluetooth
88
from homeassistant.components.lawn_mower import (
@@ -107,7 +107,7 @@ async def async_start_mowing(self) -> None:
107107
device = bluetooth.async_ble_device_from_address(
108108
self.coordinator.hass, self.coordinator.address, connectable=True
109109
)
110-
if not await self.coordinator.mower.connect(device):
110+
if await self.coordinator.mower.connect(device) is not ResponseResult.OK:
111111
return
112112

113113
await self.coordinator.mower.mower_resume()
@@ -126,7 +126,7 @@ async def async_dock(self) -> None:
126126
device = bluetooth.async_ble_device_from_address(
127127
self.coordinator.hass, self.coordinator.address, connectable=True
128128
)
129-
if not await self.coordinator.mower.connect(device):
129+
if await self.coordinator.mower.connect(device) is not ResponseResult.OK:
130130
return
131131

132132
await self.coordinator.mower.mower_park()
@@ -143,7 +143,7 @@ async def async_pause(self) -> None:
143143
device = bluetooth.async_ble_device_from_address(
144144
self.coordinator.hass, self.coordinator.address, connectable=True
145145
)
146-
if not await self.coordinator.mower.connect(device):
146+
if await self.coordinator.mower.connect(device) is not ResponseResult.OK:
147147
return
148148

149149
await self.coordinator.mower.mower_pause()

homeassistant/components/husqvarna_automower_ble/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
"dependencies": ["bluetooth_adapters"],
1313
"documentation": "https://www.home-assistant.io/integrations/husqvarna_automower_ble",
1414
"iot_class": "local_polling",
15-
"requirements": ["automower-ble==0.2.1"]
15+
"requirements": ["automower-ble==0.2.7"]
1616
}

requirements_all.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

requirements_test_all.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/components/husqvarna_automower_ble/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from collections.abc import Generator
44
from unittest.mock import AsyncMock, patch
55

6+
from automower_ble.protocol import ResponseResult
67
import pytest
78

89
from homeassistant.components.husqvarna_automower_ble.const import DOMAIN
@@ -37,7 +38,7 @@ def mock_automower_client(enable_bluetooth: None) -> Generator[AsyncMock]:
3738
),
3839
):
3940
client = mock_client.return_value
40-
client.connect.return_value = True
41+
client.connect.return_value = ResponseResult.OK
4142
client.is_connected.return_value = True
4243
client.get_model.return_value = "305"
4344
client.battery_level.return_value = 100

tests/components/husqvarna_automower_ble/test_init.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from unittest.mock import Mock
44

5-
from bleak import BleakError
5+
from automower_ble.protocol import ResponseResult
66
import pytest
77
from syrupy.assertion import SnapshotAssertion
88

@@ -46,7 +46,7 @@ async def test_setup_retry_connect(
4646
) -> None:
4747
"""Test setup creates expected devices."""
4848

49-
mock_automower_client.connect.return_value = False
49+
mock_automower_client.connect.side_effect = TimeoutError
5050

5151
mock_config_entry.add_to_hass(hass)
5252
await hass.config_entries.async_setup(mock_config_entry.entry_id)
@@ -55,14 +55,13 @@ async def test_setup_retry_connect(
5555
assert mock_config_entry.state is ConfigEntryState.SETUP_RETRY
5656

5757

58-
async def test_setup_failed_connect(
58+
async def test_setup_unknown_error(
5959
hass: HomeAssistant,
6060
mock_automower_client: Mock,
6161
mock_config_entry: MockConfigEntry,
6262
) -> None:
63-
"""Test setup creates expected devices."""
64-
65-
mock_automower_client.connect.side_effect = BleakError
63+
"""Test setup fails when we receive an error from the device."""
64+
mock_automower_client.connect.return_value = ResponseResult.UNKNOWN_ERROR
6665

6766
mock_config_entry.add_to_hass(hass)
6867
await hass.config_entries.async_setup(mock_config_entry.entry_id)

0 commit comments

Comments
 (0)