mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Add Bluetooth discovery for Snooz Breez devices (#190245)
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
"domain": "snooz",
|
||||
"name": "Snooz",
|
||||
"bluetooth": [
|
||||
{
|
||||
"local_name": "Breez*"
|
||||
},
|
||||
{
|
||||
"local_name": "Snooz*"
|
||||
},
|
||||
|
||||
Generated
+4
@@ -1109,6 +1109,10 @@ BLUETOOTH: Final[list[dict[str, bool | str | int | list[int]]]] = [
|
||||
"domain": "shelly",
|
||||
"manufacturer_id": 2985,
|
||||
},
|
||||
{
|
||||
"domain": "snooz",
|
||||
"local_name": "Breez*",
|
||||
},
|
||||
{
|
||||
"domain": "snooz",
|
||||
"local_name": "Snooz*",
|
||||
|
||||
@@ -31,6 +31,20 @@ NOT_SNOOZ_SERVICE_INFO = BluetoothServiceInfo(
|
||||
source="local",
|
||||
)
|
||||
|
||||
TEST_BREEZ_ADDRESS = "00:00:00:00:0B:FA"
|
||||
TEST_BREEZ_DISPLAY_NAME = "Breez 0BFA"
|
||||
|
||||
# A Breez advertises its name and manufacturer data but no service UUIDs
|
||||
BREEZ_SERVICE_INFO = BluetoothServiceInfo(
|
||||
name="Breez-0BFA",
|
||||
address=TEST_BREEZ_ADDRESS,
|
||||
rssi=-63,
|
||||
manufacturer_data={65552: bytes([0x14]) + bytes([0] * 8)},
|
||||
service_data={},
|
||||
service_uuids=[],
|
||||
source="local",
|
||||
)
|
||||
|
||||
SNOOZ_SERVICE_INFO_PAIRING = BluetoothServiceInfo(
|
||||
name=TEST_SNOOZ_LOCAL_NAME,
|
||||
address=TEST_ADDRESS,
|
||||
|
||||
@@ -4,6 +4,7 @@ from asyncio import Event, sleep
|
||||
from unittest.mock import patch
|
||||
|
||||
from pytest_homeassistant.common import MockConfigEntry
|
||||
from pytest_homeassistant.components.bluetooth import inject_bluetooth_service_info
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.snooz.const import DOMAIN
|
||||
@@ -13,11 +14,13 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from . import (
|
||||
BREEZ_SERVICE_INFO,
|
||||
NOT_SNOOZ_SERVICE_INFO,
|
||||
SNOOZ_SERVICE_INFO_CHARACTERISTIC_NAME,
|
||||
SNOOZ_SERVICE_INFO_NOT_PAIRING,
|
||||
SNOOZ_SERVICE_INFO_PAIRING,
|
||||
TEST_ADDRESS,
|
||||
TEST_BREEZ_DISPLAY_NAME,
|
||||
TEST_PAIRING_TOKEN,
|
||||
TEST_SNOOZ_DISPLAY_NAME,
|
||||
)
|
||||
@@ -89,6 +92,19 @@ async def test_async_step_bluetooth_not_snooz(hass: HomeAssistant) -> None:
|
||||
assert result["reason"] == "not_supported"
|
||||
|
||||
|
||||
async def test_async_step_bluetooth_breez(hass: HomeAssistant) -> None:
|
||||
"""Test a Breez advertisement matches and starts a discovery flow."""
|
||||
inject_bluetooth_service_info(hass, BREEZ_SERVICE_INFO)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
flows = hass.config_entries.flow.async_progress_by_handler(DOMAIN)
|
||||
assert len(flows) == 1
|
||||
assert flows[0]["step_id"] == "bluetooth_confirm"
|
||||
assert flows[0]["context"]["title_placeholders"] == {
|
||||
"name": TEST_BREEZ_DISPLAY_NAME
|
||||
}
|
||||
|
||||
|
||||
async def test_async_step_user_no_devices_found(hass: HomeAssistant) -> None:
|
||||
"""Test setup from service info cache with no devices found."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
||||
Reference in New Issue
Block a user