mirror of
https://github.com/home-assistant/core.git
synced 2025-09-12 00:01:43 +02:00
Update husqvarna_automower_ble bluetooth discovery checks (#151225)
This commit is contained in:
@@ -34,12 +34,8 @@ def _is_supported(discovery_info: BluetoothServiceInfo):
|
|||||||
service == "98bd0001-0b0e-421a-84e5-ddbf75dc6de4"
|
service == "98bd0001-0b0e-421a-84e5-ddbf75dc6de4"
|
||||||
for service in discovery_info.service_uuids
|
for service in discovery_info.service_uuids
|
||||||
)
|
)
|
||||||
service_generic = any(
|
|
||||||
service == "00001800-0000-1000-8000-00805f9b34fb"
|
|
||||||
for service in discovery_info.service_uuids
|
|
||||||
)
|
|
||||||
|
|
||||||
return manufacturer and service_husqvarna and service_generic
|
return manufacturer and service_husqvarna
|
||||||
|
|
||||||
|
|
||||||
def _pin_valid(pin: str) -> bool:
|
def _pin_valid(pin: str) -> bool:
|
||||||
|
@@ -17,7 +17,6 @@ AUTOMOWER_SERVICE_INFO = BluetoothServiceInfo(
|
|||||||
manufacturer_data={1062: b"\x05\x04\xbf\xcf\xbb\r"},
|
manufacturer_data={1062: b"\x05\x04\xbf\xcf\xbb\r"},
|
||||||
service_uuids=[
|
service_uuids=[
|
||||||
"98bd0001-0b0e-421a-84e5-ddbf75dc6de4",
|
"98bd0001-0b0e-421a-84e5-ddbf75dc6de4",
|
||||||
"00001800-0000-1000-8000-00805f9b34fb",
|
|
||||||
],
|
],
|
||||||
source="local",
|
source="local",
|
||||||
)
|
)
|
||||||
@@ -30,7 +29,6 @@ AUTOMOWER_UNNAMED_SERVICE_INFO = BluetoothServiceInfo(
|
|||||||
manufacturer_data={1062: b"\x05\x04\xbf\xcf\xbb\r"},
|
manufacturer_data={1062: b"\x05\x04\xbf\xcf\xbb\r"},
|
||||||
service_uuids=[
|
service_uuids=[
|
||||||
"98bd0001-0b0e-421a-84e5-ddbf75dc6de4",
|
"98bd0001-0b0e-421a-84e5-ddbf75dc6de4",
|
||||||
"00001800-0000-1000-8000-00805f9b34fb",
|
|
||||||
],
|
],
|
||||||
source="local",
|
source="local",
|
||||||
)
|
)
|
||||||
@@ -43,7 +41,6 @@ AUTOMOWER_MISSING_MANUFACTURER_DATA_SERVICE_INFO = BluetoothServiceInfo(
|
|||||||
manufacturer_data={},
|
manufacturer_data={},
|
||||||
service_uuids=[
|
service_uuids=[
|
||||||
"98bd0001-0b0e-421a-84e5-ddbf75dc6de4",
|
"98bd0001-0b0e-421a-84e5-ddbf75dc6de4",
|
||||||
"00001800-0000-1000-8000-00805f9b34fb",
|
|
||||||
],
|
],
|
||||||
source="local",
|
source="local",
|
||||||
)
|
)
|
||||||
|
@@ -13,9 +13,9 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
|
AUTOMOWER_MISSING_MANUFACTURER_DATA_SERVICE_INFO,
|
||||||
AUTOMOWER_SERVICE_INFO,
|
AUTOMOWER_SERVICE_INFO,
|
||||||
AUTOMOWER_UNNAMED_SERVICE_INFO,
|
AUTOMOWER_UNNAMED_SERVICE_INFO,
|
||||||
AUTOMOWER_UNSUPPORTED_GROUP_SERVICE_INFO,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
@@ -277,13 +277,15 @@ async def test_bluetooth_not_paired(
|
|||||||
async def test_bluetooth_invalid(hass: HomeAssistant) -> None:
|
async def test_bluetooth_invalid(hass: HomeAssistant) -> None:
|
||||||
"""Test bluetooth device discovery with invalid data."""
|
"""Test bluetooth device discovery with invalid data."""
|
||||||
|
|
||||||
inject_bluetooth_service_info(hass, AUTOMOWER_UNSUPPORTED_GROUP_SERVICE_INFO)
|
inject_bluetooth_service_info(
|
||||||
|
hass, AUTOMOWER_MISSING_MANUFACTURER_DATA_SERVICE_INFO
|
||||||
|
)
|
||||||
await hass.async_block_till_done(wait_background_tasks=True)
|
await hass.async_block_till_done(wait_background_tasks=True)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": SOURCE_BLUETOOTH},
|
context={"source": SOURCE_BLUETOOTH},
|
||||||
data=AUTOMOWER_UNSUPPORTED_GROUP_SERVICE_INFO,
|
data=AUTOMOWER_MISSING_MANUFACTURER_DATA_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] is FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
Reference in New Issue
Block a user